|
|
Code template's example
for (Iterator ${iterator} = ${collection instanceof="java.util.Collection"}.iterator(); ${iterator}.hasNext();) { ${cursor}${iterator}.next();" }Each parameter can have additional hints of what values can be assigned to it. The hint has a form
${param hint=value}or just
${param hint}which translates to
${param hint="true"}
If necessary the value of the hint can be enclosed
in quotes to allow to write whitespace or {
or }
into the value. The quote can be written by using \"
.
${cursor}
defines position where the caret will be located
after the editing of the code template default values will finish.
${param editable=false}
can be used to make the parameter to be skipped
from user's editing. This may be useful e.g. with using java-specific type
hint (described below).
Java:
${ind index}
defines that the default value of the parameter
should be an unused variable in the given context named i
.
If i
is already used then j
is attempted
or then k
etc. until z
.
Then i0
, i1
etc. are attempted.
${param type="java.util.Collection"}
defines
java type that the parameter must be instance of.
Besides class names there can be array e.g. String[]
or generics java.util.List<String>
${param array}
defines parameter of array type (including
arrays of primitive data types).
${param type="java.util.Iterator"}
defines
that the parameter has the given java type. The template processing infrastructure
will use short name Iterator
and import java.util.Iterator
.
It is a module located under ide/editor.codetemplates directory.
It consists ofCode Templates define CodeTemplatesAPI.
Question (arch-usecases): Describe the main use cases of the new API. Who will use it under what circumstances? What kind of code would typically need to be written to use the module? Answer:${...}
.
index
parameter which means that the infrastructure should fill in
a fresh index variable e.g. i
.
java.util.Collection
.
${i index}
or ${c instanceof=java.util.Collection}
.
${x default="Hello world"}
.
${x default="\"quoted string\""}
.
JTextComponent pane = ... String tempCodeTemplateText = ... CodeTemplate ct = CodeTemplateManager.get(pane.getDocument()).createTemporary(tempCodeTemplateText); ct.insert(pane);
editable
having
true
/false
.
Question (arch-time):
What are the time estimates of the work?
Answer:
The work is expected to be finished into NetBeans 4.2.
Question (arch-quality):
How will the quality
of your code be tested and
how are future regressions going to be prevented?
Answer:
The unit tests are available in ide/editor.codetemplates/test.
The following scenarios are tested:
The sources for the module are in the Apache Git repositories or in the GitHub repositories.
java.io.File
directly?
Answer:
No.
Question (resources-layer):
Does your module provide own layer? Does it create any files or
folders in it? What it is trying to communicate by that and with which
components?
Answer:
No.
Question (resources-read):
Does your module read any resources from layers? For what purpose?
Answer:
No.
Question (resources-mask):
Does your module mask/hide/override any resources provided by other modules in
their layers?
Answer:
No.
Question (resources-preferences):
Does your module uses preferences via Preferences API? Does your module use NbPreferences or
or regular JDK Preferences ? Does it read, write or both ?
Does it share preferences with other modules ? If so, then why ?
WARNING: Question with id="resources-preferences" has not been answered!
org.openide.util.Lookup
or any similar technology to find any components to communicate with? Which ones?
Answer:
Yes, it searches for Code Template Processors for particular mime-type by using
org.netbeans.api.editor.mimelookup.MimeLookup
-
Question (lookup-register):
Do you register anything into lookup for other code to find?
Answer:
No.
Question (lookup-remove):
Do you remove entries of other modules from lookup?
Answer:
No.
System.getProperty
) property?
On a similar note, is there something interesting that you
pass to java.util.logging.Logger
? Or do you observe
what others log?
Answer:
No.
Question (exec-component):
Is execution of your code influenced by any (string) property
of any of your components?
Answer:
No.
Question (exec-ant-tasks):
Do you define or register any ant tasks that other can use?
Answer:
No.
Question (exec-classloader):
Does your code create its own class loader(s)?
Answer:
No.
Question (exec-reflection):
Does your code use Java Reflection to execute other code?
Answer:
No.
Question (exec-privateaccess):
Are you aware of any other parts of the system calling some of
your methods by reflection?
Answer:
No.
Question (exec-process):
Do you execute an external process from your module? How do you ensure
that the result is the same on different platforms? Do you parse output?
Do you depend on result code?
Answer:
No.
Question (exec-introspection):
Does your module use any kind of runtime type information (instanceof
,
work with java.lang.Class
, etc.)?
Answer:
No.
Question (exec-threading):
What threading models, if any, does your module adhere to? How the
project behaves with respect to threading?
Answer:
No special threading models used.
Question (security-policy):
Does your functionality require modifications to the standard policy file?
Answer:
No.
Question (security-grant):
Does your code grant additional rights to some other code?
Answer:
No.
java.awt.datatransfer.Transferable
?
Answer:
No clipboard support.