Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEd Willink2015-05-03 13:04:10 +0000
committerEd Willink2015-05-03 18:14:59 +0000
commitc4d66f154529f70460d15e85c8a72313e8e5c54f (patch)
tree47681053f312e2829b5ca33246ac5a8dc07b29c0
parentf11addf8731420e33866675f000944386672247f (diff)
downloadorg.eclipse.qvtd-c4d66f154529f70460d15e85c8a72313e8e5c54f.tar.gz
org.eclipse.qvtd-c4d66f154529f70460d15e85c8a72313e8e5c54f.tar.xz
org.eclipse.qvtd-c4d66f154529f70460d15e85c8a72313e8e5c54f.zip
[466006] Use a derived TypedModelInstance to manage each run-time model
-rw-r--r--plugins/org.eclipse.qvtd.codegen/src/org/eclipse/qvtd/codegen/qvti/java/QVTiCG2JavaVisitor.java3
-rw-r--r--plugins/org.eclipse.qvtd.codegen/src/org/eclipse/qvtd/codegen/qvti/java/QVTiGlobalContext.java4
-rw-r--r--plugins/org.eclipse.qvtd.codegen/src/org/eclipse/qvtd/codegen/qvti/java/QVTiLocalContext.java33
-rw-r--r--plugins/org.eclipse.qvtd.pivot.qvtbase/src/org/eclipse/qvtd/pivot/qvtbase/evaluation/AbstractTransformationExecutor.java50
-rw-r--r--plugins/org.eclipse.qvtd.xtext.qvtimperative/src/org/eclipse/qvtd/xtext/qvtimperative/utilities/QVTimperativeCSResource.java8
-rw-r--r--tests/org.eclipse.qvtd.cs2as.compiler.tests/tests-gen/cg/Source2Target_qvtp_qvtias.java16
-rw-r--r--tests/org.eclipse.qvtd.cs2as.compiler.tests/tests-gen/cg/classescs2as_qvtp_qvtias.java6
-rw-r--r--tests/org.eclipse.qvtd.xtext.qvtimperative.tests/src-gen/cg/ManualUML2RDBMS.java34
-rw-r--r--tests/org.eclipse.qvtd.xtext.qvtimperative.tests/src-gen/cg/classescs2as.java12
-rw-r--r--tests/org.eclipse.qvtd.xtext.qvtimperative.tests/src-gen/cg/classescs2as_Bug459225.java2
-rw-r--r--tests/org.eclipse.qvtd.xtext.qvtimperative.tests/src-gen/cg/hsv2hls.java40
-rw-r--r--tests/org.eclipse.qvtd.xtext.qvtimperative.tests/src/org/eclipse/qvtd/xtext/qvtimperative/tests/HSV2HLS/HSV2HLS.qvti4
12 files changed, 138 insertions, 74 deletions
diff --git a/plugins/org.eclipse.qvtd.codegen/src/org/eclipse/qvtd/codegen/qvti/java/QVTiCG2JavaVisitor.java b/plugins/org.eclipse.qvtd.codegen/src/org/eclipse/qvtd/codegen/qvti/java/QVTiCG2JavaVisitor.java
index e762d4fd9..6ce5d94d4 100644
--- a/plugins/org.eclipse.qvtd.codegen/src/org/eclipse/qvtd/codegen/qvti/java/QVTiCG2JavaVisitor.java
+++ b/plugins/org.eclipse.qvtd.codegen/src/org/eclipse/qvtd/codegen/qvti/java/QVTiCG2JavaVisitor.java
@@ -131,7 +131,8 @@ public class QVTiCG2JavaVisitor extends CG2JavaVisitor<QVTiCodeGenerator> implem
}
CGTypedModel cgTypedModel = cgRealizedVariable.getTypedModel();
//
- js.append("modelObjects[");
+ js.append(QVTiGlobalContext.MODELS_NAME);
+ js.append("[");
appendModelIndex(cgTypedModel);
js.append("].add(");
js.appendValueName(cgRealizedVariable);
diff --git a/plugins/org.eclipse.qvtd.codegen/src/org/eclipse/qvtd/codegen/qvti/java/QVTiGlobalContext.java b/plugins/org.eclipse.qvtd.codegen/src/org/eclipse/qvtd/codegen/qvti/java/QVTiGlobalContext.java
index 6c03a462d..468312adf 100644
--- a/plugins/org.eclipse.qvtd.codegen/src/org/eclipse/qvtd/codegen/qvti/java/QVTiGlobalContext.java
+++ b/plugins/org.eclipse.qvtd.codegen/src/org/eclipse/qvtd/codegen/qvti/java/QVTiGlobalContext.java
@@ -25,6 +25,8 @@ import org.eclipse.ocl.pivot.Property;
*/
public class QVTiGlobalContext extends JavaGlobalContext<QVTiCodeGenerator>
{
+ public static final @NonNull String MODELS_NAME = "models";
+
/**
* Map from an oppositeProperty that requites a cache to the global name of that cache.
*/
@@ -33,7 +35,7 @@ public class QVTiGlobalContext extends JavaGlobalContext<QVTiCodeGenerator>
public QVTiGlobalContext(@NonNull QVTiCodeGenerator codeGenerator) {
super(codeGenerator);
nameManager.reserveName(JavaConstants.EVALUATOR_NAME, null);
- nameManager.reserveName("modelObjects", null);
+ nameManager.reserveName(MODELS_NAME, null);
}
public String addOppositeProperty(@NonNull Property pivotProperty) {
diff --git a/plugins/org.eclipse.qvtd.codegen/src/org/eclipse/qvtd/codegen/qvti/java/QVTiLocalContext.java b/plugins/org.eclipse.qvtd.codegen/src/org/eclipse/qvtd/codegen/qvti/java/QVTiLocalContext.java
index 3452e8f13..fb38bc81d 100644
--- a/plugins/org.eclipse.qvtd.codegen/src/org/eclipse/qvtd/codegen/qvti/java/QVTiLocalContext.java
+++ b/plugins/org.eclipse.qvtd.codegen/src/org/eclipse/qvtd/codegen/qvti/java/QVTiLocalContext.java
@@ -10,11 +10,18 @@
*******************************************************************************/
package org.eclipse.qvtd.codegen.qvti.java;
+import org.eclipse.emf.ecore.EObject;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.ocl.examples.codegen.cgmodel.CGElement;
import org.eclipse.ocl.examples.codegen.cgmodel.CGValuedElement;
+import org.eclipse.ocl.examples.codegen.cgmodel.CGVariable;
+import org.eclipse.ocl.examples.codegen.cgmodel.CGVariableExp;
import org.eclipse.ocl.examples.codegen.java.JavaLocalContext;
+import org.eclipse.ocl.pivot.Element;
+import org.eclipse.ocl.pivot.Variable;
+import org.eclipse.qvtd.pivot.qvtbase.Transformation;
+import org.eclipse.qvtd.pivot.qvtbase.TypedModel;
/**
* A QVTiLocalContext maintains the Java-specific local context for generation of QVTi code.
@@ -34,4 +41,30 @@ public class QVTiLocalContext extends JavaLocalContext<QVTiCodeGenerator>
public @NonNull QVTiGlobalContext getGlobalContext() {
return (QVTiGlobalContext) globalContext;
}
+
+ @Override
+ public @NonNull String getValueName(@NonNull CGValuedElement cgElement) {
+ String valueName = cgElement.getValueName();
+ if (valueName != null) {
+ return valueName;
+ }
+ if (cgElement instanceof CGVariableExp) {
+ CGVariable cgVariable = ((CGVariableExp)cgElement).getReferredVariable();
+ if (cgVariable != null) {
+ Element asVariable = cgVariable.getAst();
+ if (asVariable instanceof Variable) {
+ EObject asContainer = asVariable.eContainer();
+ if (asContainer instanceof TypedModel) {
+ Transformation asTransformation = ((TypedModel)asContainer).getTransformation();
+ if (asTransformation != null) {
+ int index = asTransformation.getModelParameter().indexOf(asContainer);
+ String name = QVTiGlobalContext.MODELS_NAME + "[" + index + "/*" + ((TypedModel)asContainer).getName() + "*/]";
+ return name;
+ }
+ }
+ }
+ }
+ }
+ return super.getValueName(cgElement);
+ }
}
diff --git a/plugins/org.eclipse.qvtd.pivot.qvtbase/src/org/eclipse/qvtd/pivot/qvtbase/evaluation/AbstractTransformationExecutor.java b/plugins/org.eclipse.qvtd.pivot.qvtbase/src/org/eclipse/qvtd/pivot/qvtbase/evaluation/AbstractTransformationExecutor.java
index c5dd250f1..3869061b9 100644
--- a/plugins/org.eclipse.qvtd.pivot.qvtbase/src/org/eclipse/qvtd/pivot/qvtbase/evaluation/AbstractTransformationExecutor.java
+++ b/plugins/org.eclipse.qvtd.pivot.qvtbase/src/org/eclipse/qvtd/pivot/qvtbase/evaluation/AbstractTransformationExecutor.java
@@ -39,9 +39,43 @@ public abstract class AbstractTransformationExecutor implements TransformationEx
{
private static final @SuppressWarnings("null")@NonNull List<Integer> EMPTY_INDEX_LIST = Collections.emptyList();
+ protected class Model implements TypedModelInstance
+ {
+ protected final @NonNull String name;
+ protected final @NonNull List<EObject> objects = new ArrayList<EObject>();
+
+ public Model(@NonNull String name) {
+ this.name = name;
+ }
+
+ public void add(@NonNull EObject eObject) {
+ objects.add(eObject);
+ }
+
+ @Override
+ public @NonNull Set<Object> getAllObjects() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public @NonNull Set<Object> getObjectsOfKind(@NonNull org.eclipse.ocl.pivot.Class type) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public @NonNull Set<Object> getObjectsOfType(@NonNull org.eclipse.ocl.pivot.Class type) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public @NonNull Set<Object> getRootObjects() {
+ throw new UnsupportedOperationException();
+ }
+ }
+
protected final @NonNull Evaluator evaluator;
protected final @NonNull IdResolver idResolver;
- protected final @NonNull List<EObject>[] modelObjects;
+ protected final @NonNull Model[] models;
protected final @NonNull Map<String, Integer> modelIndexes = new HashMap<String, Integer>();
/**
@@ -86,11 +120,11 @@ public abstract class AbstractTransformationExecutor implements TransformationEx
@Nullable PropertyId[] propertyIndex2propertyId, @Nullable ClassId[] classIndex2classId, @Nullable int[][] classIndex2allClassIndexes) {
this.evaluator = evaluator;
this.idResolver = evaluator.getIdResolver();
- @SuppressWarnings("unchecked")List<EObject>[] modelObjects = (List<EObject>[]) new List<?>[modelNames.length];
- this.modelObjects = modelObjects;
+ this.models = new Model[modelNames.length];
for (int i = 0; i < modelNames.length; i++) {
- modelObjects[i] = new ArrayList<EObject>();
- modelIndexes.put(modelNames[i], i);
+ @SuppressWarnings("null")@NonNull String modelName = modelNames[i];
+ models[i] = new Model(modelName);
+ modelIndexes.put(modelName, i);
}
//
// Prepare the unnavigable opposite property fields
@@ -200,7 +234,7 @@ public abstract class AbstractTransformationExecutor implements TransformationEx
if (modelIndex == null) {
throw new IllegalStateException("Unknown model name '" + modelName + "'");
}
- List<EObject> eObjects = modelObjects[modelIndex];
+ List<EObject> eObjects = models[modelIndex].objects;
Map<EClass, Set<Integer>> eClass2allClassIndexes = null;
Map<EClass, List<Integer>> eClass2allPropertyIndexes = null;
Map<EReference, Integer> eReference2propertyIndex = null;
@@ -277,7 +311,7 @@ public abstract class AbstractTransformationExecutor implements TransformationEx
*/
protected @NonNull <T extends EObject> List<T> getObjectsByType(@NonNull Class<T> javaClass, int modelIndex, @NonNull EClass eClass) {
- List<EObject> eRootObjects = modelObjects[modelIndex];
+ List<EObject> eRootObjects = models[modelIndex].objects;
List<T> eObjects = new ArrayList<T>();
for (EObject eRootObject : eRootObjects) {
if (eClass.isInstance(eRootObject)) {
@@ -344,7 +378,7 @@ public abstract class AbstractTransformationExecutor implements TransformationEx
if (modelIndex == null) {
throw new IllegalStateException("Unknown model name '" + modelName + "'");
}
- List<EObject> eObjects = modelObjects[modelIndex];
+ List<EObject> eObjects = models[modelIndex].objects;
List<EObject> eRootObjects = new ArrayList<EObject>(eObjects.size());
for (EObject eObject : eObjects) {
if (eObject.eContainer() == null) {
diff --git a/plugins/org.eclipse.qvtd.xtext.qvtimperative/src/org/eclipse/qvtd/xtext/qvtimperative/utilities/QVTimperativeCSResource.java b/plugins/org.eclipse.qvtd.xtext.qvtimperative/src/org/eclipse/qvtd/xtext/qvtimperative/utilities/QVTimperativeCSResource.java
index 8dfbc9f8a..f482b0733 100644
--- a/plugins/org.eclipse.qvtd.xtext.qvtimperative/src/org/eclipse/qvtd/xtext/qvtimperative/utilities/QVTimperativeCSResource.java
+++ b/plugins/org.eclipse.qvtd.xtext.qvtimperative/src/org/eclipse/qvtd/xtext/qvtimperative/utilities/QVTimperativeCSResource.java
@@ -26,6 +26,8 @@ import org.eclipse.ocl.xtext.base.cs2as.CS2AS;
import org.eclipse.ocl.xtext.base.utilities.BaseCSResource;
import org.eclipse.ocl.xtext.essentialocl.utilities.EssentialOCLCSResource;
import org.eclipse.qvtd.pivot.qvtbase.FunctionParameter;
+import org.eclipse.qvtd.pivot.qvtbase.Transformation;
+import org.eclipse.qvtd.pivot.qvtbase.TypedModel;
import org.eclipse.qvtd.pivot.qvtcorebase.CorePattern;
import org.eclipse.qvtd.pivot.qvtcorebase.RealizedVariable;
import org.eclipse.qvtd.pivot.qvtimperative.MappingLoop;
@@ -82,6 +84,12 @@ public class QVTimperativeCSResource extends EssentialOCLCSResource
else if ((element instanceof Variable) && (element.eContainer() instanceof MappingLoop)) {
return (Variable)element;
}
+ else if ((element instanceof Variable) && (element.eContainer() instanceof Transformation)) {
+ return (Variable)element;
+ }
+ else if ((element instanceof Variable) && (element.eContainer() instanceof TypedModel)) {
+ return (Variable)element;
+ }
else {
return super.isPathable(element);
}
diff --git a/tests/org.eclipse.qvtd.cs2as.compiler.tests/tests-gen/cg/Source2Target_qvtp_qvtias.java b/tests/org.eclipse.qvtd.cs2as.compiler.tests/tests-gen/cg/Source2Target_qvtp_qvtias.java
index 1ac4fa59c..b8cd5356a 100644
--- a/tests/org.eclipse.qvtd.cs2as.compiler.tests/tests-gen/cg/Source2Target_qvtp_qvtias.java
+++ b/tests/org.eclipse.qvtd.cs2as.compiler.tests/tests-gen/cg/Source2Target_qvtp_qvtias.java
@@ -236,7 +236,7 @@ public class Source2Target_qvtp_qvtias extends CS2ASTransformationExecutor
// creations
final /*@Thrown*/ TRoot tRoot = TargetFactory.eINSTANCE.createTRoot();
assert tRoot != null;
- modelObjects[1/*rightAS*/].add(tRoot);
+ models[1/*rightAS*/].add(tRoot);
// assignments
sRoot.setAst(tRoot);
// mapping statements
@@ -281,7 +281,7 @@ public class Source2Target_qvtp_qvtias extends CS2ASTransformationExecutor
// creations
final /*@Thrown*/ A3 a3 = TargetFactory.eINSTANCE.createA3();
assert a3 != null;
- modelObjects[1/*rightAS*/].add(a3);
+ models[1/*rightAS*/].add(a3);
// assignments
x.setAst(a3);
// mapping statements
@@ -325,7 +325,7 @@ public class Source2Target_qvtp_qvtias extends CS2ASTransformationExecutor
// creations
final /*@Thrown*/ A2 a2 = TargetFactory.eINSTANCE.createA2();
assert a2 != null;
- modelObjects[1/*rightAS*/].add(a2);
+ models[1/*rightAS*/].add(a2);
// assignments
x_0.setAst(a2);
// mapping statements
@@ -363,7 +363,7 @@ public class Source2Target_qvtp_qvtias extends CS2ASTransformationExecutor
// creations
final /*@Thrown*/ A1 a1 = TargetFactory.eINSTANCE.createA1();
assert a1 != null;
- modelObjects[1/*rightAS*/].add(a1);
+ models[1/*rightAS*/].add(a1);
// assignments
x_1.setAst(a1);
// mapping statements
@@ -396,7 +396,7 @@ public class Source2Target_qvtp_qvtias extends CS2ASTransformationExecutor
// creations
final /*@Thrown*/ B b = TargetFactory.eINSTANCE.createB();
assert b != null;
- modelObjects[1/*rightAS*/].add(b);
+ models[1/*rightAS*/].add(b);
// assignments
y1.setAst(b);
// mapping statements
@@ -429,7 +429,7 @@ public class Source2Target_qvtp_qvtias extends CS2ASTransformationExecutor
// creations
final /*@Thrown*/ C c = TargetFactory.eINSTANCE.createC();
assert c != null;
- modelObjects[1/*rightAS*/].add(c);
+ models[1/*rightAS*/].add(c);
// assignments
y2.setAst(c);
// mapping statements
@@ -471,7 +471,7 @@ public class Source2Target_qvtp_qvtias extends CS2ASTransformationExecutor
// creations
final /*@Thrown*/ D d = TargetFactory.eINSTANCE.createD();
assert d != null;
- modelObjects[1/*rightAS*/].add(d);
+ models[1/*rightAS*/].add(d);
// assignments
z.setAst(d);
// mapping statements
@@ -512,7 +512,7 @@ public class Source2Target_qvtp_qvtias extends CS2ASTransformationExecutor
// creations
final /*@Thrown*/ D d = TargetFactory.eINSTANCE.createD();
assert d != null;
- modelObjects[1/*rightAS*/].add(d);
+ models[1/*rightAS*/].add(d);
// assignments
z_0.setAst(d);
// mapping statements
diff --git a/tests/org.eclipse.qvtd.cs2as.compiler.tests/tests-gen/cg/classescs2as_qvtp_qvtias.java b/tests/org.eclipse.qvtd.cs2as.compiler.tests/tests-gen/cg/classescs2as_qvtp_qvtias.java
index 9b3a6e9df..2263955b6 100644
--- a/tests/org.eclipse.qvtd.cs2as.compiler.tests/tests-gen/cg/classescs2as_qvtp_qvtias.java
+++ b/tests/org.eclipse.qvtd.cs2as.compiler.tests/tests-gen/cg/classescs2as_qvtp_qvtias.java
@@ -199,7 +199,7 @@ public class classescs2as_qvtp_qvtias extends CS2ASTransformationExecutor
// creations
final /*@Thrown*/ example2.classes.Class symbol_0 = ClassesFactory.eINSTANCE.createClass();
assert symbol_0 != null;
- modelObjects[1/*rightAS*/].add(symbol_0);
+ models[1/*rightAS*/].add(symbol_0);
// assignments
classCS.setAst(symbol_0);
// mapping statements
@@ -232,7 +232,7 @@ public class classescs2as_qvtp_qvtias extends CS2ASTransformationExecutor
// creations
final /*@Thrown*/ Package symbol_0 = ClassesFactory.eINSTANCE.createPackage();
assert symbol_0 != null;
- modelObjects[1/*rightAS*/].add(symbol_0);
+ models[1/*rightAS*/].add(symbol_0);
// assignments
packageCS.setAst(symbol_0);
// mapping statements
@@ -265,7 +265,7 @@ public class classescs2as_qvtp_qvtias extends CS2ASTransformationExecutor
// creations
final /*@Thrown*/ Root root = ClassesFactory.eINSTANCE.createRoot();
assert root != null;
- modelObjects[1/*rightAS*/].add(root);
+ models[1/*rightAS*/].add(root);
// assignments
rootCS.setAst(root);
// mapping statements
diff --git a/tests/org.eclipse.qvtd.xtext.qvtimperative.tests/src-gen/cg/ManualUML2RDBMS.java b/tests/org.eclipse.qvtd.xtext.qvtimperative.tests/src-gen/cg/ManualUML2RDBMS.java
index 49db54a47..22a3d9adb 100644
--- a/tests/org.eclipse.qvtd.xtext.qvtimperative.tests/src-gen/cg/ManualUML2RDBMS.java
+++ b/tests/org.eclipse.qvtd.xtext.qvtimperative.tests/src-gen/cg/ManualUML2RDBMS.java
@@ -275,7 +275,7 @@ public class ManualUML2RDBMS extends AbstractTransformationExecutor
// creations
final /*@Thrown*/ PackageToSchema p2s_11 = UML2RDBMSFactory.eINSTANCE.createPackageToSchema();
assert p2s_11 != null;
- modelObjects[2/*middle*/].add(p2s_11);
+ models[2/*middle*/].add(p2s_11);
// assignments
p2s_11.setUmlPackage(p);
final @Nullable /*@Thrown*/ String name = p.getName();
@@ -363,7 +363,7 @@ public class ManualUML2RDBMS extends AbstractTransformationExecutor
// creations
final /*@Thrown*/ Schema s_2 = RDBMSFactory.eINSTANCE.createSchema();
assert s_2 != null;
- modelObjects[1/*rdbms*/].add(s_2);
+ models[1/*rdbms*/].add(s_2);
// assignments
p2s.setSchema(s_2);
// mapping statements
@@ -468,7 +468,7 @@ public class ManualUML2RDBMS extends AbstractTransformationExecutor
// creations
final /*@Thrown*/ PrimitiveToName p2n_3 = UML2RDBMSFactory.eINSTANCE.createPrimitiveToName();
assert p2n_3 != null;
- modelObjects[2/*middle*/].add(p2n_3);
+ models[2/*middle*/].add(p2n_3);
// assignments
p2n_3.setOwner(p2s_0);
p2n_3.setPrimitive(prim);
@@ -567,7 +567,7 @@ public class ManualUML2RDBMS extends AbstractTransformationExecutor
// creations
final /*@Thrown*/ PrimitiveToName p2n_3 = UML2RDBMSFactory.eINSTANCE.createPrimitiveToName();
assert p2n_3 != null;
- modelObjects[2/*middle*/].add(p2n_3);
+ models[2/*middle*/].add(p2n_3);
// assignments
p2n_3.setOwner(p2s_3);
p2n_3.setPrimitive(prim_0);
@@ -666,7 +666,7 @@ public class ManualUML2RDBMS extends AbstractTransformationExecutor
// creations
final /*@Thrown*/ PrimitiveToName p2n_3 = UML2RDBMSFactory.eINSTANCE.createPrimitiveToName();
assert p2n_3 != null;
- modelObjects[2/*middle*/].add(p2n_3);
+ models[2/*middle*/].add(p2n_3);
// assignments
p2n_3.setOwner(p2s_5);
p2n_3.setPrimitive(prim_1);
@@ -784,7 +784,7 @@ public class ManualUML2RDBMS extends AbstractTransformationExecutor
// creations
final /*@Thrown*/ ClassToTable c2t_3 = UML2RDBMSFactory.eINSTANCE.createClassToTable();
assert c2t_3 != null;
- modelObjects[2/*middle*/].add(c2t_3);
+ models[2/*middle*/].add(c2t_3);
// assignments
c2t_3.setOwner(p2s_7);
c2t_3.setUmlClass(c);
@@ -882,7 +882,7 @@ public class ManualUML2RDBMS extends AbstractTransformationExecutor
// creations
final /*@Thrown*/ Table t_0 = RDBMSFactory.eINSTANCE.createTable();
assert t_0 != null;
- modelObjects[1/*rdbms*/].add(t_0);
+ models[1/*rdbms*/].add(t_0);
// assignments
t_0.setKind(STR_base);
t_0.setSchema(s);
@@ -1024,10 +1024,10 @@ public class ManualUML2RDBMS extends AbstractTransformationExecutor
// creations
final /*@Thrown*/ Column pc = RDBMSFactory.eINSTANCE.createColumn();
assert pc != null;
- modelObjects[1/*rdbms*/].add(pc);
+ models[1/*rdbms*/].add(pc);
final /*@Thrown*/ Key pk = RDBMSFactory.eINSTANCE.createKey();
assert pk != null;
- modelObjects[1/*rdbms*/].add(pk);
+ models[1/*rdbms*/].add(pk);
// assignments
pk.setOwner(t_2);
pk.setKind(STR_primary);
@@ -1198,7 +1198,7 @@ public class ManualUML2RDBMS extends AbstractTransformationExecutor
// creations
final /*@Thrown*/ AssociationToForeignKey a2f_0 = UML2RDBMSFactory.eINSTANCE.createAssociationToForeignKey();
assert a2f_0 != null;
- modelObjects[2/*middle*/].add(a2f_0);
+ models[2/*middle*/].add(a2f_0);
// assignments
sc2t_0.setOwner(p2s_9);
a2f_0.setOwner(sc2t_0);
@@ -1380,10 +1380,10 @@ public class ManualUML2RDBMS extends AbstractTransformationExecutor
// creations
final /*@Thrown*/ Column fc_0 = RDBMSFactory.eINSTANCE.createColumn();
assert fc_0 != null;
- modelObjects[1/*rdbms*/].add(fc_0);
+ models[1/*rdbms*/].add(fc_0);
final /*@Thrown*/ ForeignKey fk_0 = RDBMSFactory.eINSTANCE.createForeignKey();
assert fk_0 != null;
- modelObjects[1/*rdbms*/].add(fk_0);
+ models[1/*rdbms*/].add(fk_0);
// assignments
sc2t.setOwner(p2s_10);
fk_0.setName(name);
@@ -1546,7 +1546,7 @@ public class ManualUML2RDBMS extends AbstractTransformationExecutor
// creations
final /*@Thrown*/ AttributeToColumn atc = UML2RDBMSFactory.eINSTANCE.createAttributeToColumn();
assert atc != null;
- modelObjects[2/*middle*/].add(atc);
+ models[2/*middle*/].add(atc);
// assignments
atc.setAttribute(a_0);
OPPOSITE_OF_FromAttribute_attribute.put(a_0, atc);
@@ -1614,7 +1614,7 @@ public class ManualUML2RDBMS extends AbstractTransformationExecutor
// creations
final /*@Thrown*/ NonLeafAttribute fa = UML2RDBMSFactory.eINSTANCE.createNonLeafAttribute();
assert fa != null;
- modelObjects[2/*middle*/].add(fa);
+ models[2/*middle*/].add(fa);
// assignments
fa.setAttribute(a_1);
OPPOSITE_OF_FromAttribute_attribute.put(a_1, fa);
@@ -1765,7 +1765,7 @@ public class ManualUML2RDBMS extends AbstractTransformationExecutor
// creations
final /*@Thrown*/ AttributeToColumn fa = UML2RDBMSFactory.eINSTANCE.createAttributeToColumn();
assert fa != null;
- modelObjects[2/*middle*/].add(fa);
+ models[2/*middle*/].add(fa);
// assignments
fa.setOwner(fao_1);
final @NonNull /*@Thrown*/ SetValue Set = ValueUtil.createSetOfEach(SET_CLSSid_AttributeToColumn, fa);
@@ -1891,7 +1891,7 @@ public class ManualUML2RDBMS extends AbstractTransformationExecutor
// creations
final /*@Thrown*/ NonLeafAttribute fa = UML2RDBMSFactory.eINSTANCE.createNonLeafAttribute();
assert fa != null;
- modelObjects[2/*middle*/].add(fa);
+ models[2/*middle*/].add(fa);
// assignments
fa.setOwner(fao_1_0);
final @Nullable /*@Thrown*/ List<FromAttribute> fromAttributes = fao_1_0.getFromAttributes();
@@ -1993,7 +1993,7 @@ public class ManualUML2RDBMS extends AbstractTransformationExecutor
// creations
final /*@Thrown*/ Column c_4 = RDBMSFactory.eINSTANCE.createColumn();
assert c_4 != null;
- modelObjects[1/*rdbms*/].add(c_4);
+ models[1/*rdbms*/].add(c_4);
// assignments
c_4.setOwner(t);
// mapping statements
diff --git a/tests/org.eclipse.qvtd.xtext.qvtimperative.tests/src-gen/cg/classescs2as.java b/tests/org.eclipse.qvtd.xtext.qvtimperative.tests/src-gen/cg/classescs2as.java
index b921fdebe..ff56d78e7 100644
--- a/tests/org.eclipse.qvtd.xtext.qvtimperative.tests/src-gen/cg/classescs2as.java
+++ b/tests/org.eclipse.qvtd.xtext.qvtimperative.tests/src-gen/cg/classescs2as.java
@@ -166,7 +166,7 @@ public class classescs2as extends AbstractTransformationExecutor
// creations
final /*@Thrown*/ ClassCS2Class c2c_0 = ClassescstracesFactory.eINSTANCE.createClassCS2Class();
assert c2c_0 != null;
- modelObjects[2/*middle*/].add(c2c_0);
+ models[2/*middle*/].add(c2c_0);
// assignments
c2c_0.setClassCS(classCS);
OPPOSITE_OF_ClassCS2Class_classCS.put(classCS, c2c_0);
@@ -200,7 +200,7 @@ public class classescs2as extends AbstractTransformationExecutor
// creations
final /*@Thrown*/ RootCS2Root r2r_0 = ClassescstracesFactory.eINSTANCE.createRootCS2Root();
assert r2r_0 != null;
- modelObjects[2/*middle*/].add(r2r_0);
+ models[2/*middle*/].add(r2r_0);
// assignments
r2r_0.setRootCS(rootCS);
OPPOSITE_OF_RootCS2Root_rootCS.put(rootCS, r2r_0);
@@ -234,7 +234,7 @@ public class classescs2as extends AbstractTransformationExecutor
// creations
final /*@Thrown*/ PackageCS2Package p2p_0 = ClassescstracesFactory.eINSTANCE.createPackageCS2Package();
assert p2p_0 != null;
- modelObjects[2/*middle*/].add(p2p_0);
+ models[2/*middle*/].add(p2p_0);
// assignments
p2p_0.setPackageCS(packageCS);
OPPOSITE_OF_PackageCS2Package_packageCS.put(packageCS, p2p_0);
@@ -268,7 +268,7 @@ public class classescs2as extends AbstractTransformationExecutor
// creations
final /*@Thrown*/ classes.Class symbol_3 = ClassesFactory.eINSTANCE.createClass();
assert symbol_3 != null;
- modelObjects[1/*rightAS*/].add(symbol_3);
+ models[1/*rightAS*/].add(symbol_3);
// assignments
c2c.setClass(symbol_3);
// mapping statements
@@ -301,7 +301,7 @@ public class classescs2as extends AbstractTransformationExecutor
// creations
final /*@Thrown*/ Root root_0 = ClassesFactory.eINSTANCE.createRoot();
assert root_0 != null;
- modelObjects[1/*rightAS*/].add(root_0);
+ models[1/*rightAS*/].add(root_0);
// assignments
r2r.setRoot(root_0);
// mapping statements
@@ -334,7 +334,7 @@ public class classescs2as extends AbstractTransformationExecutor
// creations
final /*@Thrown*/ Package symbol_3 = ClassesFactory.eINSTANCE.createPackage();
assert symbol_3 != null;
- modelObjects[1/*rightAS*/].add(symbol_3);
+ models[1/*rightAS*/].add(symbol_3);
// assignments
p2p.setPackage(symbol_3);
// mapping statements
diff --git a/tests/org.eclipse.qvtd.xtext.qvtimperative.tests/src-gen/cg/classescs2as_Bug459225.java b/tests/org.eclipse.qvtd.xtext.qvtimperative.tests/src-gen/cg/classescs2as_Bug459225.java
index a6b0f9792..f06541c54 100644
--- a/tests/org.eclipse.qvtd.xtext.qvtimperative.tests/src-gen/cg/classescs2as_Bug459225.java
+++ b/tests/org.eclipse.qvtd.xtext.qvtimperative.tests/src-gen/cg/classescs2as_Bug459225.java
@@ -193,7 +193,7 @@ public class classescs2as_Bug459225 extends AbstractTransformationExecutor
// creations
final /*@Thrown*/ Package symbol_0 = ClassesFactory.eINSTANCE.createPackage();
assert symbol_0 != null;
- modelObjects[1/*rightAS*/].add(symbol_0);
+ models[1/*rightAS*/].add(symbol_0);
// assignments
@Nullable /*@Caught*/ Object CAUGHT_name;
try {
diff --git a/tests/org.eclipse.qvtd.xtext.qvtimperative.tests/src-gen/cg/hsv2hls.java b/tests/org.eclipse.qvtd.xtext.qvtimperative.tests/src-gen/cg/hsv2hls.java
index 414d8189e..0f9d9d4e2 100644
--- a/tests/org.eclipse.qvtd.xtext.qvtimperative.tests/src-gen/cg/hsv2hls.java
+++ b/tests/org.eclipse.qvtd.xtext.qvtimperative.tests/src-gen/cg/hsv2hls.java
@@ -22,10 +22,10 @@ import org.eclipse.ocl.pivot.ids.IdResolver;
import org.eclipse.ocl.pivot.ids.NsURIPackageId;
import org.eclipse.ocl.pivot.ids.RootPackageId;
import org.eclipse.ocl.pivot.ids.TypeId;
-import org.eclipse.ocl.pivot.library.classifier.ClassifierAllInstancesOperation;
import org.eclipse.ocl.pivot.values.InvalidValueException;
import org.eclipse.ocl.pivot.values.SetValue;
import org.eclipse.qvtd.pivot.qvtbase.evaluation.AbstractTransformationExecutor;
+import org.eclipse.qvtd.pivot.qvtbase.library.model.ModelObjectsOfKindOperation;
import test.hls.HLSTree.HLSNode;
import test.hls.HLSTree.HLSTreeFactory;
import test.hls.HLSTree.HLSTreePackage;
@@ -50,6 +50,7 @@ import test.middle.HSV2HLS.HSVNode2HLSNode;
public class hsv2hls extends AbstractTransformationExecutor
{
public static final @NonNull /*@NonInvalid*/ RootPackageId PACKid_$metamodel$ = IdManager.getRootPackageId("$metamodel$");
+ public static final @NonNull /*@NonInvalid*/ NsURIPackageId PACKid_http_c_s_s_www_eclipse_org_s_qvt_s_2015_s_QVTbaseLibrary = IdManager.getNsURIPackageId("http://www.eclipse.org/qvt/2015/QVTbaseLibrary", "qvtbaselib", null);
public static final @NonNull /*@NonInvalid*/ NsURIPackageId PACKid_http_c_s_s_www_eclipse_org_s_qvt_s_examples_s_0_1_s_HLSTree = IdManager.getNsURIPackageId("http://www.eclipse.org/qvt/examples/0.1/HLSTree", null, HLSTreePackage.eINSTANCE);
public static final @NonNull /*@NonInvalid*/ NsURIPackageId PACKid_http_c_s_s_www_eclipse_org_s_qvt_s_examples_s_0_1_s_HSVTree = IdManager.getNsURIPackageId("http://www.eclipse.org/qvt/examples/0.1/HSVTree", null, HSVTreePackage.eINSTANCE);
public static final @NonNull /*@NonInvalid*/ NsURIPackageId PACKid_http_c_s_s_www_eclipse_org_s_qvt_s_examples_s_0_1_s_HSVtoHLS = IdManager.getNsURIPackageId("http://www.eclipse.org/qvt/examples/0.1/HSVtoHLS", null, HSV2HLSPackage.eINSTANCE);
@@ -57,6 +58,7 @@ public class hsv2hls extends AbstractTransformationExecutor
public static final @NonNull /*@NonInvalid*/ ClassId CLSSid_HLSNode = PACKid_http_c_s_s_www_eclipse_org_s_qvt_s_examples_s_0_1_s_HLSTree.getClassId("HLSNode", 0);
public static final @NonNull /*@NonInvalid*/ ClassId CLSSid_HSVNode = PACKid_http_c_s_s_www_eclipse_org_s_qvt_s_examples_s_0_1_s_HSVTree.getClassId("HSVNode", 0);
public static final @NonNull /*@NonInvalid*/ ClassId CLSSid_HSVNode2HLSNode = PACKid_http_c_s_s_www_eclipse_org_s_qvt_s_examples_s_0_1_s_HSVtoHLS.getClassId("HSVNode2HLSNode", 0);
+ public static final @NonNull /*@NonInvalid*/ ClassId CLSSid_Model = PACKid_http_c_s_s_www_eclipse_org_s_qvt_s_2015_s_QVTbaseLibrary.getClassId("Model", 0);
public static final @NonNull /*@NonInvalid*/ DataTypeId DATAid_HLS = PACKid_http_c_s_s_www_eclipse_org_s_qvt_s_examples_s_0_1_s_HLSTree.getDataTypeId("HLS", 0);
public static final @NonNull /*@NonInvalid*/ DataTypeId DATAid_HSV = PACKid_http_c_s_s_www_eclipse_org_s_qvt_s_examples_s_0_1_s_HSVTree.getDataTypeId("HSV", 0);
public static final @NonNull /*@NonInvalid*/ DataTypeId DATAid_RGB = PACKid_http_c_s_s_www_eclipse_org_s_qvt_s_examples_s_0_1_s_HSVtoHLS.getDataTypeId("RGB", 0);
@@ -64,25 +66,9 @@ public class hsv2hls extends AbstractTransformationExecutor
public static final @NonNull /*@NonInvalid*/ CollectionTypeId ORD_CLSSid_HSVNode2HLSNode = TypeId.ORDERED_SET.getSpecializedId(CLSSid_HSVNode2HLSNode);
public static final @NonNull /*@NonInvalid*/ CollectionTypeId SET_CLSSid_HSVNode = TypeId.SET.getSpecializedId(CLSSid_HSVNode);
- /*
- * Array of the ClassIds of each class for which allInstances() may be invoked. Array index is the ClassIndex.
- */
- private static final @NonNull ClassId[] classIndex2classId = new ClassId[]{
- CLSSid_HSVNode // 0 => HSVNode
- };
-
- /*
- * Mapping from each ClassIndex to all the ClassIndexes to which an object of the outer index
- * may contribute results to an allInstances() invocation.
- * Non trivial inner arrays arise when one ClassId is a derivation of another and so an
- * instance of the derived classId contributes to derived and inherited ClassIndexes.
- */
- private final static @NonNull int[][] classIndex2allClassIndexes = new int[][] {
- {0} // 0 : HSVNode -> {HSVNode}
- };
public hsv2hls(final @NonNull Evaluator evaluator) {
- super(evaluator, new String[] {"hsv", "hls", "middle"}, null, classIndex2classId, classIndex2allClassIndexes);
+ super(evaluator, new String[] {"hsv", "hls", "middle"}, null, null, null);
}
public boolean run() {
@@ -113,7 +99,7 @@ public class hsv2hls extends AbstractTransformationExecutor
* )
* { |
* }
- * for hsvRoot : HSVTree::HSVNode in HSVTree::HSVNode.allInstances()
+ * for hsvRoot : HSVTree::HSVNode in hsv.objectsOfKind(HSVTree::HSVNode)
* {
* map HSV2MiddleRoot {
* hsvRoot := hsvRoot;
@@ -127,11 +113,11 @@ public class hsv2hls extends AbstractTransformationExecutor
// creations
// assignments
// mapping statements
- final @NonNull /*@Thrown*/ SetValue allInstances = ClassifierAllInstancesOperation.INSTANCE.evaluate(evaluator, SET_CLSSid_HSVNode, TYP_HSVTree_c_c_HSVNode_0);
- final List<HSVNode> UNBOXED_allInstances = allInstances.asEcoreObjects(idResolver, HSVNode.class);
- assert UNBOXED_allInstances != null;
+ final @NonNull /*@Thrown*/ SetValue objectsOfKind = ModelObjectsOfKindOperation.INSTANCE.evaluate(evaluator, SET_CLSSid_HSVNode, models[0/*hsv*/], TYP_HSVTree_c_c_HSVNode_0);
+ final List<HSVNode> UNBOXED_objectsOfKind = objectsOfKind.asEcoreObjects(idResolver, HSVNode.class);
+ assert UNBOXED_objectsOfKind != null;
;
- for (HSVNode hsvRoot_1 : UNBOXED_allInstances) {
+ for (HSVNode hsvRoot_1 : UNBOXED_objectsOfKind) {
if (hsvRoot_1 != null) {
final @NonNull /*@NonInvalid*/ HSVNode symbol_1 = (HSVNode)hsvRoot_1;
HSV2MiddleRoot(symbol_1);
@@ -181,7 +167,7 @@ public class hsv2hls extends AbstractTransformationExecutor
// creations
final /*@Thrown*/ HSVNode2HLSNode middleRoot = HSV2HLSFactory.eINSTANCE.createHSVNode2HLSNode();
assert middleRoot != null;
- modelObjects[2/*middle*/].add(middleRoot);
+ models[2/*middle*/].add(middleRoot);
// assignments
middleRoot.setHsv(hsvRoot);
final @Nullable /*@Thrown*/ String name = hsvRoot.getName();
@@ -235,7 +221,7 @@ public class hsv2hls extends AbstractTransformationExecutor
// creations
final /*@Thrown*/ HSVNode2HLSNode middleNode_1 = HSV2HLSFactory.eINSTANCE.createHSVNode2HLSNode();
assert middleNode_1 != null;
- modelObjects[2/*middle*/].add(middleNode_1);
+ models[2/*middle*/].add(middleNode_1);
// assignments
middleNode_1.setParent(middleParent);
middleNode_1.setHsv(hsvNode);
@@ -287,7 +273,7 @@ public class hsv2hls extends AbstractTransformationExecutor
// creations
final /*@Thrown*/ HLSNode hlsNode = HLSTreeFactory.eINSTANCE.createHLSNode();
assert hlsNode != null;
- modelObjects[1/*hls*/].add(hlsNode);
+ models[1/*hls*/].add(hlsNode);
// assignments
hlsNode.setParent(null);
middleNode.setHls(hlsNode);
@@ -339,7 +325,7 @@ public class hsv2hls extends AbstractTransformationExecutor
// creations
final /*@Thrown*/ HLSNode hlsNode = HLSTreeFactory.eINSTANCE.createHLSNode();
assert hlsNode != null;
- modelObjects[1/*hls*/].add(hlsNode);
+ models[1/*hls*/].add(hlsNode);
// assignments
final @Nullable /*@Thrown*/ HSVNode2HLSNode parent = middleNode_0.getParent();
if (parent == null) {
diff --git a/tests/org.eclipse.qvtd.xtext.qvtimperative.tests/src/org/eclipse/qvtd/xtext/qvtimperative/tests/HSV2HLS/HSV2HLS.qvti b/tests/org.eclipse.qvtd.xtext.qvtimperative.tests/src/org/eclipse/qvtd/xtext/qvtimperative/tests/HSV2HLS/HSV2HLS.qvti
index 22de9f844..d693430c5 100644
--- a/tests/org.eclipse.qvtd.xtext.qvtimperative.tests/src/org/eclipse/qvtd/xtext/qvtimperative/tests/HSV2HLS/HSV2HLS.qvti
+++ b/tests/org.eclipse.qvtd.xtext.qvtimperative.tests/src/org/eclipse/qvtd/xtext/qvtimperative/tests/HSV2HLS/HSV2HLS.qvti
@@ -19,8 +19,8 @@ query hsv2hls::rgb2hls(color : HSV2HLS::RGB) : HLSTree::HLS;
query hsv2hls::rgb2hsv(color : HSV2HLS::RGB) : HSVTree::HSV;
map __root__ in hsv2hls {
- for hsvRoot : HSVTree::HSVNode in HSVTree::HSVNode.allInstances() {
--- for hsvRoot : HSVTree::HSVNode in hsv.objectsOfKind(HSVTree::HSVNode) {
+-- for hsvRoot : HSVTree::HSVNode in HSVTree::HSVNode.allInstances() {
+ for hsvRoot : HSVTree::HSVNode in hsv.objectsOfKind(HSVTree::HSVNode) {
call HSV2MiddleRoot {
hsvRoot := hsvRoot;
}

Back to the top