Commit 7dcff103 authored by Marco Konersmann's avatar Marco Konersmann

renames "get" to "resolve" in the id registry, where an actual resolving...

renames "get" to "resolve" in the id registry, where an actual resolving happens + some more refactoring
parent 4d84ccf2
......@@ -89,13 +89,13 @@ class PriorIlToNewIlCopier extends Copier {
final String targetId = priorIdRegistry.getIDFromTranslationModelElement(originalTargetElement);
if (targetId == null)
continue; // this happens, when a prior il object has been deleted. Ignore.
final EObject cloneTarget = idRegistry.getTranslationModelElement(targetId, ilModelRoots);
final EObject cloneTarget = idRegistry.resolveTranslationModelElement(targetId, ilModelRoots);
cloneTargetList.add(cloneTarget);
}
clone.eSet(ref, cloneTargetList);
} else {
final String targetId = priorIdRegistry.getIDFromTranslationModelElement((EObject) originalTarget);
final EObject cloneTarget = idRegistry.getTranslationModelElement(targetId, ilModelRoots);
final EObject cloneTarget = idRegistry.resolveTranslationModelElement(targetId, ilModelRoots);
clone.eSet(ref, cloneTarget);
}
}
......
......@@ -94,32 +94,31 @@ public abstract class JavaBasedImplementationLanguageDefinition extends Implemen
}
@Override
public void transformTMToCode(List<EObject> ilRoots, List<EObject> cmRoots, IDRegistry idRegistry,
public void transformTMToCode(List<EObject> tmRoots, List<EObject> imRoots, IDRegistry idRegistry,
List<IJavaProject> projects) throws CodelingException {
idRegistry.getRegistryEntries().keySet().stream().forEach(id -> {
final EObject cmElement = idRegistry.getImplementationModelElement(id, cmRoots);
final EObject cmElement = idRegistry.resolveImplementationModelElement(id, imRoots);
if (cmElement == null)
return;
final EObject foundationalIALElement = idRegistry.getTranslationModelElement(id, ilRoots);
final EObject foundationalIALElement = idRegistry.resolveTranslationModelElement(id, tmRoots);
if (foundationalIALElement == null)
return;
final IJavaElement codeElement = resolveCodeElement(idRegistry, cmElement);
if (codeElement == null)
return;
final List<? extends IALTransformation<?, ?>> referencesTransformations = createIALTransformationInstance(
final List<? extends IALTransformation<?, ?>> ialTransformations = createIALTransformationInstance(
cmElement);
if (referencesTransformations != null) {
referencesTransformations.stream().forEach(t -> {
IALHolder holder = t.getIALHolder();
holder.setFoundationalIALElement(foundationalIALElement);
holder.setIALCodeElement(codeElement);
if (ialTransformations != null) {
ialTransformations.stream().forEach(t -> {
t.setIDRegistry(idRegistry);
t.setModelElement(t.resolveTranslatedIALElement());
if (findTranslatedElements == null)
findTranslatedElements = new FindTranslatedElements();
t.setWhereToFindTranslatedElements(findTranslatedElements);
t.getIALHolder().setFoundationalIALElement(foundationalIALElement);
t.getIALHolder().setIALCodeElement(codeElement);
final ModelToJavaTransformation executor = new ModelToJavaTransformation(projects,
(AbstractModelCodeTransformation<?, ?>) t, new LinkedList<>());
......@@ -137,11 +136,11 @@ public abstract class JavaBasedImplementationLanguageDefinition extends Implemen
try {
idRegistry.getRegistryEntries().keySet().stream().forEach(id -> {
try {
final EObject imElement = idRegistry.getImplementationModelElement(id, imRoots);
final EObject imElement = idRegistry.resolveImplementationModelElement(id, imRoots);
if (imElement == null)
return; // If this element has not implementation model representation, ignore it.
final EObject tmElement = idRegistry.getTranslationModelElement(imElement, tmRoots);
final EObject tmElement = idRegistry.resolveTranslationModelElement(imElement, tmRoots);
final List<? extends IALTransformation<?, ?>> ialTransformations = createIALTransformationInstance(
imElement);
if (ialTransformations != null)
......@@ -164,7 +163,7 @@ public abstract class JavaBasedImplementationLanguageDefinition extends Implemen
// profiles facade.
final Resource applicationResource = getResource(rSet,
CodelingConfiguration.DEBUG_MODELDIR_PATH + "profile-application.pa.xmi");
mergeStereotypeApplicationsWithILModel(tmRoots, applicationResource);
mergeStereotypeApplicationsWithTranslationModel(tmRoots, applicationResource);
return new TransformationResult(tmRoots, idRegistry);
} catch (final IOException e) {
throw new CodelingException("Could not handle the temporary resource for the profile application.", e);
......@@ -188,7 +187,7 @@ public abstract class JavaBasedImplementationLanguageDefinition extends Implemen
}
private void mergeStereotypeApplicationsWithILModel(final List<EObject> ilModelRoots,
private void mergeStereotypeApplicationsWithTranslationModel(final List<EObject> ilModelRoots,
final Resource applicationResource) throws IOException {
final TreeIterator<EObject> iterator = applicationResource.getAllContents();
final LinkedList<EObject> stereotypeApplications = new LinkedList<>();
......
......@@ -510,7 +510,7 @@ public abstract class AbstractModelCodeTransformation<ELEMENTECLASS extends EObj
final EObject childModelElement = childTransformation.getModelElement();
if (childModelElement != null && idRegistry.knowsImplementationModelElement(childModelElement)) {
final String id = idRegistry.getIDFromImplementationModelElement(childModelElement);
final EObject priorChildElement = priorIDRegistry.getImplementationModelElement(id,
final EObject priorChildElement = priorIDRegistry.resolveImplementationModelElement(id,
EcoreUtil.getRootContainer(priorModelElement));
childTransformation.setPriorModelElement(priorChildElement);
}
......@@ -692,7 +692,7 @@ public abstract class AbstractModelCodeTransformation<ELEMENTECLASS extends EObj
protected EObject resolvePriorElement(EObject eObject) {
String id = idRegistry.getIDFromImplementationModelElement(eObject);
return priorIDRegistry.getImplementationModelElement(id, priorModelElement.eResource().getContents());
return priorIDRegistry.resolveImplementationModelElement(id, priorModelElement.eResource().getContents());
}
/**
......@@ -720,7 +720,7 @@ public abstract class AbstractModelCodeTransformation<ELEMENTECLASS extends EObj
EObject priorTarget = null;
if (idRegistry.knowsImplementationModelElement(currentElement)) {
String oldID = idRegistry.getIDFromImplementationModelElement(currentElement);
priorTarget = priorIDRegistry.getImplementationModelElement(oldID,
priorTarget = priorIDRegistry.resolveImplementationModelElement(oldID,
EcoreUtil.getRootContainer(priorModelElement));
}
return priorTarget;
......
......@@ -38,7 +38,7 @@ public class ArchivesTransformation extends NinjaSingletonContainmentTransformat
}
for (EObject target : Models.getTargetsAsList(priorModelElement, eReference)) {
String priorID = priorIDRegistry.getIDFromImplementationModelElement(target);
EObject newElement = idRegistry.getImplementationModelElement(priorID, EcoreUtil.getRootContainer(modelElement));
EObject newElement = idRegistry.resolveImplementationModelElement(priorID, EcoreUtil.getRootContainer(modelElement));
if (newElement == null) {
AbstractModelCodeTransformation<?, ?> t = new NamespaceTransformation(this);
t.setPriorModelElement(target);
......
......@@ -44,7 +44,7 @@ public class BeansTransformation extends NinjaSingletonContainmentTransformation
}
for (EObject target : Models.getTargetsAsList(priorModelElement, eReference)) {
String priorID = priorIDRegistry.getIDFromImplementationModelElement(target);
EObject newElement = idRegistry.getImplementationModelElement(priorID, EcoreUtil.getRootContainer(modelElement));
EObject newElement = idRegistry.resolveImplementationModelElement(priorID, EcoreUtil.getRootContainer(modelElement));
if (newElement == null) {
AbstractModelCodeTransformation<?, ?> t = createSpecificTransformation(target);
t.setPriorModelElement(target);
......
......@@ -40,7 +40,7 @@ public class EntitiesTransformation extends NinjaSingletonContainmentTransformat
}
for (EObject target : Models.getTargetsAsList(priorModelElement, eReference)) {
String priorID = priorIDRegistry.getIDFromImplementationModelElement(target);
EObject newElement = idRegistry.getImplementationModelElement(priorID, EcoreUtil.getRootContainer(modelElement));
EObject newElement = idRegistry.resolveImplementationModelElement(priorID, EcoreUtil.getRootContainer(modelElement));
if (newElement == null) {
AbstractModelCodeTransformation<?, ?> t = new EntityTransformation(this);
t.setPriorModelElement(target);
......
......@@ -41,7 +41,7 @@ public class NamespacesTransformation extends NinjaSingletonContainmentTransform
}
for (EObject target : Models.getTargetsAsList(priorModelElement, eReference)) {
String priorID = priorIDRegistry.getIDFromImplementationModelElement(target);
EObject newElement = idRegistry.getImplementationModelElement(priorID, EcoreUtil.getRootContainer(modelElement));
EObject newElement = idRegistry.resolveImplementationModelElement(priorID, EcoreUtil.getRootContainer(modelElement));
if (newElement == null) {
AbstractModelCodeTransformation<?, ?> t = new NamespaceTransformation(this);
t.setPriorModelElement(target);
......
......@@ -38,7 +38,7 @@ public class ComponentsTransformation extends NinjaSingletonContainmentTransform
}
for (EObject target : Models.getTargetsAsList(priorModelElement, eReference)) {
String priorID = priorIDRegistry.getIDFromImplementationModelElement(target);
EObject newElement = idRegistry.getImplementationModelElement(priorID, EcoreUtil.getRootContainer(modelElement));
EObject newElement = idRegistry.resolveImplementationModelElement(priorID, EcoreUtil.getRootContainer(modelElement));
if (newElement == null) {
AbstractModelCodeTransformation<?, ?> t = new ComponentTransformation(this);
t.setPriorModelElement(target);
......
......@@ -39,7 +39,7 @@ public class OperationsTransformation extends ContainmentOperationTransformation
}
for (EObject target : Models.getTargetsAsList(priorModelElement, eReference)) {
String priorID = priorIDRegistry.getIDFromImplementationModelElement(target);
EObject newElement = idRegistry.getImplementationModelElement(priorID, EcoreUtil.getRootContainer(modelElement));
EObject newElement = idRegistry.resolveImplementationModelElement(priorID, EcoreUtil.getRootContainer(modelElement));
if (newElement == null) {
AbstractModelCodeTransformation<?, ?> t = new BusinessOperationTransformation(this);
t.setPriorModelElement(target);
......
......@@ -36,7 +36,7 @@ public class StatemachineTransformation extends AnnotatedMemberReferenceTransfor
}
for (EObject target : Models.getTargetsAsList(priorModelElement, eReference)) {
String priorID = priorIDRegistry.getIDFromImplementationModelElement(target);
EObject newElement = idRegistry.getImplementationModelElement(priorID, EcoreUtil.getRootContainer(modelElement));
EObject newElement = idRegistry.resolveImplementationModelElement(priorID, EcoreUtil.getRootContainer(modelElement));
if (newElement == null) {
AbstractModelCodeTransformation<?, ?> t = new StatemachineTransformation(this);
t.setPriorModelElement(target);
......
......@@ -38,7 +38,7 @@ public class TransitionsTransformation extends ContainmentOperationTransformatio
}
for (EObject target : Models.getTargetsAsList(priorModelElement, eReference)) {
String priorID = priorIDRegistry.getIDFromImplementationModelElement(target);
EObject newElement = idRegistry.getImplementationModelElement(priorID, EcoreUtil.getRootContainer(modelElement));
EObject newElement = idRegistry.resolveImplementationModelElement(priorID, EcoreUtil.getRootContainer(modelElement));
if (newElement == null) {
AbstractModelCodeTransformation<?, ?> t = new TransitionTransformation(this);
t.setPriorModelElement(target);
......
......@@ -37,7 +37,7 @@ public class StatesTransformation extends AnnotatedMemberReferenceTransformation
}
for (EObject target : Models.getTargetsAsList(priorModelElement, eReference)) {
String priorID = priorIDRegistry.getIDFromImplementationModelElement(target);
EObject newElement = idRegistry.getImplementationModelElement(priorID, EcoreUtil.getRootContainer(modelElement));
EObject newElement = idRegistry.resolveImplementationModelElement(priorID, EcoreUtil.getRootContainer(modelElement));
if (newElement == null) {
AbstractModelCodeTransformation<?, ?> t = new StateTransformation(this);
t.setPriorModelElement(target);
......
......@@ -161,7 +161,7 @@ public class IDRegistry {
return null;
}
public EObject getImplementationModelElement(EObject translationModelElement, EObject implementationModelRootElement) {
public EObject resolveImplementationModelElement(EObject translationModelElement, EObject implementationModelRootElement) {
final String translationModelPath = getPath(translationModelElement);
for (final Entry<String, String[]> e : id2paths.entrySet()) {
......@@ -306,7 +306,7 @@ public class IDRegistry {
return sb.toString();
}
public EObject getImplementationModelElement(String id, List<EObject> implementationModelRoots) {
public EObject resolveImplementationModelElement(String id, List<EObject> implementationModelRoots) {
final String[] entry = id2paths.get(id);
if (entry == null) {
......@@ -324,19 +324,19 @@ public class IDRegistry {
}
}
public EObject getImplementationModelElement(String id, EObject rootContainer) {
public EObject resolveImplementationModelElement(String id, EObject rootContainer) {
final LinkedList<EObject> roots = new LinkedList<>();
roots.add(rootContainer);
return getImplementationModelElement(id, roots);
return resolveImplementationModelElement(id, roots);
}
public EObject getTranslationModelElement(String id, EObject rootContainer) {
public EObject resolveTranslationModelElement(String id, EObject rootContainer) {
final LinkedList<EObject> roots = new LinkedList<>();
roots.add(rootContainer);
return getTranslationModelElement(id, roots);
return resolveTranslationModelElement(id, roots);
}
public EObject getTranslationModelElement(String id, List<EObject> translationModelRoots) {
public EObject resolveTranslationModelElement(String id, List<EObject> translationModelRoots) {
final String[] entry = id2paths.get(id);
if (entry == null || entry[2] == null) {
......@@ -376,13 +376,13 @@ public class IDRegistry {
}
public EObject getTranslationModelElement(EObject implementationModelElement, EObject translationModelRootElement) {
public EObject resolveTranslationModelElement(EObject implementationModelElement, EObject translationModelRootElement) {
final LinkedList<EObject> roots = new LinkedList<>();
roots.add(translationModelRootElement);
return getTranslationModelElement(implementationModelElement, roots);
return resolveTranslationModelElement(implementationModelElement, roots);
}
public EObject getTranslationModelElement(EObject implementationModelElement, List<EObject> translationModelRoots) {
public EObject resolveTranslationModelElement(EObject implementationModelElement, List<EObject> translationModelRoots) {
final String implementationModelPath = getPath(implementationModelElement);
boolean foundImplementationModelElement = false;
......
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