Netbeans Code Templates Formatting Syntax

I would like to know what syntax or language is used to format code templates in netbeans ide. I mean, in the default templates, I see things like:

while (${EXP default="exp"}) { ${selection line}${cursor} } 

and

 // <editor-fold defaultstate="collapsed" desc="${comment}"> ${selection}${cursor}// </editor-fold> 

And I experimented and did this:

 int ${IDX newVarName default="loop"}; for (${IDX} = 0; ${IDX} < ${SIZE int default="size"}; ${IDX}++) { ${cursor} } 

And it works, but I really don't know where "$ {IDX}" or "$ {SIZE int default =" size "}" or from "$ {selection} $ {cursor}" and from which other operators I can use to format my templates.

Is this some kind of script or programming language?

Where can I find this information?

+6
source share
2 answers

I think Netbeans uses the Freemarker template engine for this. Thus, all variables (= ${...} ) are populated by Netbeans while using the template.

Unfortunately, I do not have a complete list of all the default variables / methods that you can use, but two of them are listed here:

${cursor} :

determines the position in which the carriage will be located after editing the values ​​of the code template is completed.

${selection} :

defines the position for inserting the contents of the editor selection This is used by the so-called "selection templates", which are displayed as prompts when the user selects some text in the editor.

See here: http://wiki.netbeans.org/Java_EditorUsersGuide#How_to_use_Code_Templates

${IDX} looks like the user variable you are using.

See also:
- Code Support in NetBeans Java IDE Editor: Reference Guide (Code Template)
- NetBeans IDE code templates for PHP

+6
source

How_to_use_Code_Templates pretty much covers everything there is. Looking at CodeTemplateParameter.java , there is another hint called "completeInvoke" in which the requests show a pop-up code completion window for the current lumped text component , but that’s all.

+3
source

All Articles