JavaFX Plugin - Code Templates Feature Specification
| Document Status | Initial Draft |
This is living document. Some parts of it are still unwritten.
Note: This specification is a subject to changes until the specification of the JavaFX language is not finalized.
If you are interested in changes in this document you might want to sign to this page RSS feed.
Introduction
Code Templates Feature of the JavaFX Plugin is extension of the Code Templates Feature of the NetBeans's editor (See
Architecture Review Opinion).
The Code Templates provide an infrastructure for pasting parameterized code snippets into the editor. On pasting a code template, all its parameters are assigned with default values and the editor switches to a special state in which all changes made to a parameter value are automatically replicated across all the parameter's occurrences.
See also page 2 in NetBeans 6.0 Keyboard Shortcuts & Code Templates.
Selection templates
Some of code templates are selection templates. It means that such template can be applied to the selected piece of code.
Basic Requirements
The code templates should meet the following requirements:
- An Abbreviation MUST BE unique in the specified set of abbreviations. Note: Abbreviations are case-sensitive. TBD GUI with drop-down list of variants
- An Abbreviation MUST NOT BE the same as a keyword. TBD
- Each code template MUST generate a syntactically correct language construct.
- A language construct generated by default MUST not provoke semantic error (e.g. endless loop).
- A preferred abbreviation SHOULD BE started with the same letters as starting letters of the first token of the target language construct.
Code Templates
Keywords
Code Templates of this category don't have any parameters.
An abbreviation of this category will be simply expanded into the associated keyword with automatic terminating either the space or the semi-colon ';' .
| Abbreviation | Keyword | Contexts | Comments |
| ab | abstract |
| as | assert |
| | attribute | | See the specific abbreviations in other sections. |
| bi | bind | first clause in an expression | |
| bil | bind lazy | immediately after bind keyword in the expression | |
| br | break | body of a while or for statement | It will be completed by the semi-colon ';' |
| | class | | See the specific abbreviations in other sections. |
| cn | continue | body of a while or for statement | It will be completed by the semi-colon ';' |
| | delete | | See the Array Data Modification Statements section. |
| fa | false |
| | for | | See the specific abbreviations in other sections. |
| | function | | See the specific abbreviations in other sections. |
| | if | | See the specific abbreviations in other sections. |
| im | import |
| | init | | Abbreviation will not be provided. |
| | insert | | See the specific abbreviations in other sections. |
| | let | | Abbreviation will not be provided. |
| | new | | Abbreviation will not be provided. |
| | not | | Abbreviation will not be provided. |
| | null | | Abbreviation will not be provided. |
| pa | package | once at begin of file | ??? Should such clause be automatically generated by the file template? Whether we have at least one use case for the abbreviation? |
| pr | private |
| pe | protected |
| pu | public |
| ro | readonly |
| re | return | | 1. return value? 2. ';' |
| su | super |
| so | sizeof |
| st | static |
| th | this |
| | throw | | See the specific abbreviations in other sections. |
| | try | | See the specific abbreviations in other sections. |
| tr | true |
| | var | | Abbreviation will not be provided. |
| | while | | See the specific abbreviations in other sections. |
| | after | | Abbreviation will not be provided. |
| | and | | Abbreviation will not be provided. |
| | as | | Abbreviation will not be provided. |
| | before | | Abbreviation will not be provided. |
| | by | | Abbreviation will not be provided. |
| | catch | | See the specific abbreviations in other sections. |
| | do | | See the specific abbreviations in other sections. |
| | dur | | ??? |
| | else | | See the specific abbreviations in other sections. |
| | exclusive | | ??? |
| | extends | | See the specific abbreviations in other sections. |
| | finally | | See the specific abbreviations in other sections. |
| | first | | Abbreviation will not be provided. |
| | from | | Abbreviation will not be provided. |
| | in | | Abbreviation will not be provided. |
| ind | indexof |
| iof | instanceof |
| | into | | Abbreviation will not be provided. |
| inv | inverse |
| | last | | Abbreviation will not be provided. |
| | on | | Abbreviation will not be provided. |
| | or | | Abbreviation will not be provided. |
| | replace | | ??? |
| | step | | Abbreviation will not be provided. |
| tof | typeof |
| | with | | Abbreviation will not be provided. |
| we | were |
Not in list:
format as
Data Types
Code Templates of this category don't have any parameters. An abbreviation of this category will be simply expanded into the associated data type after tabbing.
| Abbreviation | Data Type | Comments |
| Bo | Boolean | |
| In | Integer | |
| Nu | Number | |
| St | String | |
Array Data Modification Statements
See syntax and semantics in the draft XQuery-Update specification.
| Abbreviation | Language construction | Code Template | Comments |
| ins | insert into | insert Expression1 into Expression2; | It is the same as insert as last into |
| insf | insert as first into | insert Expression1 as first into Expression2; | |
| insl | insert as last into | insert Expression1 as last into Expression2; | It is the same as insert into |
| insb | insert before | insert Expression1 before Expression2; | |
| insa | insert after | insert Expression1 after Expression2; | |
| de | delete | delete VariableOrAttribute; | |
Querying Arrays Operators
| Abbreviation | Language construction | Code Template | Comments |
| selfi | select from in | select Expression1 from Expression2 in Expression2 | If it is last operator in expression then closing ; should be generated. |
| selfiw | select from in where | select Expression1 from Expression2 in Expression3 where Expression4 | If it is last operator in expression then closing ; should be generated. |
| fore | foreach | foreach (List) StatementOrBlock | List is a comma separated list of Exp1 in Exp2 or Exp1 in Exp2 where Exp2 |
Statements
| Abbreviation | Language construction | Code Template | Contexts | Comments |
| | primary expression | | body of an operation | e.g. call expression |
| if | if | if(...) { ... } | body of an operation |
| ife | if else | if(...) { ... } else {...} | body of an operation |
| el | if else | else {...} | immediately after if statement in body of an operation |
| eli | if else | else if {...} | immediately after if statement in body of an operation |
| wh | while | while(...) {...} | body of an operation | Note: curly braces are always required around the body |
| tr | try catch | try {...} catch (Variable) {...} | body of an operation |
| ca | try catch | catch (Variable) {...} | immediately after try catch statement in body of an operation |
| fi | try catch | finally {...} | immediately after catch clause of the try catch statement in body of an operation |
| for | for | for (idx in array) {...} | body of an operation |
| ret | return | return Expression; | body of an operation |
| tw | throw | throw AnyObject; | body of an operation |
| do | do | do {...} | body of an operation |
| dol | do later | do later {...} | body of an operation |
Classes and Objects
| Abbreviation | Language construction | Code Template | Contexts | Comments |
| cl | class | class ClassName {...} | |
| ex | extends | extends ${SuperClassName} | immediately after ClassName in a class definition |
| at | attribute | attribute AttributeName [: AttributeType] [Cardinality]; | class declaration | |
| inv | attribute inverse | inverse ClassName.InverseAttributeName | once at the end of the attribute declaration | Note: it rely on the fact that terminating semi-colon is already exist, e.g. before: attribute AttrDef; after: attribute AttrDef inverse ClassName.InverseAttributeName; |
| at | attribute | attribute QualifiedAttributeName = ...; | file scope | It is named as the Attribute Declarations in the The JavaFX Script Programming Language, but it seems the Attribute Definition term is more correct. |
Object Literals
No any static code templates can be proposed for such language constructs.
Update Triggers
| Abbreviation | Language construction | Code Template | Contexts | Comments |
| trin | Creation Trigger | trigger on new ClassName { ... } | file scope |
| trii | Insert Trigger | trigger on insert LocalVariableName into QualifiedAttributeName { ... } | file scope |
| trid | Delete Trigger | trigger on delete LocalVariableName from QualifiedAttributeName { ... } | file scope |
| trir | Replace Trigger | trigger on QualifiedAttributeName''OldValueLocalVariableName'' = NewValueLocalVariableName { ... } | file scope |
Reflection
No any code templates (patterns) are defined for this language feature.
Other
TBD
| Abbreviation | Language construction | Code Template | Comments |
| fu | function | function ...(...) { ... return ...;} | |
| oper | operation | operation ...(...): ... { ... } | |
| var | var | var ... = ...; | |
| serr | System.err.println("${cursor}"); |
| sout | System.out.println("${cursor}"); |