Easily format generated Java code

XPath function for accessing EMF EClass

A new XPath function, emf.eClass() will access the EClass of an object, if it has one. If object is an XPath variable referring to an EMF Object, then emf.eClass($object)/@name will return its EClass name.

If the argument is not specified, then it defaults to the current XPath context object.

XPath function for accessing UML2 Stereotypes

A new Xpath function, uml2.stereotype will access a stereotype on a UML2 Element, if it has one. If element is an XPath variable referring to
a UML2 element, then uml2.stereotype($element, "Profile-name::Stereotype-name") will access the applied stereotype.

The first argument is optional. If not specified, it defaults to the current XPath context object.

The f:indent tag now preserves user regions

Improved integration with PDE build and international characters

PDE build assumes that all Java files have the same encoding (the default for the JVM executing the build). Prior to this release, JET would set the
encoding a the Java class generated from each template to the same encoding as the template. This could be problematic if the selected encoding was not the one used by PDE build.

The JET compiler now compiles templates into Java classes that always have the default Java encoding. Characters that cannot be represented in that encoding are transformed into Unicode escape sequences.

In addition, a new JET template extension has been defined (.jet2) whose default encoding is UTF-8. The default encoding of files with a .jet use the platform's default encoding for text files - this can change from installation to installation.

Compact alternative to c:get tag

JET now permits the use of ${xpath-expression} within the static text as an alternative to the c:get tag. This expression form may also be used in tag attributes values as an alternative to {xpath-expression}.

The value is ${@someModelAttribute}.

For compatibility, existing JET projects will not support this unless the <transform> element in plugin.xml has the attribute enableEmbeddedExpressions="true". New JET projects are created with this attribute set.

When embedded expressions are enabled, you must escape the ${ if you want them to appear as static text in a template. Escaping is done by including the characters within a string literal inside an embedded expression.

JET can now read .java files

If a JET transformation is given a .java file as input, then JET will create a JDT abstract syntax tree (AST) for the Java file, and allow templates to traverse this AST. The root element of the loaded document is typically compilationUnit.

The child steps available from any ast node are defined by the child and child list property descriptors available on the node.

The attributes available from any ast node are defined by the simple property descriptors available on the node. In addition, the following for attributes are always available:

offset - the 0-based offset of the node within the source

length - the length of the source text corresponding to the ast node

source - the source code corresponding to the ast node

nodeType - the simple class name (no package qualifier) of the AST node

An understanding of the JDT abstract syntax tree APIs is suggested.

As an example, the following XPath expression will return all fields declared in a class

The c:with tag does not iterate. It will evaluate its block only once. If the select expression does not return a value, the c:with body is not evaluated.

For compatibility, this behavior is only enabled if the JET variable org.eclipse.jet.taglib.control.iterateSetsContext is set to true(). New JET projects have this variable set automatically in the generated main.jet template. Existing JET transformations will need to add a statement such
as the following to main.jet to enable this behavior.