Commit 2b37a8b5 authored by Marco Konersmann's avatar Marco Konersmann

Adds prior targets to annotated member reference transformations

parent 865ae074
package org.codeling.mechanisms.transformations.references
import de.mkonersmann.advert.java.embed.ASTUtils
import de.mkonersmann.advert.java.embed.transformation.AbstractModelCodeTransformation
import java.util.Collection
import java.util.LinkedHashSet
import java.util.LinkedList
......@@ -9,6 +8,7 @@ import java.util.List
import java.util.Set
import org.codeling.mechanisms.MechanismsMapping
import org.codeling.mechanisms.classes.MarkerInterfaceMechanism
import org.codeling.mechanisms.transformations.ClassMechanismTransformation
import org.codeling.mechanisms.transformations.ReferenceMechanismTransformation
import org.codeling.utils.CodelingException
import org.eclipse.emf.ecore.EObject
......@@ -18,9 +18,6 @@ import org.eclipse.jdt.core.ICompilationUnit
import org.eclipse.jdt.core.IField
import org.eclipse.jdt.core.IType
import org.eclipse.jdt.core.dom.AST
import org.codeling.mechanisms.transformations.ClassMechanismTransformation
import org.modelversioning.emfprofileapplication.StereotypeApplication
import org.modelversioning.emfprofileapplication.StereotypeApplicability
abstract class AnnotatedMemberReferenceTransformation<OWNERECLASS extends EObject, TARGETECLASS extends EObject> extends ReferenceMechanismTransformation<OWNERECLASS, TARGETECLASS, IType> {
......@@ -34,7 +31,6 @@ abstract class AnnotatedMemberReferenceTransformation<OWNERECLASS extends EObjec
}
override createCodeFragments() throws CodelingException {
// Create Code Fragments is only executed for the Marker Interface Mechanism as target
var String fieldCode = "";
if (eReference.isMany) {
val LinkedList<EObject> targets = new LinkedList();
......@@ -91,30 +87,33 @@ abstract class AnnotatedMemberReferenceTransformation<OWNERECLASS extends EObjec
// We want to keep any custom annotations on the "states" field in the 'x..* MarkerInterface' scenario. Therefore we change the annotation parameters.
val LinkedList<EObject> targets = new LinkedList();
targets.addAll(modelElement.eGet(eReference) as Collection<EObject>);
if (targets === null)
val LinkedList<EObject> priorTargets = new LinkedList();
priorTargets.addAll(priorModelElement.eGet(eReference) as Collection<EObject>);
if (targets === null || priorTargets === null)
return;
if (targetIsMarkerInterface) {
updateMarkerInterfaceReferenceMulti(targets);
} else {
updateTypeAnnotationReferenceMulti(targets);
updateTypeAnnotationReferenceMulti(priorTargets, targets);
}
} else {
val EObject target = modelElement.eGet(eReference) as EObject;
if (target === null)
val priorTarget = priorModelElement.eGet(eReference) as EObject;
if (target === null || priorTarget === null)
return;
if (targetIsMarkerInterface) {
updateMarkerInterfaceReferenceSingle(target);
} else {
updateTypeAnnotationReferenceSingle(target);
updateTypeAnnotationReferenceSingle(priorTarget, target);
}
}
}
def void updateTypeAnnotationReferenceSingle(EObject target) {}
def void updateTypeAnnotationReferenceSingle(EObject priorTarget, EObject target) {}
def void updateMarkerInterfaceReferenceSingle(EObject target) {}
def void updateTypeAnnotationReferenceMulti(LinkedList<EObject> targets) {}
def void updateTypeAnnotationReferenceMulti(LinkedList<EObject> priorTargets, LinkedList<EObject> targets) {}
def void updateMarkerInterfaceReferenceMulti(LinkedList<EObject> targets) {
var ICompilationUnit cu = codeElement.compilationUnit;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment