From 84552c2d39ee904da32e4f34258eb0e287fcd9a4 Mon Sep 17 00:00:00 2001 From: Heiko Klare Date: Tue, 23 Feb 2021 10:09:06 +0100 Subject: [PATCH] Remove obsolete functionality from Mappings runtime project --- .../META-INF/MANIFEST.MF | 6 +- .../mappings/AbstractMappingRuntime.xtend | 68 ----------- .../dslsruntime/mappings/MappingsUtil.xtend | 92 -------------- ...pCandidatesAndInstanceHalvesRegistry.xtend | 112 ------------------ ...hMapLeftAndRightInstanceHalfRegistry.xtend | 97 --------------- ...pCandidatesAndInstanceHalvesRegistry.xtend | 54 --------- .../impl/SetMultimapElementsRegistry.xtend | 46 ------- .../IBothSidesCombiningRegistry.xtend | 26 ---- .../interfaces/IElementsRegistry.xtend | 15 --- .../ILeftAndRightCandidatesRegistry.xtend | 10 -- .../interfaces/IMappingInstanceHalf.xtend | 15 --- .../interfaces/IMappingRegistry.xtend | 11 -- ...gistry4DependingCandidatesGenerators.xtend | 13 -- .../IMappingRegistry4Reactions.xtend | 13 -- 14 files changed, 1 insertion(+), 577 deletions(-) delete mode 100644 bundles/extensions/dslsruntime/tools.vitruv.extensions.dslsruntime.mappings/src/tools/vitruv/extensions/dslsruntime/mappings/AbstractMappingRuntime.xtend delete mode 100644 bundles/extensions/dslsruntime/tools.vitruv.extensions.dslsruntime.mappings/src/tools/vitruv/extensions/dslsruntime/mappings/MappingsUtil.xtend delete mode 100644 bundles/extensions/dslsruntime/tools.vitruv.extensions.dslsruntime.mappings/src/tools/vitruv/extensions/dslsruntime/mappings/impl/HashMapCandidatesAndInstanceHalvesRegistry.xtend delete mode 100644 bundles/extensions/dslsruntime/tools.vitruv.extensions.dslsruntime.mappings/src/tools/vitruv/extensions/dslsruntime/mappings/impl/HashMapLeftAndRightInstanceHalfRegistry.xtend delete mode 100644 bundles/extensions/dslsruntime/tools.vitruv.extensions.dslsruntime.mappings/src/tools/vitruv/extensions/dslsruntime/mappings/impl/SetMultimapElementsAndHashMapCandidatesAndInstanceHalvesRegistry.xtend delete mode 100644 bundles/extensions/dslsruntime/tools.vitruv.extensions.dslsruntime.mappings/src/tools/vitruv/extensions/dslsruntime/mappings/impl/SetMultimapElementsRegistry.xtend delete mode 100644 bundles/extensions/dslsruntime/tools.vitruv.extensions.dslsruntime.mappings/src/tools/vitruv/extensions/dslsruntime/mappings/interfaces/IBothSidesCombiningRegistry.xtend delete mode 100644 bundles/extensions/dslsruntime/tools.vitruv.extensions.dslsruntime.mappings/src/tools/vitruv/extensions/dslsruntime/mappings/interfaces/IElementsRegistry.xtend delete mode 100644 bundles/extensions/dslsruntime/tools.vitruv.extensions.dslsruntime.mappings/src/tools/vitruv/extensions/dslsruntime/mappings/interfaces/ILeftAndRightCandidatesRegistry.xtend delete mode 100644 bundles/extensions/dslsruntime/tools.vitruv.extensions.dslsruntime.mappings/src/tools/vitruv/extensions/dslsruntime/mappings/interfaces/IMappingInstanceHalf.xtend delete mode 100644 bundles/extensions/dslsruntime/tools.vitruv.extensions.dslsruntime.mappings/src/tools/vitruv/extensions/dslsruntime/mappings/interfaces/IMappingRegistry.xtend delete mode 100644 bundles/extensions/dslsruntime/tools.vitruv.extensions.dslsruntime.mappings/src/tools/vitruv/extensions/dslsruntime/mappings/interfaces/IMappingRegistry4DependingCandidatesGenerators.xtend delete mode 100644 bundles/extensions/dslsruntime/tools.vitruv.extensions.dslsruntime.mappings/src/tools/vitruv/extensions/dslsruntime/mappings/interfaces/IMappingRegistry4Reactions.xtend diff --git a/bundles/extensions/dslsruntime/tools.vitruv.extensions.dslsruntime.mappings/META-INF/MANIFEST.MF b/bundles/extensions/dslsruntime/tools.vitruv.extensions.dslsruntime.mappings/META-INF/MANIFEST.MF index 1ffbbd17c1..c1d84d9e86 100644 --- a/bundles/extensions/dslsruntime/tools.vitruv.extensions.dslsruntime.mappings/META-INF/MANIFEST.MF +++ b/bundles/extensions/dslsruntime/tools.vitruv.extensions.dslsruntime.mappings/META-INF/MANIFEST.MF @@ -8,9 +8,5 @@ Bundle-Vendor: %providerName Bundle-RequiredExecutionEnvironment: JavaSE-11 Require-Bundle: edu.kit.ipd.sdq.activextendannotations, tools.vitruv.extensions.dslsruntime.reactions;visibility:=reexport -Export-Package: tools.vitruv.extensions.dslsruntime.mappings, - tools.vitruv.extensions.dslsruntime.mappings.impl;x-internal:=true, - tools.vitruv.extensions.dslsruntime.mappings.interfaces, - tools.vitruv.extensions.dslsruntime.mappings.marker, +Export-Package: tools.vitruv.extensions.dslsruntime.mappings.marker, tools.vitruv.extensions.dslsruntime.mappings.updates - diff --git a/bundles/extensions/dslsruntime/tools.vitruv.extensions.dslsruntime.mappings/src/tools/vitruv/extensions/dslsruntime/mappings/AbstractMappingRuntime.xtend b/bundles/extensions/dslsruntime/tools.vitruv.extensions.dslsruntime.mappings/src/tools/vitruv/extensions/dslsruntime/mappings/AbstractMappingRuntime.xtend deleted file mode 100644 index 30df94943c..0000000000 --- a/bundles/extensions/dslsruntime/tools.vitruv.extensions.dslsruntime.mappings/src/tools/vitruv/extensions/dslsruntime/mappings/AbstractMappingRuntime.xtend +++ /dev/null @@ -1,68 +0,0 @@ -package tools.vitruv.extensions.dslsruntime.mappings - -import org.eclipse.xtend.lib.annotations.Delegate -import tools.vitruv.extensions.dslsruntime.mappings.interfaces.IElementsRegistry -import tools.vitruv.extensions.dslsruntime.mappings.interfaces.IMappingInstanceHalf -import tools.vitruv.extensions.dslsruntime.mappings.interfaces.IMappingRegistry4Reactions -import tools.vitruv.extensions.dslsruntime.mappings.interfaces.IMappingRegistry4DependingCandidatesGenerators -import tools.vitruv.extensions.dslsruntime.mappings.interfaces.IBothSidesCombiningRegistry -import tools.vitruv.extensions.dslsruntime.mappings.interfaces.ILeftAndRightCandidatesRegistry -import tools.vitruv.extensions.dslsruntime.mappings.impl.SetMultimapElementsAndHashMapCandidatesAndInstanceHalvesRegistry - -/** - *

Base class instantiated by all runtime registry classes that are generated - * for mappings defined with the mappings language.

- * - *

It is the only entry point to all mapping platform code from reactions or Xtend code. - * It provides, for example, access to methods for maintaining runtime information about instances of relevant - * metaclasses ({@link IElementsRegistry getElementsRegistry()}) and to current instances of mappings as well as to - * candidates for instances of mappings - * (see {@link tools.vitruv.extensions.dslsruntime.mappings.interfaces.IMappingRegistry4Reactions IMappingRegistry4Reactions}. - *

- * - *

Access to and manipulation of runtime information for mappings is restricted and realized in three different ways:

- * - *

First, only the methods of {@link tools.vitruv.extensions.dslsruntime.mappings.interfaces.IMappingRegistry4Reactions IMappingRegistry4Reactions} - * are accessible from generated reactions code. (This is achieved by delegating these methods to the {@link #registry} field.)

- * - *

Second, the methods of {@link tools.vitruv.extensions.dslsruntime.mappings.interfaces.IMappingRegistry4DependingCandidatesGenerators IMappingRegistry4DependingCandidatesGenerators} - * are made available to generated Xtend code but not to reactions code. (This is realized by generating a package protected getter - * in the generated mapping class. This getter delegates to the protected getter in AbstractMappingRuntime, which is a superclass of the generated mapping class.)

- * - *

Third and last, the methods of {@link tools.vitruv.extensions.dslsruntime.mappings.interfaces.IElementsRegistry IElementsRegistry} - * and {@link tools.vitruv.extensions.dslsruntime.mappings.interfaces.ILeftAndRightInstanceHalvesRegistry ILeftAndRightInstanceHalvesRegistry} - * are made available to generated Xtend code but not to reactions code via ordinary protected getters.

- */ -abstract class AbstractMappingRuntime implements IMappingRegistry4Reactions { - @Delegate - val SetMultimapElementsAndHashMapCandidatesAndInstanceHalvesRegistry registry - - /** - * @param mappingName the name of the mapping for debugging and error messages. - */ - protected new(String mappingName) { - this.registry = new SetMultimapElementsAndHashMapCandidatesAndInstanceHalvesRegistry(mappingName) - // TODO MK reestablish all mapping runtime information from previous runs of Vitruvius - // As discussed with HK and JG, the goal is to visit all correspondences after they were loaded - // and to build up the instance part of the registry by looking at the correspondence tags. - // The elements part of the registry has to be reestablished by visiting - // all contents of all models and afterwards the candidates part has to be restablished by computing - // all cartesian products of these elements but subtracting the instances that were restablished from the correspondences. - } - - protected def IMappingRegistry4DependingCandidatesGenerators getRegistry4DependingCandidatesGenerator() { - return registry - } - - protected def IElementsRegistry getElementsRegistry() { - return registry.elementsRegistry - } - - protected def ILeftAndRightCandidatesRegistry getLeftAndRightRegistry() { - return registry.leftAndRightRegistry - } - - protected def IBothSidesCombiningRegistry getBothSidesCombiningRegistry() { - return registry - } -} \ No newline at end of file diff --git a/bundles/extensions/dslsruntime/tools.vitruv.extensions.dslsruntime.mappings/src/tools/vitruv/extensions/dslsruntime/mappings/MappingsUtil.xtend b/bundles/extensions/dslsruntime/tools.vitruv.extensions.dslsruntime.mappings/src/tools/vitruv/extensions/dslsruntime/mappings/MappingsUtil.xtend deleted file mode 100644 index c618aebd23..0000000000 --- a/bundles/extensions/dslsruntime/tools.vitruv.extensions.dslsruntime.mappings/src/tools/vitruv/extensions/dslsruntime/mappings/MappingsUtil.xtend +++ /dev/null @@ -1,92 +0,0 @@ -package tools.vitruv.extensions.dslsruntime.mappings - -import org.eclipse.emf.ecore.EObject -import java.util.List -import java.util.Set -import com.google.common.collect.Sets -import edu.kit.ipd.sdq.activextendannotations.Utility -import edu.kit.ipd.sdq.commons.util.java.Pair -import edu.kit.ipd.sdq.commons.util.java.Triple -import edu.kit.ipd.sdq.commons.util.java.Quadruple -import edu.kit.ipd.sdq.commons.util.java.Monuple -import edu.kit.ipd.sdq.commons.util.java.Quintuple - -/** - * Utility class providing static methods that are used by code that is generated for mappings - * that were defined using the mappings language. - */ -@Utility -class MappingsUtil { - - def static boolean allElementsStillExisting(EObject... elements) { - for (element : elements) { - if (element.eResource === null) { - return false - } - } - return true - } - - /** - * Returns the cartesian product of the given sets. - * (Used by generated mapping code for computing all mapping candidate combinations.) - */ - private def static Iterable> untypedCartesianProduct(Set... sets) { - return Sets.cartesianProduct(sets) - } - - /** - * Returns the correctly typed cartesian product of the given set. - */ - def static Iterable> typedCartesianProduct(Set aSet) { - return untypedCartesianProduct(aSet).map[new Monuple( - it.get(0) - )] - } - - /** - * Returns the correctly typed cartesian product of the given sets. - */ - def static Iterable> typedCartesianProduct(Set aSet, Set bSet) { - return untypedCartesianProduct(aSet, bSet).map[new Pair( - it.get(0) as A, - it.get(1) as B - )] - } - - /** - * Returns the correctly typed cartesian product of the given sets. - */ - def static Iterable> typedCartesianProduct(Set aSet, Set bSet, Set cSet) { - return untypedCartesianProduct(aSet, bSet, cSet).map[new Triple( - it.get(0) as A, - it.get(1) as B, - it.get(2) as C - )] - } - - /** - * Returns the correctly typed cartesian product of the given sets. - */ - def static Iterable> typedCartesianProduct(Set aSet, Set bSet, Set cSet, Set dSet) { - return untypedCartesianProduct(aSet, bSet, cSet, dSet).map[new Quadruple( - it.get(0) as A, - it.get(1) as B, - it.get(2) as C, - it.get(3) as D - )] - } - - /** - * Returns the correctly typed cartesian product of the given sets. - */ - def static Iterable> typedCartesianProduct(Set aSet, Set bSet, Set cSet, Set dSet, Set eSet) { - return untypedCartesianProduct(aSet, bSet, cSet, dSet).map[new Quintuple( - it.get(0) as A, - it.get(1) as B, - it.get(2) as C, - it.get(3) as D, - it.get(4) as E - )] - } -} \ No newline at end of file diff --git a/bundles/extensions/dslsruntime/tools.vitruv.extensions.dslsruntime.mappings/src/tools/vitruv/extensions/dslsruntime/mappings/impl/HashMapCandidatesAndInstanceHalvesRegistry.xtend b/bundles/extensions/dslsruntime/tools.vitruv.extensions.dslsruntime.mappings/src/tools/vitruv/extensions/dslsruntime/mappings/impl/HashMapCandidatesAndInstanceHalvesRegistry.xtend deleted file mode 100644 index 2bf4212478..0000000000 --- a/bundles/extensions/dslsruntime/tools.vitruv.extensions.dslsruntime.mappings/src/tools/vitruv/extensions/dslsruntime/mappings/impl/HashMapCandidatesAndInstanceHalvesRegistry.xtend +++ /dev/null @@ -1,112 +0,0 @@ -package tools.vitruv.extensions.dslsruntime.mappings.impl - -import java.util.List -import java.util.Map -import java.util.Set -import org.apache.log4j.Logger -import org.eclipse.emf.ecore.EObject -import tools.vitruv.extensions.dslsruntime.mappings.interfaces.IMappingInstanceHalf - -/** - * An object of this class keeps track of current mapping instantiations and of candidates, which are combinations - * of model elements that can become future mapping instantiations, for one side of a certain mapping. - * That is, two objects of this class are necessary to keep track of the left and the right half of each - * mapping instantiation and each mapping instantiation candidate. - */ -class HashMapCandidatesAndInstanceHalvesRegistry { - static extension Logger LOGGER = Logger.getLogger(HashMapCandidatesAndInstanceHalvesRegistry) - val String mappingName - val String sideName - val Map,H> candidatesRegistry = newHashMap() - val Map,H> instanceHalvesRegistry = newHashMap() - - new(String mappingName, String sideName) { - this.mappingName = mappingName - this.sideName = sideName - } - - /********** BEGIN GETTER METHODS **********/ - protected def Iterable getCandidatesClone() { - return candidatesRegistry.values.clone - } - - protected def Iterable getInstanceHalvesClone() { - return instanceHalvesRegistry.values.clone - } - - protected def H getCandidateForElements(List elements) { - return candidatesRegistry.get(elements) - } - - protected def H getInstanceHalfForElements(List elements) { - return instanceHalvesRegistry.get(elements) - } - - /********** BEGIN SETTER METHODS **********/ - protected def void addCandidates(Iterable candidates) { - candidates.forEach[addCandidatesOrInstanceHalf(candidatesRegistry, it, "candidate")] - } - - private def void removeCandidate(H candidate) { - removeCandidateOrInstanceHalf(candidatesRegistry, candidate, "candidate") - } - - private def void addInstanceHalf(H instanceHalf) { - addCandidatesOrInstanceHalf(instanceHalvesRegistry, instanceHalf, "instance half") - } - - protected def void removeInstanceHalf(H instanceHalf) { - removeCandidateOrInstanceHalf(instanceHalvesRegistry, instanceHalf, "instance half") - } - - private def void addCandidatesOrInstanceHalf(Map,H> registry, H candidateOrInstanceHalf, String type) { - val previouslyRegistered = registry.put(candidateOrInstanceHalf.getElements(), candidateOrInstanceHalf) - if (previouslyRegistered !== null) { - throw new IllegalStateException('''Cannot register the «sideName» mapping «type» '«candidateOrInstanceHalf»' for the mapping '«mappingName»' - because the «sideName» mapping «type» '«previouslyRegistered»' is already registered for - the «sideName» elements '«candidateOrInstanceHalf.getElements()»'!''') - } - } - - private def void removeCandidateOrInstanceHalf(Map,H> registry, H candidateOrInstanceHalf, String type) { - val registered = registry.remove(candidateOrInstanceHalf.getElements()) - if (registered === null) { - throw new IllegalStateException(getDeregisterMessage(candidateOrInstanceHalf,"nothing ", type)) - } else if (registered != candidateOrInstanceHalf) { - throw new IllegalStateException(getDeregisterMessage(candidateOrInstanceHalf,'''the «sideName» mapping instance half '«registered»' ''', type)) - } - } - - private def String getDeregisterMessage(H candidateOrInstanceHalf, String mapped, String type) '''Cannot deregister the «sideName» mapping «type» '«candidateOrInstanceHalf»' for the mapping '«mappingName»' - and the «sideName» elements '«candidateOrInstanceHalf.getElements()» because «mapped»was registered for these elements!''' - - /********** BEGIN CANDIDATE METHODS **********/ - protected def void removeCandidatesForElement(EObject element) { - val iterator = candidatesRegistry.keySet().iterator() - var atLeastOneSetRemoved = false - while (iterator.hasNext()) { - val pivot = iterator.next() - if (pivot.contains(element)) { - iterator.remove() - atLeastOneSetRemoved = true - } - } - if (!atLeastOneSetRemoved) { - info('''No «sideName» candidates to be removed are registered for the element '«element»' - in '«iterator.toList»' of the mapping '«mappingName»'.''') - } - } - - protected def Set getCandidatesAndInstances() { - val candidatesAndInstances = newHashSet() - candidatesAndInstances.addAll(candidatesClone) - candidatesAndInstances.addAll(instanceHalvesClone) - return candidatesAndInstances - } - - /********** BEGIN INSTANCE METHODS **********/ - protected def void promoteCandidateToInstanceHalf(H candidate) { - removeCandidate(candidate) - addInstanceHalf(candidate) - } -} \ No newline at end of file diff --git a/bundles/extensions/dslsruntime/tools.vitruv.extensions.dslsruntime.mappings/src/tools/vitruv/extensions/dslsruntime/mappings/impl/HashMapLeftAndRightInstanceHalfRegistry.xtend b/bundles/extensions/dslsruntime/tools.vitruv.extensions.dslsruntime.mappings/src/tools/vitruv/extensions/dslsruntime/mappings/impl/HashMapLeftAndRightInstanceHalfRegistry.xtend deleted file mode 100644 index 19c75bd0c2..0000000000 --- a/bundles/extensions/dslsruntime/tools.vitruv.extensions.dslsruntime.mappings/src/tools/vitruv/extensions/dslsruntime/mappings/impl/HashMapLeftAndRightInstanceHalfRegistry.xtend +++ /dev/null @@ -1,97 +0,0 @@ -package tools.vitruv.extensions.dslsruntime.mappings.impl - -import java.util.List -import java.util.Set -import org.eclipse.emf.ecore.EObject -import tools.vitruv.extensions.dslsruntime.mappings.interfaces.IMappingInstanceHalf -import tools.vitruv.extensions.dslsruntime.mappings.interfaces.IMappingRegistry - -/** - * An object of this class keeps track of the left and the right half of every - * mapping instantiation and every mapping instantiation candidate for a certain mapping. - * See also {@link HashMapCandidatesAndInstanceHalvesRegistry} - */ -class HashMapLeftAndRightInstanceHalfRegistry implements IMappingRegistry { - val HashMapCandidatesAndInstanceHalvesRegistry left - val HashMapCandidatesAndInstanceHalvesRegistry right - - new(String mappingName) { - this.left = new HashMapCandidatesAndInstanceHalvesRegistry(mappingName, "left") - this.right = new HashMapCandidatesAndInstanceHalvesRegistry(mappingName, "right") - } - - /********** BEGIN PROTECTED METHODS **********/ - /* (only used by SetMultimapElementsAndHashMapCandidatesAndInstanceHalvesRegistry) */ - protected def L getLeftCandidateForElements(List elements) { - return left.getCandidateForElements(elements) - } - - protected def R getRightCandidateForElements(List elements) { - return right.getCandidateForElements(elements) - } - - protected def void removeLeftCandidatesForElement(EObject element) { - left.removeCandidatesForElement(element) - } - - protected def void removeRightCandidatesForElement(EObject element) { - right.removeCandidatesForElement(element) - } - - protected def void promoteLeftCandidateToInstanceHalf(L candidate) { - left.promoteCandidateToInstanceHalf(candidate) - } - - protected def void promoteRightCandidateToInstanceHalf(R candidate) { - right.promoteCandidateToInstanceHalf(candidate) - } - - protected def L getLeftInstanceHalfForElements(List elements) { - return left.getInstanceHalfForElements(elements) - } - - protected def R getRightInstanceHalfForElements(List elements) { - return right.getInstanceHalfForElements(elements) - } - - protected def void removeLeftInstanceHalf(L instance) { - left.removeInstanceHalf(instance) - } - - protected def removeRightInstanceHalf(R instance) { - right.removeInstanceHalf(instance) - } - - /********** BEGIN DELEGATED PUBLIC METHODS **********/ - override Iterable getLeftCandidatesClone() { - return left.candidatesClone - } - - override Iterable getRightCandidatesClone() { - return right.candidatesClone - } - - override void addLeftCandidates(Iterable candidates) { - left.addCandidates(candidates) - } - - override void addRightCandidates(Iterable candidates) { - right.addCandidates(candidates) - } - - override Iterable getLeftInstanceHalvesClone() { - return left.instanceHalvesClone - } - - override Iterable getRightInstanceHalvesClone() { - return right.instanceHalvesClone - } - - override Set getLeftCandidatesAndInstances() { - return left.candidatesAndInstances - } - - override Set getRightCandidatesAndInstances() { - return right.candidatesAndInstances - } -} \ No newline at end of file diff --git a/bundles/extensions/dslsruntime/tools.vitruv.extensions.dslsruntime.mappings/src/tools/vitruv/extensions/dslsruntime/mappings/impl/SetMultimapElementsAndHashMapCandidatesAndInstanceHalvesRegistry.xtend b/bundles/extensions/dslsruntime/tools.vitruv.extensions.dslsruntime.mappings/src/tools/vitruv/extensions/dslsruntime/mappings/impl/SetMultimapElementsAndHashMapCandidatesAndInstanceHalvesRegistry.xtend deleted file mode 100644 index 9efe71b6ca..0000000000 --- a/bundles/extensions/dslsruntime/tools.vitruv.extensions.dslsruntime.mappings/src/tools/vitruv/extensions/dslsruntime/mappings/impl/SetMultimapElementsAndHashMapCandidatesAndInstanceHalvesRegistry.xtend +++ /dev/null @@ -1,54 +0,0 @@ -package tools.vitruv.extensions.dslsruntime.mappings.impl - -import java.util.List -import org.eclipse.emf.ecore.EObject -import org.eclipse.xtend.lib.annotations.Accessors -import org.eclipse.xtend.lib.annotations.Delegate -import tools.vitruv.extensions.dslsruntime.mappings.interfaces.IElementsRegistry -import tools.vitruv.extensions.dslsruntime.mappings.interfaces.IMappingInstanceHalf -import tools.vitruv.extensions.dslsruntime.mappings.interfaces.IMappingRegistry -import tools.vitruv.extensions.dslsruntime.mappings.interfaces.IBothSidesCombiningRegistry - -/** - * An object of this class maintains runtime information about instances of relevant - * metaclasses, current instances and candidates for instances of a certain mapping - * by using a registry for the metaclass instances (also called elements), and - * another registry that combines two registries for left and right instantiation halves and candidates - * for these halves. - */ -class SetMultimapElementsAndHashMapCandidatesAndInstanceHalvesRegistry implements IBothSidesCombiningRegistry, IMappingRegistry { - @Accessors(PUBLIC_GETTER) - val IElementsRegistry elementsRegistry - @Accessors(PUBLIC_GETTER) - @Delegate - val HashMapLeftAndRightInstanceHalfRegistry leftAndRightRegistry - - new(String mappingName) { - this.leftAndRightRegistry = new HashMapLeftAndRightInstanceHalfRegistry(mappingName) - this.elementsRegistry = new SetMultimapElementsRegistry(mappingName) - } - - override void removeLeftElementAndCandidates(Class clazz, C element) { - elementsRegistry.removeElement(clazz, element) - leftAndRightRegistry.removeLeftCandidatesForElement(element) - } - - override void removeRightElementAndCandidates(Class clazz, C element) { - elementsRegistry.removeElement(clazz, element) - leftAndRightRegistry.removeRightCandidatesForElement(element) - } - - override void removeInvalidatedInstanceHalves(List leftElements, List rightElements) { - val leftInstanceHalf = leftAndRightRegistry.getLeftInstanceHalfForElements(leftElements) - val rightInstanceHalf = leftAndRightRegistry.getRightInstanceHalfForElements(rightElements) - leftAndRightRegistry.removeLeftInstanceHalf(leftInstanceHalf) - leftAndRightRegistry.removeRightInstanceHalf(rightInstanceHalf) - } - - override void promoteValidatedCandidatesToInstances(List leftElements, List rightElements) { - val leftCandidate = leftAndRightRegistry.getLeftCandidateForElements(leftElements) - val rightCandidate = leftAndRightRegistry.getRightCandidateForElements(rightElements) - leftAndRightRegistry.promoteLeftCandidateToInstanceHalf(leftCandidate) - leftAndRightRegistry.promoteRightCandidateToInstanceHalf(rightCandidate) - } -} \ No newline at end of file diff --git a/bundles/extensions/dslsruntime/tools.vitruv.extensions.dslsruntime.mappings/src/tools/vitruv/extensions/dslsruntime/mappings/impl/SetMultimapElementsRegistry.xtend b/bundles/extensions/dslsruntime/tools.vitruv.extensions.dslsruntime.mappings/src/tools/vitruv/extensions/dslsruntime/mappings/impl/SetMultimapElementsRegistry.xtend deleted file mode 100644 index 4e04724114..0000000000 --- a/bundles/extensions/dslsruntime/tools.vitruv.extensions.dslsruntime.mappings/src/tools/vitruv/extensions/dslsruntime/mappings/impl/SetMultimapElementsRegistry.xtend +++ /dev/null @@ -1,46 +0,0 @@ -package tools.vitruv.extensions.dslsruntime.mappings.impl - -import com.google.common.collect.SetMultimap -import org.eclipse.emf.ecore.EObject -import com.google.common.collect.HashMultimap -import java.util.Set -import tools.vitruv.extensions.dslsruntime.mappings.interfaces.IElementsRegistry - -/** - * An object of this class keeps track of all instances of all metaclasses that appear as a - * mapping parameter on at least one side of a mapping signature for a certain mapping. - * Realized by mapping every relevant metaclass to a set that contains all instances of the metaclass. - */ -class SetMultimapElementsRegistry implements IElementsRegistry { - /** - * Behaves like a {@code Map, Set>} but creates - * and maintains the necessary sets for us. - */ - val SetMultimap, EObject> elementsMap - val String mappingName - - new(String mappingName) { - this.elementsMap = HashMultimap.create() - this.mappingName = mappingName - } - - override Set getElements(Class clazz) { - return elementsMap.get(clazz) as Set - } - - override void addElement(Class clazz, C element) { - val elementIsNew = elementsMap.put(clazz, element) - if (!elementIsNew) { - throw new IllegalStateException('''Cannot register the element '«element»' for the mapping '«mappingName»' - and the class '«clazz»' because it is already registered for them!''') - } - } - - override void removeElement(Class clazz, C element) { - val wasMapped = elementsMap.remove(clazz, element) - if (!wasMapped) { - throw new IllegalStateException('''Cannot deregister the element '«element»' for the mapping '«mappingName»' - and the class '«clazz»' because it is not registered for them!''') - } - } -} \ No newline at end of file diff --git a/bundles/extensions/dslsruntime/tools.vitruv.extensions.dslsruntime.mappings/src/tools/vitruv/extensions/dslsruntime/mappings/interfaces/IBothSidesCombiningRegistry.xtend b/bundles/extensions/dslsruntime/tools.vitruv.extensions.dslsruntime.mappings/src/tools/vitruv/extensions/dslsruntime/mappings/interfaces/IBothSidesCombiningRegistry.xtend deleted file mode 100644 index a6e4cac4d0..0000000000 --- a/bundles/extensions/dslsruntime/tools.vitruv.extensions.dslsruntime.mappings/src/tools/vitruv/extensions/dslsruntime/mappings/interfaces/IBothSidesCombiningRegistry.xtend +++ /dev/null @@ -1,26 +0,0 @@ -package tools.vitruv.extensions.dslsruntime.mappings.interfaces - -import org.eclipse.emf.ecore.EObject -import java.util.List - -/** - * Interface for updating runtime information when an instance of a metaclass that appears as a mapping parameter - * in a mapping signature is removed or when candidate tuples of such instances no longer or newly fulfill - * the conditions of the mapping (i.e. they are invalidated or new mapping instantiations). - */ -interface IBothSidesCombiningRegistry { - /** - * Removes the passed element, which has to be an instance of a metaclass that - * appears as a mapping parameter on the left side of a mapping signature, and all candidate tuples - * that involve the element from the runtime registry for the mapping. - */ - def void removeLeftElementAndCandidates(Class clazz, C element) - /** - * Removes the passed element, which has to be an instance of a metaclass that - * appears as a mapping parameter on the right side of a mapping signature, and all candidate tuples - * that involve the element from the runtime registry for the mapping. - */ - def void removeRightElementAndCandidates(Class clazz, C element) - def void removeInvalidatedInstanceHalves(List leftElements, List rightElements) - def void promoteValidatedCandidatesToInstances(List leftElements, List rightElements) -} \ No newline at end of file diff --git a/bundles/extensions/dslsruntime/tools.vitruv.extensions.dslsruntime.mappings/src/tools/vitruv/extensions/dslsruntime/mappings/interfaces/IElementsRegistry.xtend b/bundles/extensions/dslsruntime/tools.vitruv.extensions.dslsruntime.mappings/src/tools/vitruv/extensions/dslsruntime/mappings/interfaces/IElementsRegistry.xtend deleted file mode 100644 index 0ed3e53774..0000000000 --- a/bundles/extensions/dslsruntime/tools.vitruv.extensions.dslsruntime.mappings/src/tools/vitruv/extensions/dslsruntime/mappings/interfaces/IElementsRegistry.xtend +++ /dev/null @@ -1,15 +0,0 @@ -package tools.vitruv.extensions.dslsruntime.mappings.interfaces - -import java.util.Set -import org.eclipse.emf.ecore.EObject - -/** - * Interface for keeping track of all instances for certain metaclasses. - * Used to restrict the checking of mapping conditions to instances - * of those metaclasses that appear as mapping parameters in the mapping signature. - */ -interface IElementsRegistry { - def Set getElements(Class clazz) - def void addElement(Class clazz, C element) - def void removeElement(Class clazz, C element) -} \ No newline at end of file diff --git a/bundles/extensions/dslsruntime/tools.vitruv.extensions.dslsruntime.mappings/src/tools/vitruv/extensions/dslsruntime/mappings/interfaces/ILeftAndRightCandidatesRegistry.xtend b/bundles/extensions/dslsruntime/tools.vitruv.extensions.dslsruntime.mappings/src/tools/vitruv/extensions/dslsruntime/mappings/interfaces/ILeftAndRightCandidatesRegistry.xtend deleted file mode 100644 index e0400351f2..0000000000 --- a/bundles/extensions/dslsruntime/tools.vitruv.extensions.dslsruntime.mappings/src/tools/vitruv/extensions/dslsruntime/mappings/interfaces/ILeftAndRightCandidatesRegistry.xtend +++ /dev/null @@ -1,10 +0,0 @@ -package tools.vitruv.extensions.dslsruntime.mappings.interfaces - -/** - * Interface for registering tuples of instances of mapped metaclasses that may or may not fulfill the conditions - * specified in a mapping. The tuples are called mapping instantiation candidates or briefly candidates. - */ -interface ILeftAndRightCandidatesRegistry { - def void addLeftCandidates(Iterable candidates); - def void addRightCandidates(Iterable candidates); -} \ No newline at end of file diff --git a/bundles/extensions/dslsruntime/tools.vitruv.extensions.dslsruntime.mappings/src/tools/vitruv/extensions/dslsruntime/mappings/interfaces/IMappingInstanceHalf.xtend b/bundles/extensions/dslsruntime/tools.vitruv.extensions.dslsruntime.mappings/src/tools/vitruv/extensions/dslsruntime/mappings/interfaces/IMappingInstanceHalf.xtend deleted file mode 100644 index 5cc603fbbd..0000000000 --- a/bundles/extensions/dslsruntime/tools.vitruv.extensions.dslsruntime.mappings/src/tools/vitruv/extensions/dslsruntime/mappings/interfaces/IMappingInstanceHalf.xtend +++ /dev/null @@ -1,15 +0,0 @@ -package tools.vitruv.extensions.dslsruntime.mappings.interfaces - -import java.util.List -import org.eclipse.emf.ecore.EObject - -/** - * Interface for data structures that group elements of a metamodel for an instantiation of a mapping, which relates instances of two metamodels. - */ -interface IMappingInstanceHalf { - def List getElements() - - def boolean contains(EObject element) { - return getElements().contains(element) - } -} \ No newline at end of file diff --git a/bundles/extensions/dslsruntime/tools.vitruv.extensions.dslsruntime.mappings/src/tools/vitruv/extensions/dslsruntime/mappings/interfaces/IMappingRegistry.xtend b/bundles/extensions/dslsruntime/tools.vitruv.extensions.dslsruntime.mappings/src/tools/vitruv/extensions/dslsruntime/mappings/interfaces/IMappingRegistry.xtend deleted file mode 100644 index 4f6d5f40c1..0000000000 --- a/bundles/extensions/dslsruntime/tools.vitruv.extensions.dslsruntime.mappings/src/tools/vitruv/extensions/dslsruntime/mappings/interfaces/IMappingRegistry.xtend +++ /dev/null @@ -1,11 +0,0 @@ -package tools.vitruv.extensions.dslsruntime.mappings.interfaces - -/** - * Convenience interface combining all methods to maintain runtime information about instantiations - * and instantiation candidates for a mapping on both sides. It does not provide information - * about individual instantiations of metaclasses that appear as mapping parameters but only on - * tuples that contain such elements of the right type and the right order. - */ -interface IMappingRegistry extends ILeftAndRightCandidatesRegistry, IMappingRegistry4Reactions, IMappingRegistry4DependingCandidatesGenerators { - // no additional methods -} \ No newline at end of file diff --git a/bundles/extensions/dslsruntime/tools.vitruv.extensions.dslsruntime.mappings/src/tools/vitruv/extensions/dslsruntime/mappings/interfaces/IMappingRegistry4DependingCandidatesGenerators.xtend b/bundles/extensions/dslsruntime/tools.vitruv.extensions.dslsruntime.mappings/src/tools/vitruv/extensions/dslsruntime/mappings/interfaces/IMappingRegistry4DependingCandidatesGenerators.xtend deleted file mode 100644 index 507dd74245..0000000000 --- a/bundles/extensions/dslsruntime/tools.vitruv.extensions.dslsruntime.mappings/src/tools/vitruv/extensions/dslsruntime/mappings/interfaces/IMappingRegistry4DependingCandidatesGenerators.xtend +++ /dev/null @@ -1,13 +0,0 @@ -package tools.vitruv.extensions.dslsruntime.mappings.interfaces - -import java.util.Set - -/** - * Interface used by candidate generators that are generated as Xtend classes for every mapping of the mappings language. - * If a mapping B depends on a mapping A, then then this interface provides all current mapping instantiations - * and mapping instantiation candidates of A to the code generated for B. - */ -interface IMappingRegistry4DependingCandidatesGenerators { - def Set getLeftCandidatesAndInstances(); - def Set getRightCandidatesAndInstances(); -} \ No newline at end of file diff --git a/bundles/extensions/dslsruntime/tools.vitruv.extensions.dslsruntime.mappings/src/tools/vitruv/extensions/dslsruntime/mappings/interfaces/IMappingRegistry4Reactions.xtend b/bundles/extensions/dslsruntime/tools.vitruv.extensions.dslsruntime.mappings/src/tools/vitruv/extensions/dslsruntime/mappings/interfaces/IMappingRegistry4Reactions.xtend deleted file mode 100644 index 65f32153c2..0000000000 --- a/bundles/extensions/dslsruntime/tools.vitruv.extensions.dslsruntime.mappings/src/tools/vitruv/extensions/dslsruntime/mappings/interfaces/IMappingRegistry4Reactions.xtend +++ /dev/null @@ -1,13 +0,0 @@ -package tools.vitruv.extensions.dslsruntime.mappings.interfaces - -/** - * Interface used in reactions that are generated for mappings that are defined using the mappings language. - * It is used to obtain runtime information about current instances of a mapping and tuples of elements - * that may become such instances and are therefore called candidates. - */ -interface IMappingRegistry4Reactions { - def Iterable getLeftCandidatesClone(); - def Iterable getRightCandidatesClone(); - def Iterable getLeftInstanceHalvesClone(); - def Iterable getRightInstanceHalvesClone(); -} \ No newline at end of file