-
Notifications
You must be signed in to change notification settings - Fork 1
Cross reference updating between compilation units
The current implementation of the Java to UML transformation works on Java compilation units (i.e. files). When a file is modified, the corresponding UML model elements are deleted, regenerated or updated. However these are not the only elements that have to be updated, because there can be cross-references of the modified elements in other compilation units. To address this issue these cross-references have to be found and updated.
Finding the needed references can be problematic, especially when there is a compile error in the java code. In this case the types cannot be correctly resolved in the AST, and it makes hard to decide what is the target of the reference. E.g. when a member with a non-existent type is added to a class, it is not trivial to tell when should the reference be updated (after the creation of the missing type). To compute the qualified name of the types that should trigger the update of these references, the package imports have to be considered. However these computations are already executed during the JDT incremental build, and it would be unnecessary to implement them again.
The JDT during an incremental build computes the list of compilation units affected by structural changes of other files, and stores this information in a State
object describing the build state. In our solution we provided a CompilationParticipant that after every build gets the list of the affected files from the JDT build state, and creates an UPDATE_DEPENDENCIES
event for each of them.
This solution fits in the event driven transformation by introducing a new DEPENDENCIES_UPDATED
activation state (besides the transactional INACTIVE, MODIFIED, COMMITTED, DELETED and FIRED
states). Cross references are only updated if the corresponding resource is saved, and the activation is in the FIRED
state, in which case the state is changed to DEPENDENCIES_UPDATED
and then the rules handling this activation state are executed.