Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEd Willink2015-08-17 16:42:38 -0400
committerEd Willink2015-08-17 16:42:38 -0400
commit95404765517baffb967314519c7717a848d19ff4 (patch)
tree1a52c565f606ca20540aba2fa580d7a3289176e1
parent302d2174597ebb38ec2bf77de3499cb9948994a9 (diff)
downloadorg.eclipse.qvtd-ewillink/ocl25.tar.gz
org.eclipse.qvtd-ewillink/ocl25.tar.xz
org.eclipse.qvtd-ewillink/ocl25.zip
-rw-r--r--plugins/org.eclipse.qvtd.xtext.qvtrelation/src/org/eclipse/qvtd/xtext/qvtrelation/cs2as/QVTrelationCSLeft2RightVisitor.java23
-rw-r--r--plugins/org.eclipse.qvtd.xtext.qvtrelation/src/org/eclipse/qvtd/xtext/qvtrelation/utilities/QVTrelation.java42
-rw-r--r--tests/org.eclipse.qvtd.xtext.qvtrelation.tests/src/org/eclipse/qvtd/xtext/qvtrelation/tests/LoadTests.java3
3 files changed, 67 insertions, 1 deletions
diff --git a/plugins/org.eclipse.qvtd.xtext.qvtrelation/src/org/eclipse/qvtd/xtext/qvtrelation/cs2as/QVTrelationCSLeft2RightVisitor.java b/plugins/org.eclipse.qvtd.xtext.qvtrelation/src/org/eclipse/qvtd/xtext/qvtrelation/cs2as/QVTrelationCSLeft2RightVisitor.java
index 15b527071..be89d65f5 100644
--- a/plugins/org.eclipse.qvtd.xtext.qvtrelation/src/org/eclipse/qvtd/xtext/qvtrelation/cs2as/QVTrelationCSLeft2RightVisitor.java
+++ b/plugins/org.eclipse.qvtd.xtext.qvtrelation/src/org/eclipse/qvtd/xtext/qvtrelation/cs2as/QVTrelationCSLeft2RightVisitor.java
@@ -35,8 +35,10 @@ import org.eclipse.ocl.pivot.utilities.StringUtil;
import org.eclipse.ocl.xtext.base.cs2as.CS2AS;
import org.eclipse.ocl.xtext.base.cs2as.CS2ASConversion;
import org.eclipse.ocl.xtext.basecs.ElementCS;
+import org.eclipse.ocl.xtext.basecs.ModelElementCS;
import org.eclipse.ocl.xtext.basecs.PathNameCS;
import org.eclipse.ocl.xtext.essentialocl.cs2as.ImplicitSourceTypeIterator;
+import org.eclipse.ocl.xtext.essentialocl.cs2as.ImplicitSourceVariableIterator;
import org.eclipse.ocl.xtext.essentialoclcs.AbstractNameExpCS;
import org.eclipse.ocl.xtext.essentialoclcs.ExpCS;
import org.eclipse.ocl.xtext.essentialoclcs.NameExpCS;
@@ -47,6 +49,7 @@ import org.eclipse.qvtd.pivot.qvtbase.Domain;
import org.eclipse.qvtd.pivot.qvtbase.Function;
import org.eclipse.qvtd.pivot.qvtbase.Rule;
import org.eclipse.qvtd.pivot.qvtbase.Transformation;
+import org.eclipse.qvtd.pivot.qvtbase.utilities.QVTbaseUtil;
import org.eclipse.qvtd.pivot.qvtrelation.QVTrelationPackage;
import org.eclipse.qvtd.pivot.qvtrelation.Relation;
import org.eclipse.qvtd.pivot.qvtrelation.RelationCallExp;
@@ -102,6 +105,26 @@ public class QVTrelationCSLeft2RightVisitor extends AbstractQVTrelationCSLeft2Ri
}
@Override
+ protected @NonNull ImplicitSourceVariableIterator createImplicitSourceVariableIterator(@NonNull ModelElementCS csElement) {
+ return new ImplicitSourceVariableIterator(csElement)
+ {
+ @Override
+ protected boolean doNext(@NonNull ElementCS csParent, @NonNull ElementCS csChild) {
+ if (csParent instanceof TransformationCS) {
+ Transformation asContext = PivotUtil.getPivot(Transformation.class, (TransformationCS)csParent);
+ if (asContext != null) {
+ addNext(QVTbaseUtil.getContextVariable(standardLibrary, asContext));
+ }
+ return DONE; // no more parents
+ }
+ else {
+ return super.doNext(csParent, csChild);
+ }
+ }
+ };
+ }
+
+ @Override
protected ImplicitSourceTypeIterator createImplicitSourceTypeIterator(@NonNull ElementCS csElement) {
return new ImplicitSourceTypeIterator(csElement)
{
diff --git a/plugins/org.eclipse.qvtd.xtext.qvtrelation/src/org/eclipse/qvtd/xtext/qvtrelation/utilities/QVTrelation.java b/plugins/org.eclipse.qvtd.xtext.qvtrelation/src/org/eclipse/qvtd/xtext/qvtrelation/utilities/QVTrelation.java
new file mode 100644
index 000000000..8402054e9
--- /dev/null
+++ b/plugins/org.eclipse.qvtd.xtext.qvtrelation/src/org/eclipse/qvtd/xtext/qvtrelation/utilities/QVTrelation.java
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * 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.xtext.qvtrelation.utilities;
+
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.jdt.annotation.Nullable;
+import org.eclipse.ocl.pivot.resource.ProjectManager;
+import org.eclipse.qvtd.pivot.qvtbase.utilities.QVTbase;
+import org.eclipse.qvtd.pivot.qvtbase.utilities.QVTbaseEnvironmentFactory;
+
+/**
+ * The QVTimperative facade refines the QVTbase and OCL facades to enforce use of the QVTimperative Standard Library.
+ */
+public class QVTrelation extends QVTbase
+{
+ public static @NonNull QVTrelation newInstance(@NonNull ProjectManager projectManager, @Nullable ResourceSet externalResourceSet) {
+ QVTbaseEnvironmentFactory environmentFactory = new QVTbaseEnvironmentFactory(projectManager, externalResourceSet);
+ QVTrelation qvt = new QVTrelation(environmentFactory);
+ if (externalResourceSet != null) {
+ environmentFactory.adapt(externalResourceSet);
+ }
+ return qvt;
+ }
+
+ public QVTrelation(@NonNull QVTbaseEnvironmentFactory environmentFactory) {
+ super(environmentFactory);
+ }
+
+// @Override
+// public @NonNull QVTiEnvironmentFactory getEnvironmentFactory() {
+// return (QVTiEnvironmentFactory) super.getEnvironmentFactory();
+// }
+} \ No newline at end of file
diff --git a/tests/org.eclipse.qvtd.xtext.qvtrelation.tests/src/org/eclipse/qvtd/xtext/qvtrelation/tests/LoadTests.java b/tests/org.eclipse.qvtd.xtext.qvtrelation.tests/src/org/eclipse/qvtd/xtext/qvtrelation/tests/LoadTests.java
index 4c05fa4d1..b5ab154ae 100644
--- a/tests/org.eclipse.qvtd.xtext.qvtrelation.tests/src/org/eclipse/qvtd/xtext/qvtrelation/tests/LoadTests.java
+++ b/tests/org.eclipse.qvtd.xtext.qvtrelation.tests/src/org/eclipse/qvtd/xtext/qvtrelation/tests/LoadTests.java
@@ -17,6 +17,7 @@ import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.ocl.pivot.utilities.OCL;
import org.eclipse.ocl.xtext.base.services.BaseLinkingService;
import org.eclipse.qvtd.xtext.qvtbase.tests.LoadTestCase;
+import org.eclipse.qvtd.xtext.qvtrelation.utilities.QVTrelation;
/**
* Tests that load a model and verify that there are no unresolved proxies as a result.
@@ -30,7 +31,7 @@ public class LoadTests extends LoadTestCase
}
protected void doLoad_Concrete(URI inputURI, URI pivotURI) throws IOException {
- OCL ocl = OCL.newInstance(getProjectMap());
+ OCL ocl = QVTrelation.newInstance(getProjectMap(), null);
doLoad_Concrete(ocl, inputURI, pivotURI);
ocl.dispose();
}

Back to the top