Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdolfo SBH2016-03-21 14:27:45 -0400
committerAdolfo SBH2016-03-26 05:46:35 -0400
commit00120651918ddda0e97394a4ed36bcbbe7dcba99 (patch)
treea044acd7d8281be820eaf234634d8c84ad8afbee /tests/org.eclipse.qvtd.cs2as.compiler.tests/src/org/eclipse/qvtd
parent2324e9520771a6872eecaf21552bafed448f4d08 (diff)
downloadorg.eclipse.qvtd-00120651918ddda0e97394a4ed36bcbbe7dcba99.tar.gz
org.eclipse.qvtd-00120651918ddda0e97394a4ed36bcbbe7dcba99.tar.xz
org.eclipse.qvtd-00120651918ddda0e97394a4ed36bcbbe7dcba99.zip
[cs2as] - Redefining Example2 to support aliases
Diffstat (limited to 'tests/org.eclipse.qvtd.cs2as.compiler.tests/src/org/eclipse/qvtd')
-rw-r--r--tests/org.eclipse.qvtd.cs2as.compiler.tests/src/org/eclipse/qvtd/cs2as/compiler/tests/models/example2/EnvExample2.ecore30
-rw-r--r--tests/org.eclipse.qvtd.cs2as.compiler.tests/src/org/eclipse/qvtd/cs2as/compiler/tests/models/example2/classescs2asLookup.ocl4
-rw-r--r--tests/org.eclipse.qvtd.cs2as.compiler.tests/src/org/eclipse/qvtd/cs2as/compiler/tests/models/example2/classescs2asV2Lookup.ocl8
3 files changed, 31 insertions, 11 deletions
diff --git a/tests/org.eclipse.qvtd.cs2as.compiler.tests/src/org/eclipse/qvtd/cs2as/compiler/tests/models/example2/EnvExample2.ecore b/tests/org.eclipse.qvtd.cs2as.compiler.tests/src/org/eclipse/qvtd/cs2as/compiler/tests/models/example2/EnvExample2.ecore
index 946f0ea0a..501c9db39 100644
--- a/tests/org.eclipse.qvtd.cs2as.compiler.tests/src/org/eclipse/qvtd/cs2as/compiler/tests/models/example2/EnvExample2.ecore
+++ b/tests/org.eclipse.qvtd.cs2as.compiler.tests/src/org/eclipse/qvtd/cs2as/compiler/tests/models/example2/EnvExample2.ecore
@@ -12,7 +12,7 @@
<eClassifiers xsi:type="ecore:EClass" name="LookupEnvironment" eSuperTypes="#//Env4CG">
<eOperations name="addElements" lowerBound="1" eType="#//LookupEnvironment">
<eAnnotations source="http://www.eclipse.org/emf/2002/Ecore/OCL/Pivot">
- <details key="body" value="LookupEnvironment{&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;&#x9;namedElements = namedElements->includingAll(elements),&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;&#x9;parentEnv = parentEnv&#x9;&#xA;&#x9;&#x9;&#x9;&#x9;}"/>
+ <details key="body" value="elements->iterate(x : classes::NamedElement ; acc : LookupEnvironment = self | acc.addElement(x))"/>
</eAnnotations>
<eTypeParameters name="NE">
<eBounds eClassifier="ecore:EClass Classes.ecore#//NamedElement"/>
@@ -25,12 +25,25 @@
</eOperations>
<eOperations name="addElement" lowerBound="1" eType="#//LookupEnvironment">
<eAnnotations source="http://www.eclipse.org/emf/2002/Ecore/OCL/Pivot">
- <details key="body" value="LookupEnvironment{&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;&#x9;namedElements = namedElements->including(element),&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;&#x9;parentEnv = parentEnv&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;}"/>
+ <details key="body" value="addElementWithName(element.name, element)"/>
</eAnnotations>
- <eParameters name="element" eType="ecore:EClass Classes.ecore#//NamedElement"/>
+ <eParameters name="element" lowerBound="1" eType="ecore:EClass Classes.ecore#//NamedElement"/>
</eOperations>
- <eStructuralFeatures xsi:type="ecore:EReference" name="namedElements" upperBound="-1"
- eType="ecore:EClass Classes.ecore#//NamedElement"/>
+ <eOperations name="addElementWithName" lowerBound="1" eType="#//LookupEnvironment">
+ <eAnnotations source="http://www.eclipse.org/emf/2002/Ecore/OCL/Pivot">
+ <details key="body" value="let entry = entries->select(name = entryName)&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;in LookupEnvironment {&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;&#x9;entries = if entry = null &#xA;&#x9;&#x9;&#x9;&#x9;&#x9;&#x9;&#x9;&#x9;then entries->including( EnvEntry {name=entryName, namedElements = OrderedSet{element}} )&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;&#x9;&#x9;&#x9;else entries->excluding(entry)->including( EnvEntry {name=entryName, namedElements = entry.namedElements->including(element)})&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;&#x9;&#x9;&#x9;endif&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;}&#xA;&#x9;&#x9;&#x9;&#xA;&#x9;&#x9;&#x9;"/>
+ </eAnnotations>
+ <eParameters name="entryName" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
+ <eParameters name="element" lowerBound="1" eType="ecore:EClass Classes.ecore#//NamedElement"/>
+ </eOperations>
+ <eOperations name="getNamedElements" upperBound="-1" eType="ecore:EClass Classes.ecore#//NamedElement">
+ <eAnnotations source="http://www.eclipse.org/emf/2002/Ecore/OCL/Pivot">
+ <details key="body" value="let entry = entries->select(name = entryName)&#xA;&#x9;&#x9;&#x9;&#x9;in if entry = null then OrderedSet(classes::NamedElement){} else entry.namedElements endif"/>
+ </eAnnotations>
+ <eParameters name="entryName" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
+ </eOperations>
+ <eStructuralFeatures xsi:type="ecore:EReference" name="entries" upperBound="-1"
+ eType="#//EnvEntry" containment="true" eOpposite="#//EnvEntry/env"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="parentEnv" eType="#//LookupEnvironment"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="Env4CG" abstract="true" interface="true">
@@ -45,6 +58,13 @@
</eAnnotations>
</eOperations>
</eClassifiers>
+ <eClassifiers xsi:type="ecore:EClass" name="EnvEntry">
+ <eStructuralFeatures xsi:type="ecore:EAttribute" name="name" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
+ <eStructuralFeatures xsi:type="ecore:EReference" name="namedElements" lowerBound="1"
+ upperBound="-1" eType="ecore:EClass Classes.ecore#//NamedElement"/>
+ <eStructuralFeatures xsi:type="ecore:EReference" name="env" eType="#//LookupEnvironment"
+ eOpposite="#//LookupEnvironment/entries"/>
+ </eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="Executor" instanceClassName="org.eclipse.ocl.pivot.evaluation.Executor"
abstract="true" interface="true"/>
</ecore:EPackage>
diff --git a/tests/org.eclipse.qvtd.cs2as.compiler.tests/src/org/eclipse/qvtd/cs2as/compiler/tests/models/example2/classescs2asLookup.ocl b/tests/org.eclipse.qvtd.cs2as.compiler.tests/src/org/eclipse/qvtd/cs2as/compiler/tests/models/example2/classescs2asLookup.ocl
index a63a28672..4a1166059 100644
--- a/tests/org.eclipse.qvtd.cs2as.compiler.tests/src/org/eclipse/qvtd/cs2as/compiler/tests/models/example2/classescs2asLookup.ocl
+++ b/tests/org.eclipse.qvtd.cs2as.compiler.tests/src/org/eclipse/qvtd/cs2as/compiler/tests/models/example2/classescs2asLookup.ocl
@@ -82,7 +82,7 @@ def : _unqualified_env_Class(child : ocl::OclElement) : lookup::LookupEnvironmen
context Visitable
-- Package lookup
def : _lookupPackage(env : lookup::LookupEnvironment, pName : String) : OrderedSet(Package) =
-let foundPackage = env.namedElements->selectByKind(Package)->select(name = pName)
+let foundPackage = env.getNamedElements(pName)->selectByKind(Package)
in if foundPackage->isEmpty() and not (env.parentEnv = null)
then _lookupPackage(env.parentEnv, pName)
else foundPackage
@@ -114,7 +114,7 @@ def : lookupPackage(segments : OrderedSet(cs::PathElementCS)) : Package[?] =
-- Class lookup
def : _lookupClass(env : lookup::LookupEnvironment, cName : String) : OrderedSet(Class) =
-let foundClass = env.namedElements->selectByKind(Class)->select(name = cName)
+let foundClass = env.getNamedElements(cName)->selectByKind(Class)
in if foundClass->isEmpty() and not (env.parentEnv = null)
then _lookupClass(env.parentEnv, cName)
else foundClass
diff --git a/tests/org.eclipse.qvtd.cs2as.compiler.tests/src/org/eclipse/qvtd/cs2as/compiler/tests/models/example2/classescs2asV2Lookup.ocl b/tests/org.eclipse.qvtd.cs2as.compiler.tests/src/org/eclipse/qvtd/cs2as/compiler/tests/models/example2/classescs2asV2Lookup.ocl
index c4a4b6669..1b5a56220 100644
--- a/tests/org.eclipse.qvtd.cs2as.compiler.tests/src/org/eclipse/qvtd/cs2as/compiler/tests/models/example2/classescs2asV2Lookup.ocl
+++ b/tests/org.eclipse.qvtd.cs2as.compiler.tests/src/org/eclipse/qvtd/cs2as/compiler/tests/models/example2/classescs2asV2Lookup.ocl
@@ -187,7 +187,7 @@ def : _appliesFilter_Operation(args : OrderedSet(Argument)) : Boolean =
context Visitable
-- Package lookup
def : _lookupPackage(env : lookup::LookupEnvironment, pName : String) : OrderedSet(Package) =
-let foundPackage = env.namedElements->selectByKind(Package)->select(name = pName)
+let foundPackage = env.getNamedElements(pName)->selectByKind(Package)
in if foundPackage->isEmpty() and not (env.parentEnv = null)
then _lookupPackage(env.parentEnv, pName)
else foundPackage
@@ -219,7 +219,7 @@ def : lookupPackage(segments : OrderedSet(cs::PathElementCS)) : Package[?] =
-- Class lookup
def : _lookupClass(env : lookup::LookupEnvironment, cName : String) : OrderedSet(Class) =
-let foundClass = env.namedElements->selectByKind(Class)->select(name = cName)
+let foundClass = env.getNamedElements(cName)->selectByKind(Class)
in if foundClass->isEmpty() and not (env.parentEnv = null)
then _lookupClass(env.parentEnv, cName)
else foundClass
@@ -281,7 +281,7 @@ def : lookupPropertyFrom(exporter : Class, segments : OrderedSet(cs::PathElement
endif
-- Operation lookup
def : _lookupOperation(env : lookup::LookupEnvironment, oName : String, args : OrderedSet(Argument)) : OrderedSet(Operation) =
-let foundOperation = env.namedElements->selectByKind(Operation)->select(name = oName)
+let foundOperation = env.getNamedElements(oName)->selectByKind(Operation)
->select(_appliesFilter_Operation(args))
in if foundOperation->isEmpty() and not (env.parentEnv = null)
then _lookupOperation(env.parentEnv, oName, args)
@@ -314,7 +314,7 @@ def : lookupOperation(segments : OrderedSet(cs::PathElementCS), args : OrderedSe
-- Property lookup
def : _lookupProperty(env : lookup::LookupEnvironment, pName : String) : OrderedSet(Property) =
-let foundProperty = env.namedElements->selectByKind(Property)->select(name = pName)
+let foundProperty = env.getNamedElements(pName)->selectByKind(Property)
in if foundProperty->isEmpty() and not (env.parentEnv = null)
then _lookupProperty(env.parentEnv, pName)
else foundProperty

Back to the top