Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEd Willink2015-06-07 09:30:27 +0000
committerEd Willink2015-06-07 09:41:13 +0000
commit9575705d77acc12b0e74ee8c5050c026a2e3cbec (patch)
treeda423071ebb6bea6039d68e1f0122858fa77e466
parentcf1278c2fbe6a23fd8364c3cdcc4b9910614d18f (diff)
downloadorg.eclipse.qvtd-9575705d77acc12b0e74ee8c5050c026a2e3cbec.tar.gz
org.eclipse.qvtd-9575705d77acc12b0e74ee8c5050c026a2e3cbec.tar.xz
org.eclipse.qvtd-9575705d77acc12b0e74ee8c5050c026a2e3cbec.zip
[469560] Define helper instances for evaluation
-rw-r--r--plugins/org.eclipse.qvtd.debug/src/org/eclipse/qvtd/debug/evaluator/QVTiVMEvaluator.java12
-rw-r--r--plugins/org.eclipse.qvtd.pivot.qvtbase/plugin.xml7
-rw-r--r--plugins/org.eclipse.qvtd.pivot.qvtbase/src/org/eclipse/qvtd/pivot/qvtbase/evaluation/AbstractTransformationExecutor.java5
-rw-r--r--plugins/org.eclipse.qvtd.pivot.qvtbase/src/org/eclipse/qvtd/pivot/qvtbase/evaluation/TransformationInstance.java3
-rw-r--r--plugins/org.eclipse.qvtd.pivot.qvtbase/src/org/eclipse/qvtd/pivot/qvtbase/evaluation/TypedModelInstance.java2
-rw-r--r--plugins/org.eclipse.qvtd.pivot.qvtbase/src/org/eclipse/qvtd/pivot/qvtbase/utilities/TransformationInstanceLabelGenerator.java31
-rw-r--r--plugins/org.eclipse.qvtd.pivot.qvtbase/src/org/eclipse/qvtd/pivot/qvtbase/utilities/TypedModelInstanceLabelGenerator.java31
-rw-r--r--plugins/org.eclipse.qvtd.pivot.qvtimperative/src/org/eclipse/qvtd/pivot/qvtimperative/evaluation/QVTiModelManager.java12
8 files changed, 102 insertions, 1 deletions
diff --git a/plugins/org.eclipse.qvtd.debug/src/org/eclipse/qvtd/debug/evaluator/QVTiVMEvaluator.java b/plugins/org.eclipse.qvtd.debug/src/org/eclipse/qvtd/debug/evaluator/QVTiVMEvaluator.java
index 8145776c0..4e4394ac0 100644
--- a/plugins/org.eclipse.qvtd.debug/src/org/eclipse/qvtd/debug/evaluator/QVTiVMEvaluator.java
+++ b/plugins/org.eclipse.qvtd.debug/src/org/eclipse/qvtd/debug/evaluator/QVTiVMEvaluator.java
@@ -17,10 +17,13 @@ import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.ocl.examples.debug.vm.evaluator.IVMEvaluator;
+import org.eclipse.ocl.pivot.Variable;
+import org.eclipse.ocl.pivot.internal.complete.StandardLibraryInternal;
import org.eclipse.ocl.pivot.utilities.MetamodelManager;
import org.eclipse.ocl.pivot.utilities.NameUtil;
import org.eclipse.qvtd.pivot.qvtbase.Transformation;
import org.eclipse.qvtd.pivot.qvtbase.TypedModel;
+import org.eclipse.qvtd.pivot.qvtbase.utilities.QVTbaseUtil;
import org.eclipse.qvtd.pivot.qvtimperative.ImperativeModel;
import org.eclipse.qvtd.pivot.qvtimperative.evaluation.QVTiTransformationAnalysis;
import org.eclipse.qvtd.xtext.qvtimperative.utilities.QVTiXtextEvaluator;
@@ -96,6 +99,15 @@ public class QVTiVMEvaluator implements IVMEvaluator
Transformation transformation = getTransformation();
IQVTiVMEvaluationEnvironment evalEnv = vmEnvironmentFactory.createVMEvaluationEnvironment(transformation, vmModelManager);
QVTiVMRootEvaluationVisitor visitor = vmEnvironmentFactory.createVMEvaluationVisitor(evalEnv);
+ StandardLibraryInternal standardLibrary = vmEnvironmentFactory.getEnvironmentFactory().getStandardLibrary();
+ Variable ownedContext = QVTbaseUtil.getContextVariable(standardLibrary, transformation);
+ evalEnv.add(ownedContext, vmModelManager.getTransformationInstance(transformation));
+ for (TypedModel typedModel : transformation.getModelParameter()) {
+ if (typedModel != null) {
+ ownedContext = QVTbaseUtil.getContextVariable(standardLibrary, typedModel);
+ evalEnv.add(ownedContext, vmModelManager.getTypedModelInstance(typedModel));
+ }
+ }
visitor.start(suspendOnStartup);
return (Boolean) transformation.accept(visitor);
}
diff --git a/plugins/org.eclipse.qvtd.pivot.qvtbase/plugin.xml b/plugins/org.eclipse.qvtd.pivot.qvtbase/plugin.xml
index d096f11e8..ce3399797 100644
--- a/plugins/org.eclipse.qvtd.pivot.qvtbase/plugin.xml
+++ b/plugins/org.eclipse.qvtd.pivot.qvtbase/plugin.xml
@@ -35,6 +35,13 @@
</describer>
</content-type>
</extension>
+
+ <extension point="org.eclipse.ocl.pivot.label_generator">
+ <generator for="org.eclipse.qvtd.pivot.qvtbase.evaluation.TransformationInstance"
+ class="org.eclipse.qvtd.pivot.qvtbase.utilities.TransformationInstanceLabelGenerator"/>
+ <generator for="org.eclipse.qvtd.pivot.qvtbase.evaluation.TypedModelInstance"
+ class="org.eclipse.qvtd.pivot.qvtbase.utilities.TypedModelInstanceLabelGenerator"/>
+ </extension>
<extension point="org.eclipse.ocl.pivot.standard_library"
id="qvtbaselibrary" name="QVTbase Library">
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 513e8ea6a..b1b7370a3 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
@@ -252,6 +252,11 @@ public abstract class AbstractTransformationExecutor implements TransformationEx
public String toString() {
return name + " " + (rootEObjects != null ? rootEObjects.size() : "null") + "/" + (allEObjects != null ? allEObjects.size() : "null");
}
+
+ @Override
+ public @NonNull String getName() {
+ return name;
+ }
}
protected final @NonNull Evaluator evaluator;
diff --git a/plugins/org.eclipse.qvtd.pivot.qvtbase/src/org/eclipse/qvtd/pivot/qvtbase/evaluation/TransformationInstance.java b/plugins/org.eclipse.qvtd.pivot.qvtbase/src/org/eclipse/qvtd/pivot/qvtbase/evaluation/TransformationInstance.java
index 25b074b1d..cf47a321b 100644
--- a/plugins/org.eclipse.qvtd.pivot.qvtbase/src/org/eclipse/qvtd/pivot/qvtbase/evaluation/TransformationInstance.java
+++ b/plugins/org.eclipse.qvtd.pivot.qvtbase/src/org/eclipse/qvtd/pivot/qvtbase/evaluation/TransformationInstance.java
@@ -10,5 +10,8 @@
*******************************************************************************/
package org.eclipse.qvtd.pivot.qvtbase.evaluation;
+import org.eclipse.jdt.annotation.Nullable;
+
public interface TransformationInstance {
+ @Nullable String getName();
}
diff --git a/plugins/org.eclipse.qvtd.pivot.qvtbase/src/org/eclipse/qvtd/pivot/qvtbase/evaluation/TypedModelInstance.java b/plugins/org.eclipse.qvtd.pivot.qvtbase/src/org/eclipse/qvtd/pivot/qvtbase/evaluation/TypedModelInstance.java
index eb1de6010..eeb31da0c 100644
--- a/plugins/org.eclipse.qvtd.pivot.qvtbase/src/org/eclipse/qvtd/pivot/qvtbase/evaluation/TypedModelInstance.java
+++ b/plugins/org.eclipse.qvtd.pivot.qvtbase/src/org/eclipse/qvtd/pivot/qvtbase/evaluation/TypedModelInstance.java
@@ -14,10 +14,12 @@ import java.util.Collection;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.jdt.annotation.Nullable;
public interface TypedModelInstance
{
@NonNull Collection<EObject> getAllObjects();
+ @Nullable String getName();
@NonNull Collection<EObject> getObjectsOfKind(@NonNull org.eclipse.ocl.pivot.Class type);
@NonNull Collection<EObject> getObjectsOfType(@NonNull org.eclipse.ocl.pivot.Class type);
@NonNull Collection<EObject> getRootObjects();
diff --git a/plugins/org.eclipse.qvtd.pivot.qvtbase/src/org/eclipse/qvtd/pivot/qvtbase/utilities/TransformationInstanceLabelGenerator.java b/plugins/org.eclipse.qvtd.pivot.qvtbase/src/org/eclipse/qvtd/pivot/qvtbase/utilities/TransformationInstanceLabelGenerator.java
new file mode 100644
index 000000000..a2b0fad94
--- /dev/null
+++ b/plugins/org.eclipse.qvtd.pivot.qvtbase/src/org/eclipse/qvtd/pivot/qvtbase/utilities/TransformationInstanceLabelGenerator.java
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * Copyright (c) 2015 Willink Transformations and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * E.D.Willink - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.qvtd.pivot.qvtbase.utilities;
+
+import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.ocl.pivot.labels.AbstractLabelGenerator;
+import org.eclipse.qvtd.pivot.qvtbase.evaluation.TransformationInstance;
+
+public final class TransformationInstanceLabelGenerator extends AbstractLabelGenerator<TransformationInstance>
+{
+ public static void initialize(Registry registry) {
+ registry.install(TransformationInstance.class, new TransformationInstanceLabelGenerator());
+ }
+
+ public TransformationInstanceLabelGenerator() {
+ super(TransformationInstance.class);
+ }
+
+ @Override
+ public void buildLabelFor(@NonNull Builder labelBuilder, @NonNull TransformationInstance element) {
+ labelBuilder.appendString(element.getName());
+ }
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.qvtd.pivot.qvtbase/src/org/eclipse/qvtd/pivot/qvtbase/utilities/TypedModelInstanceLabelGenerator.java b/plugins/org.eclipse.qvtd.pivot.qvtbase/src/org/eclipse/qvtd/pivot/qvtbase/utilities/TypedModelInstanceLabelGenerator.java
new file mode 100644
index 000000000..86912ddc7
--- /dev/null
+++ b/plugins/org.eclipse.qvtd.pivot.qvtbase/src/org/eclipse/qvtd/pivot/qvtbase/utilities/TypedModelInstanceLabelGenerator.java
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * Copyright (c) 2015 Willink Transformations and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * E.D.Willink - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.qvtd.pivot.qvtbase.utilities;
+
+import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.ocl.pivot.labels.AbstractLabelGenerator;
+import org.eclipse.qvtd.pivot.qvtbase.evaluation.TypedModelInstance;
+
+public final class TypedModelInstanceLabelGenerator extends AbstractLabelGenerator<TypedModelInstance>
+{
+ public static void initialize(Registry registry) {
+ registry.install(TypedModelInstance.class, new TypedModelInstanceLabelGenerator());
+ }
+
+ public TypedModelInstanceLabelGenerator() {
+ super(TypedModelInstance.class);
+ }
+
+ @Override
+ public void buildLabelFor(@NonNull Builder labelBuilder, @NonNull TypedModelInstance element) {
+ labelBuilder.appendString(element.getName());
+ }
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.qvtd.pivot.qvtimperative/src/org/eclipse/qvtd/pivot/qvtimperative/evaluation/QVTiModelManager.java b/plugins/org.eclipse.qvtd.pivot.qvtimperative/src/org/eclipse/qvtd/pivot/qvtimperative/evaluation/QVTiModelManager.java
index 1e269f1ba..47727fbc2 100644
--- a/plugins/org.eclipse.qvtd.pivot.qvtimperative/src/org/eclipse/qvtd/pivot/qvtimperative/evaluation/QVTiModelManager.java
+++ b/plugins/org.eclipse.qvtd.pivot.qvtimperative/src/org/eclipse/qvtd/pivot/qvtimperative/evaluation/QVTiModelManager.java
@@ -340,6 +340,11 @@ public class QVTiModelManager implements ModelManager
return modelManager;
}
+ @Override
+ public @Nullable String getName() {
+ return transformation.getName();
+ }
+
public @NonNull Transformation getTransformation() {
return transformation;
}
@@ -359,6 +364,11 @@ public class QVTiModelManager implements ModelManager
public @NonNull Set<EObject> getAllObjects() {
throw new UnsupportedOperationException();
}
+
+ @Override
+ public @Nullable String getName() {
+ return typedModel.getName();
+ }
@Override
public @NonNull Set<EObject> getObjectsOfKind(@NonNull org.eclipse.ocl.pivot.Class type) {
@@ -386,7 +396,7 @@ public class QVTiModelManager implements ModelManager
public @NonNull Collection<EObject> getRootObjects() {
throw new UnsupportedOperationException();
}
-
+
public @NonNull TypedModel getTypedModel() {
return typedModel;
}

Back to the top