Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEd Willink2015-05-03 20:50:20 +0000
committerEd Willink2015-05-03 20:50:20 +0000
commit8c2198f5d31f1b1c34d5456fa1959303343b9c8f (patch)
tree8c507d5af821743fa99669666c689f5e03062540
parentc4d66f154529f70460d15e85c8a72313e8e5c54f (diff)
downloadorg.eclipse.qvtd-8c2198f5d31f1b1c34d5456fa1959303343b9c8f.tar.gz
org.eclipse.qvtd-8c2198f5d31f1b1c34d5456fa1959303343b9c8f.tar.xz
org.eclipse.qvtd-8c2198f5d31f1b1c34d5456fa1959303343b9c8f.zip
[445105] Use QVT Library in QVTimperative editor
-rw-r--r--plugins/org.eclipse.qvtd.xtext.qvtimperative.ui/src/org/eclipse/qvtd/xtext/qvtimperative/ui/model/QVTimperativeDocumentProvider.java30
-rw-r--r--tests/org.eclipse.qvtd.xtext.qvtimperative.tests/src-gen/cg/hsv2hls.java32
-rw-r--r--tests/org.eclipse.qvtd.xtext.qvtimperative.tests/src/org/eclipse/qvtd/xtext/qvtimperative/tests/HSV2HLS/HSV2HLS.qvti4
3 files changed, 55 insertions, 11 deletions
diff --git a/plugins/org.eclipse.qvtd.xtext.qvtimperative.ui/src/org/eclipse/qvtd/xtext/qvtimperative/ui/model/QVTimperativeDocumentProvider.java b/plugins/org.eclipse.qvtd.xtext.qvtimperative.ui/src/org/eclipse/qvtd/xtext/qvtimperative/ui/model/QVTimperativeDocumentProvider.java
index 16517e0a6..fef43361c 100644
--- a/plugins/org.eclipse.qvtd.xtext.qvtimperative.ui/src/org/eclipse/qvtd/xtext/qvtimperative/ui/model/QVTimperativeDocumentProvider.java
+++ b/plugins/org.eclipse.qvtd.xtext.qvtimperative.ui/src/org/eclipse/qvtd/xtext/qvtimperative/ui/model/QVTimperativeDocumentProvider.java
@@ -12,7 +12,12 @@ package org.eclipse.qvtd.xtext.qvtimperative.ui.model;
import org.eclipse.emf.common.util.URI;
import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.jdt.annotation.Nullable;
+import org.eclipse.ocl.pivot.internal.utilities.OCLInternal;
+import org.eclipse.ocl.pivot.resource.BasicProjectManager;
+import org.eclipse.ocl.pivot.utilities.OCL;
import org.eclipse.ocl.xtext.base.ui.model.BaseCSorASDocumentProvider;
+import org.eclipse.qvtd.pivot.qvtbase.utilities.QVTbase;
import org.eclipse.qvtd.xtext.qvtimperativecs.QVTimperativeCSPackage;
/**
@@ -21,6 +26,13 @@ import org.eclipse.qvtd.xtext.qvtimperativecs.QVTimperativeCSPackage;
*/
public class QVTimperativeDocumentProvider extends BaseCSorASDocumentProvider
{
+ private @Nullable OCLInternal ocl; // FIXME Eliminate once OCL implements createOCL
+
+// @Override
+ protected @NonNull OCLInternal createOCL() {
+ return QVTbase.newInstance(BasicProjectManager.createDefaultProjectManager(), null);
+ }
+
@Override
protected @NonNull String createTestDocument(@NonNull URI uri, @NonNull String lastSegment) {
return "package " + lastSegment + " : pfx = '"+ uri + "' {\n" +
@@ -28,6 +40,16 @@ public class QVTimperativeDocumentProvider extends BaseCSorASDocumentProvider
}
@Override
+ protected void disconnected() {
+ OCL ocl2 = ocl;
+ if (ocl2 != null) {
+ ocl = null;
+ ocl2.dispose();
+ }
+ super.disconnected();
+ }
+
+ @Override
protected String getCScontentType() {
return QVTimperativeCSPackage.eCONTENT_TYPE;
}
@@ -36,4 +58,12 @@ public class QVTimperativeDocumentProvider extends BaseCSorASDocumentProvider
protected @NonNull String getFileExtension() {
return "qvti";
}
+
+ protected @NonNull OCLInternal getOCL() {
+ OCLInternal ocl2 = ocl;
+ if (ocl2 == null) {
+ ocl = ocl2 = createOCL();
+ }
+ return ocl2;
+ }
}
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 0f9d9d4e2..f27f8e766 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,7 +50,6 @@ 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);
@@ -58,7 +57,6 @@ 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);
@@ -66,9 +64,25 @@ 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, null, null);
+ super(evaluator, new String[] {"hsv", "hls", "middle"}, null, classIndex2classId, classIndex2allClassIndexes);
}
public boolean run() {
@@ -99,7 +113,7 @@ public class hsv2hls extends AbstractTransformationExecutor
* )
* { |
* }
- * for hsvRoot : HSVTree::HSVNode in hsv.objectsOfKind(HSVTree::HSVNode)
+ * for hsvRoot : HSVTree::HSVNode in HSVTree::HSVNode.allInstances()
* {
* map HSV2MiddleRoot {
* hsvRoot := hsvRoot;
@@ -113,11 +127,11 @@ public class hsv2hls extends AbstractTransformationExecutor
// creations
// assignments
// mapping statements
- 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;
+ 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;
;
- for (HSVNode hsvRoot_1 : UNBOXED_objectsOfKind) {
+ for (HSVNode hsvRoot_1 : UNBOXED_allInstances) {
if (hsvRoot_1 != null) {
final @NonNull /*@NonInvalid*/ HSVNode symbol_1 = (HSVNode)hsvRoot_1;
HSV2MiddleRoot(symbol_1);
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 d693430c5..22de9f844 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