This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 164597 - Provide ${class} macro for code templates
Summary: Provide ${class} macro for code templates
Status: VERIFIED FIXED
Alias: None
Product: java
Classification: Unclassified
Component: Editor (show other bugs)
Version: 6.x
Hardware: PC Windows XP
: P3 blocker with 1 vote (vote)
Assignee: _ tboudreau
URL:
Keywords:
Depends on:
Blocks: 179805
  Show dependency tree
 
Reported: 2009-05-06 15:02 UTC by matthies
Modified: 2010-05-26 19:44 UTC (History)
1 user (show)

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description matthies 2009-05-06 15:02:49 UTC
It would be useful if ${class} could be used in code templates to have the name of the current class inserted. For 
example I'd like to define a code template

    protected ${class}() { throw new UnsupportedOperationException(); }

to generate constructors for extendable utility (= only static members) classes.
Comment 1 _ tboudreau 2010-01-21 21:02:24 UTC
Note this is more urgent now that I have added Logger and NbBundle templates to apisupport.project - both must use getClass(), which is more likely to be incorrect - preferable is always to use X.class.getName() but there is no way to reference the containing class from a template.  Need a code template hint for this.
Comment 2 _ tboudreau 2010-01-22 23:48:22 UTC
Fixed in main/ 9ab6fe4a3c92

You can now do
${var currClassName editable="false"}
to use the name of the containing class to the caret position.
Comment 3 Quality Engineering 2010-01-24 08:45:18 UTC
Integrated into 'main-golden', will be available in build *201001240200* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/9ab6fe4a3c92
User: Tim Boudreau <tboudreau@netbeans.org>
Log: #164597 and #179805 - ability to reference containing class in code templates, fix apisupport.project code templates (NbBundle, Logger) not to use getClass().
Comment 4 matthies 2010-05-26 19:44:03 UTC
Verified in 6.9 RC1, thanks!