Java Reference
In-Depth Information
This is an example of
«IF»
and
«ELSE»
from the
ProperySection.xpt
template used in GMF's diagram generation:
«
IF
createLabel() && isExpandable()-»
«
EXPAND
createControls(name()+"Control")
FOREACH
contents-»
«name()».setClient(«name()»Control);
«name()».addExpansionListener(getExpansionListener(«parentVar»));
«
ELSE
-»
«
EXPAND
createControls(name())
FOREACH
contents-»
«
ENDIF
»
14.1.8 PROTECT
To mark sections of generated code that are designated for user modification,
Xpand provides a
«PROTECT»
statement. During regeneration, these regions
are protected from being overwritten. This is the general syntax for
«PROTECT»
statements:
«
PROTECT CSTART
expression
CEND
expression
ID
expression (
DISABLE
)?»
. . .
«
ENDPROTECT
»
The
CSTART
and
CEND
expressions should be valid comment markers for the
target language—for example,
/*
and
*/
for Java comments. The
ID
expression
should be unique for the execution of the generator. By default, a protected
region is enabled, but you can disable it by adding the
DISABLED
keyword.
To use protected regions, you must configure a resolver in your workflow
file.
EMF uses the recommended approach for dealing with user-modified code,
and JMerge follows this upon regeneration. To use this approach, insert
@generated
JavaDoc comments above class, field, and method declarations.
Removing this tag and modifying it (such as by adding
NOT
to the end, as in
@generated NOT
) signifies that the block should not be overwritten.
14.1.9 LET
Sometimes it's convenient to create a local variable for use in your template. The
«LET»
statement enables you to bind an expression to a variable name using the
following syntax:
Search WWH ::
Custom Search