Please use the Apache issue tracking system for new NetBeans issues (https://issues.apache.org/jira/projects/NETBEANS0/issues) !!
Bug 124375 - Expansion for method , file and class variables does not work for java files
Expansion for method , file and class variables does not work for java files
Status: RESOLVED FIXED
Product: usersguide
Classification: Unclassified
Component: Code
6.x
Sun All
: P3 with 1 vote (vote)
: 6.x
Assigned To: AlyonaStashkova
issues@usersguide
http://www.netbeans.org/servlets/Brow...
:
: 75929 (view as bug list)
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2007-12-21 18:04 UTC by Karthikeyan Rajeswaran
Modified: 2012-11-19 13:14 UTC (History)
5 users (show)

See Also:
Issue Type: DEFECT
:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Karthikeyan Rajeswaran 2007-12-21 18:04:57 UTC
Steps to reproduce:
- Open Tools | Options | Editor | Code Templates
- Click 'New'. Name the template trl and its value as 'System.out.println("${method}");' .
- Close the dialog.
- Create a new java project.
- Open the main class and create a new method.
- Inside the method, type trl and press tab.
- The line 'System.out.println("method");' is printed. 
According to
http://www.netbeans.org/source/browse/*checkout*/java/helpset/javahelp/org/netbeans/modules/java/helpset/docs/editing/editor_template_syntax.html?rev=1.2,
the ${method} should expand to the name of the surrounding method. But it does not happen and only the string 'method'
itself is printed.

(I tried the above using NB6 on Solaris 10 with a fresh userdir).

Issue discussed at: http://www.netbeans.org/servlets/ReadMsg?list=nbusers&msgNo=106607
Comment 1 Karthikeyan Rajeswaran 2007-12-21 18:08:09 UTC
Same behaviour also happens with ${file} , ${class} , $path} , ${methodfqn} and ${classfqn} variables.
Comment 2 misterm 2007-12-21 18:48:24 UTC
I believe these work with Ruby, but they should work in the Java editor as well.
Comment 3 nsydenham 2007-12-21 21:03:36 UTC
*** Issue 75929 has been marked as a duplicate of this issue. ***
Comment 4 Dusan Balek 2008-01-03 15:12:27 UTC
The problem here is misleading documentation of the code template syntax that describes the syntax more or less Ruby
only specific. Mentioned reserved parameter names (method, class, file, etc.) are not valid for Java code templates now
(possible future enhancement?). The correct documentation should contain something like:

Any code template parameter can be specified by its name and a set of optional hints. Hints serve as a guidance on
computing the values assigned by the infrastructure to the parameters on template expansion.
Syntax for parameter definition is:
${param_name hint=value hint=value ...}

with the exception of boolean hints that can be written without the value part:
${param_name hint}  translates to  ${param_name hint=true}.

Some of the parameter names are reserved by the code template infrastructure:
${cursor} defines a position where the caret will be located after the editing of the code template values finishes.
${selection} defines a position for pasting a content of the editor selection. Used by so called 'selection templates'
that appear as hints whenever user selects some text in the editor.

Similarly, some of the hint names are reserved by the code template infrastructure:

General:
${param_name default="value"} defines the parameter's default value.
${param_name editable=false} can be used to disable user's editing of the parameter.

Java specific:
${param_name instanceof="java.util.Collection"} requires the parameter value to be an instance of the given type.
${param_name array} requires the parameter value to be of an array type (including arrays of primitive data types).
${param_name iterable} requires the parameter value to be of an array type or an instance of "java.lang.Iterable". Can
be used in 'for-each' cycles.
${param type="java.util.Iterator"} requires the parameter value to be the given type. The infrastructure will try to use
short name Iterator and import java.util.Iterator if possible.
${param_name iterableElementType} requires the parameter value to be the type of the iterable element. Can be used in
'for-each' cycles.
${param_name leftSideType} requires the parameter value to be the type of the expression on the assignment's left side.
${param_name rightSideType} requires the parameter value to be the type of the expression on the assignment's right side.
${param_name cast} defines that the parameter value would be a type cast if necessary.
${param_name newVarName} defines that the parameter value should be a 'fresh' unused variable name in the given context.

Ruby specific:
...


Reassigning.
Comment 5 Michel Graciano 2008-01-03 15:26:02 UTC
I think it should be implemented to Java too.
Comment 6 Vitezslav Stejskal 2008-01-07 12:05:15 UTC
Dusane, thanks for explanation. Obviously we would like to have all those Ruby specific parameters in Java too, but it
might take some time and in the meantime I think we should correct the documentation so that it doesn't give false
impression that these parameters work everywhere.
Comment 7 Geertjan Wielenga 2008-03-18 16:22:03 UTC
Made several changes to this topic based on the comments in this issue, but need to do more work on it.
Comment 8 Jiri Prox 2008-04-11 00:43:37 UTC
moving opened issues from TM <= 6.1 to TM=Dev
Comment 9 Patrick Keegan 2008-05-05 17:09:15 UTC
switching to usersguide since this is a docs bug
Comment 10 Kenneth Ganfield 2012-11-13 17:34:22 UTC
alyona, can you take a look at this old issue
Comment 11 AlyonaStashkova 2012-11-19 13:14:49 UTC
Java specific code template syntax provided by Dusan Balek is incorporated into the Code Template Syntax help topic by Geertjan Wielenga.
Verified on NetBeans IDE 7.3 Beta 2 (Build 201211052012).

Closing the issue as resolved fixed since support for Ruby is removed from the standard distribution of the IDE (http://wiki.netbeans.org/NetBeansArchivedFeatures#Ruby).


By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2014, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo