Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.
MoDisco/JavaAbstractSyntax
Contents
Java Abstract Syntax Discovery Tool
This generic tool is about discovering a full abstract syntax tree (AST) of the code (statements, expressions, annotations and Javadoc) taken from a Java compilation unit (typically a Class). It builds models, representing Java compilation units, which conform to a metamodel designed from the Eclipse JDT Java API.
This tool is provided by INRIA AtlanMod and its development is being supported by the IST European MODELPLEX project (MODELing solution for comPLEX software systems, FP6-IP 34081).
The overall approach is summarized in the following figure:
The discoverer, named JavaAbstractSyntaxDiscoverer, is built upon the Eclipse JDT. It takes as input a Java compilation unit (DOT java file). It uses the JDT parser in order to have an in-memory representation of the compilation unit. Then, it uses a visitor processing each in-memory AST node and creates the corresponding model elements.
We defined a metamodel of the Java compilation unit's syntax by studying the Eclipse JDT API. This metamodel is named JavaAbstractSyntax metamodel.
We provide below a short excerpt, representing the simple System.out.println("Done!"); Java statement, of a model (in XMI format) created by using this discoverer:
Related Use Cases
- SharenGo Java Legacy Reverse-Engineering : This complete use case, which covers both the "Model Discovery" and "Model Understanding" phases, is about reverse engineering a Java application. It uses the Java Abstract Syntax discovery tool (from the MoDisco Tool Box) to discoverer the abstract syntax tree (AST) of each Java compilation unit (i.e. each source file). The generated models are then analyzed by model transformations in order to produce a SharenGo business model.
Download
- metamodel : JavaAbstractSyntax metamodel expressed in the Ecore format. It is also available here in the KM3 textual format. Due to IP restrictions, the zoos of metamodels are not currently available anymore from Eclipse.org. However, the metamodels used within this use case are included into the plugin project you can download below.
- The discoverer (org.eclipse.gmt.modisco.discoverer.javast) is available here.
- All the sources contained in the archive are also available from the MoDisco SVN.
General Information
- November 2006
- By Mikael Barbero (INRIA)
- Please, ask your questions on the MoDisco newsgroup