This document describes the elements and the structure of the JET2 Transformation for generating Java code from a JDT AST. It will be particularly valuable for developers looking to use this transformation to generate Java code from a JDT AST.
JDT to code JET2 Transform is the top-level transform.
| JDT to code JET2 Transform |
|
The transform expects a Map<IJavaProject,Collection<CompilationUnit>> as the root element. It then processes the collection for each project and generates the corresponding source files in the corresponding project. The CompilationUnit elements are expected to contain all the required information, i.e. Package Declarations, Import Declarations etc
The transform uses the org.eclipse.jet.modelInspectors extension to traverse the JDT AST in the JET templates. An inspector is an object that adapts objects to the XPath information model. Each Inspector defines the types of objects that it is capable of adapting and is handed over only those objects. There is an inspector for each ASTNode that answers the XPath queries for that ASTNode. THese inspectors are implemented in the plugin com.ibm.xtools.transform.java.jet2
The transform provides the extension point com.ibm.xtools.transform.java.jet2.IJavaJET2ListenerProvider that allows the invoking transforms to perform custom actions during the transform execution. IJavaJET2ListenerProvider is an interface that lets clients register listeners with the Java JET2 transform for each ASTNode as well as org.eclipse.jet.IWriterListener for each file that is written. The structure of the extension point is described below
| IJavaJET2ListenerProvider extension |
|
The interface IJavaJET2ListenerProvider is defined as follows
| public interface IJavaJET2ListenerProvider { public IJavaJET2Listener getJavaJET2Listener(String activityId); public IWriterListener getWriterListener(String activityId); } |
IJavaJET2Listener is a node level listener that is invoked before and after each ASTNode is processed while IWriterListener is a file level listener that is invoked before and after each file is committed. Contributors can provide listeners only for particular activityIds they are interested in. ActivityId is an identifier that can be specified by the clients of the Java JET2 transform and a contributor can provide listeners for any activityId thereby allowing the contributor to extend any transform that invokes the Java JET2 transform. The interface IJavaJET2Listener is defined as below
| public interface IJavaJET2Listener { public void preVisit (ASTNode node, JET2Writer writer); public void postVisit(ASTNode node, JET2Writer writer); } |
<TBD>
<TBD>