5.10. Java - Code Generation and Reverse Engineering
Purpose - two purposes: to allow the model to be converted into java code
and updated either in java or in the model; to allow some java code to be
converted into a model.
The java things are located in
org.argouml.language.java.
The Java subsystem is a Loadable subsystem. See Section 4.7, “Loadable subsystems”.
5.10.2. Which sources are involved?
The package org.argouml.uml.reveng is supposed to hold those
classes that are common to all reverse engineering (RE) packages.
At the moment this is the Import
class which is mainly responsible to recognize directories, get their
content and parse every known source file in them. These are only Java
files at the moment, but there might be other languages like C++ in the
future. With this concept you could mix several languages within a
project.
The package org.argouml.uml.reveng.java holds the Java specific
parts of the current RE code. C++ RE might go to
org.argouml.uml.reveng.cc, or so...
5.10.3. How is the grammar of the target language implemented?
It is an Antlr (
http://www.antlr.org) grammar, based on the Antlr Java parser
example. The main difference is that the AST (Abstract Syntax Tree)
generation and tree-parser have been removed. The ArgoUML
code parses the source file and generates Model subsystem objects directly from the
sources. This was done to avoid the memory usage of an AST and the frequent
GC while parsing many source files. The disadvantage of this approach is
that it requires multiple parser passes rather than being able to work
from the pre-parsed AST.
5.10.4. Which model/diagram elements are generated?
The *context classes hold the current context for a package, class
etc. When the required information for an object is available, the
corresponding Model subsystem object is created. The collection of
newly created model elements is returned to the common Import code
where it can be used to add the elements to a diagram or diagrams
if the user has so requested.