Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdolfo SBH2016-10-26 14:34:21 +0000
committerEd Willink2016-10-31 17:39:37 +0000
commitd41aff326fddd73c8aee8eda6e5902021db41423 (patch)
tree125d5aee048ba0278bb1f7a3067b3e72da5bf2f0
parent04985be519fa240a2f243b0aca964c4611e68170 (diff)
downloadorg.eclipse.qvtd-d41aff326fddd73c8aee8eda6e5902021db41423.tar.gz
org.eclipse.qvtd-d41aff326fddd73c8aee8eda6e5902021db41423.tar.xz
org.eclipse.qvtd-d41aff326fddd73c8aee8eda6e5902021db41423.zip
[cs2as] - Minor MiniOCLFull fixes and adopting last changes from the
CompleteOCL documents generator
-rw-r--r--doc/org.eclipse.qvtd.doc.minioclcs.xtext/model/MiniOCLFull.cs2as23
-rw-r--r--doc/org.eclipse.qvtd.doc.minioclcs.xtext/model/MiniOCLFull.ocl33
-rw-r--r--doc/org.eclipse.qvtd.doc.minioclcs.xtext/model/MiniOCLFullHelpers.ocl3
-rw-r--r--doc/org.eclipse.qvtd.doc.minioclcs.xtext/model/MiniOCLFullLookup.ocl38
4 files changed, 73 insertions, 24 deletions
diff --git a/doc/org.eclipse.qvtd.doc.minioclcs.xtext/model/MiniOCLFull.cs2as b/doc/org.eclipse.qvtd.doc.minioclcs.xtext/model/MiniOCLFull.cs2as
index e95ab8f1f..00e24832c 100644
--- a/doc/org.eclipse.qvtd.doc.minioclcs.xtext/model/MiniOCLFull.cs2as
+++ b/doc/org.eclipse.qvtd.doc.minioclcs.xtext/model/MiniOCLFull.cs2as
@@ -11,13 +11,16 @@ helpers {
self = another or
superClasses->exists(conformsTo(another));
}
- cs::NameExpCS {
- parentAsCallExpCS() : CallExpCS :=
+
+ cs::NavigationExpCS {
+ parentAsCallExpCS() : CallExpCS :=
let container = self.oclContainer()
in if container.oclIsKindOf(CallExpCS)
then container.oclAsType(CallExpCS)
- else null
+ else null
endif;
+ }
+ cs::NameExpCS {
isNavExpOfACallExpCS() : Boolean :=
let parentCallExpCS = parentAsCallExpCS()
in parentCallExpCS <> null and parentCallExpCS.navExp = self;
@@ -133,8 +136,8 @@ mappings {
ownedArguments := right.trace;
referredOperation := lookupExported(Operation, trace.ownedSource.type,
opName, trace.ownedArguments);
+ type := lookup(Class, 'Boolean');
}
--- TODO
create VariableExp from NameExpCS
when fall_back {
referredVariable := null;
@@ -210,6 +213,7 @@ mappings {
ownedIterator := itVar.trace;
ownedResult := accVar.trace;
ownedBody := exp.trace;
+ ownedSource := parentAsCallExpCS()._source.trace;
type := trace.ownedResult.type;
}
@@ -218,8 +222,9 @@ mappings {
ownedIterator := if itVar = null
then as::Variable { name='self', type=lookup(Class,'OclAny') }
else itVar.trace
- endif;
+ endif;
ownedBody := exp.trace;
+ ownedSource := parentAsCallExpCS()._source.trace;
type := lookup(Class,'Collection');
}
create Variable from IteratorVarCS {
@@ -243,8 +248,8 @@ mappings {
}
create CollectionRange from CollectionLiteralPartCS
when withLastExpression {
- ownedFirst := first;
- ownedLast := last;
+ ownedFirst := first.trace;
+ ownedLast := last.trace;
type := trace.ownedFirst.type;
}
}
@@ -274,6 +279,10 @@ name_resolution {
Package using ownedPackages, exported ownedImports;
}
+ Import {
+ in exported_scope provides
+ Package using loaded Package from uri;
+ }
Package {
in current_scope provides occluding
Package using ownedPackages
diff --git a/doc/org.eclipse.qvtd.doc.minioclcs.xtext/model/MiniOCLFull.ocl b/doc/org.eclipse.qvtd.doc.minioclcs.xtext/model/MiniOCLFull.ocl
index 85772fb49..1084d2ad4 100644
--- a/doc/org.eclipse.qvtd.doc.minioclcs.xtext/model/MiniOCLFull.ocl
+++ b/doc/org.eclipse.qvtd.doc.minioclcs.xtext/model/MiniOCLFull.ocl
@@ -7,11 +7,11 @@ package cs
context ExpCS
def : ast() : as::OCLExpression =
- null
+ null -- to be overriden
context NavigationExpCS
def : ast() : as::CallExp =
- null
+ null -- to be overriden
context RootCS
def : ast() : as::Root =
@@ -91,7 +91,8 @@ def : ast() : as::OperationCallExp =
as::OperationCallExp {
ownedSource = left.ast(),
ownedArguments = right.ast(),
-referredOperation = ast().lookupOperationFrom(ast().ownedSource.type, opName, ast().ownedArguments)
+referredOperation = ast().lookupOperationFrom(ast().ownedSource.type, opName, ast().ownedArguments),
+type = ast().lookupClass('Boolean' )
}
context NameExpCS
def : ast() : as::OCLExpression =
@@ -105,7 +106,7 @@ type = ast().oclAsType(as::OperationCallExp).referredOperation ?. type
else
if isOpCallExpWithImplicitSource()
then as::OperationCallExp {
- ownedSource = let referredVar = ast().lookupVariable(' self' )
+ ownedSource = let referredVar = ast().lookupVariable('self' )
in as::VariableExp {
referredVariable = referredVar,
type = referredVar.type
@@ -131,7 +132,7 @@ else
else
if isPropCallExpWithImplicitSource()
then as::PropertyCallExp {
- ownedSource = let referredVar = ast().lookupVariable(' self' )
+ ownedSource = let referredVar = ast().lookupVariable('self' )
in as::VariableExp {
referredVariable = referredVar,
type = referredVar.type
@@ -143,7 +144,7 @@ else
else
as::VariableExp {
referredVariable = null,
- type = ast().lookupClass(' OclVoid' )
+ type = ast().lookupClass('OclVoid' )
}
endif
endif
@@ -186,25 +187,27 @@ def : ast() : as::IterateExp =
as::IterateExp {
ownedIterator = itVar.ast(),
ownedResult = accVar.ast(),
-ownedBody = exp.ast(),
+ownedBody = exp.ast(),
+ownedSource = parentAsCallExpCS()._source.ast(),
type = ast().ownedResult.type
}
context CollectExpCS
def : ast() : as::IteratorExp =
as::IteratorExp {
- iterator = ' collect' ,
+ iterator = 'collect' ,
ownedIterator = if itVar = null then as::Variable {
- name = ' self' ,
- type = ast().lookupClass(' OclAny' )
+ name = 'self' ,
+ type = ast().lookupClass('OclAny' )
} else itVar.ast() endif,
ownedBody = exp.ast(),
-type = ast().lookupClass(' Collection' )
+ownedSource = self.parentAsCallExpCS()._source.ast(),
+type = ast().lookupClass('Collection' )
}
context IteratorVarCS
def : ast() : as::Variable =
as::Variable {
name = itName,
-type = if itType <> null then ast().lookupClass(itType) else ast().lookupClass(' OclAny' ) endif
+type = if itType <> null then ast().lookupClass(itType) else ast().lookupClass('OclAny' ) endif
}
context AccVarCS
def : ast() : as::Variable =
@@ -218,7 +221,7 @@ def : ast() : as::CollectionLiteralExp =
as::CollectionLiteralExp {
kind = kind,
ownedParts = parts.ast(),
-type = ast().lookupClass(' Collection' )
+type = ast().lookupClass('Collection' )
}
context CollectionLiteralPartCS
def : ast() : as::CollectionLiteralPart =
@@ -230,8 +233,8 @@ type = ast().oclAsType(as::CollectionItem).ownedItem.type
else
if withLastExpression()
then as::CollectionRange {
- ownedFirst = first,
- ownedLast = last,
+ ownedFirst = first.ast(),
+ ownedLast = last.ast(),
type = ast().oclAsType(as::CollectionRange).ownedFirst.type
}
else
diff --git a/doc/org.eclipse.qvtd.doc.minioclcs.xtext/model/MiniOCLFullHelpers.ocl b/doc/org.eclipse.qvtd.doc.minioclcs.xtext/model/MiniOCLFullHelpers.ocl
index 932ebb9ce..fd18e0956 100644
--- a/doc/org.eclipse.qvtd.doc.minioclcs.xtext/model/MiniOCLFullHelpers.ocl
+++ b/doc/org.eclipse.qvtd.doc.minioclcs.xtext/model/MiniOCLFullHelpers.ocl
@@ -2,10 +2,11 @@ import cs : 'generated/MiniOCLCS.ecore#/'
import as : '/resource/org.eclipse.qvtd.doc.miniocl/model/MiniOCL.ecore#/'
package cs
-context cs::NameExpCS
+context cs::NavigationExpCS
def : parentAsCallExpCS() :CallExpCS =
let container = self.oclContainer()
in if container.oclIsKindOf(CallExpCS) then container.oclAsType(CallExpCS) else null endif
+context cs::NameExpCS
def : isNavExpOfACallExpCS() :Boolean =
let parentCallExpCS = parentAsCallExpCS()
in parentCallExpCS <> null and parentCallExpCS.navExp = self
diff --git a/doc/org.eclipse.qvtd.doc.minioclcs.xtext/model/MiniOCLFullLookup.ocl b/doc/org.eclipse.qvtd.doc.minioclcs.xtext/model/MiniOCLFullLookup.ocl
index 843e0db50..0eeb6e814 100644
--- a/doc/org.eclipse.qvtd.doc.minioclcs.xtext/model/MiniOCLFullLookup.ocl
+++ b/doc/org.eclipse.qvtd.doc.minioclcs.xtext/model/MiniOCLFullLookup.ocl
@@ -48,6 +48,8 @@ def : parentEnv_Property() : lookup::LookupEnvironment[1] =
def : _exported_env_Property(importer : OclElement) : lookup::LookupEnvironment[1] =
lookup::LookupEnvironment { }
+def : _exported_env_Package(importer : OclElement) : lookup::LookupEnvironment[1] =
+ lookup::LookupEnvironment { }
def : _exported_env_Operation(importer : OclElement) : lookup::LookupEnvironment[1] =
lookup::LookupEnvironment { }
@@ -330,8 +332,42 @@ context Root
def : _unqualified_env_Package(child : ocl::OclElement) : lookup::LookupEnvironment =
parentEnv_Package()
.addElements(ownedPackages)
- --TODO .addElements(ownedImports._exported_env(self).namedElements)
+ .addElements(ownedImports._exported_env_Package(self).namedElements)
+context Import
+def : _exported_env_Package(importer : ocl::OclElement) : lookup::LookupEnvironment =
+ let env = lookup::LookupEnvironment {}
+ in env
+ .addElements(OrderedSet{/*AutoGenCode Will Load The Package*/})
+
+
+def : _lookupExportedPackage(importer : ocl::OclElement, pName : String) : Package[?] =
+ let foundPackage = _lookupPackage(_exported_env_Package(importer), pName)
+ in if foundPackage->isEmpty()
+ then null
+ else foundPackage->first()
+ endif
+def : lookupExportedPackage(importer : ocl::OclElement, pName : String) : Package[?] =
+ _lookupExportedPackage(importer, pName)
+def : lookupExportedPackage(importer : ocl::OclElement, aPathElementCS : cs::PathElementCS) : Package[?] =
+ _lookupExportedPackage(importer, aPathElementCS.elementName)
+
+context Visitable
+-- Import exports Package
+def : lookupPackageFrom(exporter : Import , iName : String) : Package[?] =
+ exporter.lookupExportedPackage(self, iName)
+def : lookupPackageFrom(exporter : Import, aPathElementCS : cs::PathElementCS) : Package[?] =
+ exporter.lookupExportedPackage(self, aPathElementCS)
+def : lookupPackageFrom(exporter : Import, aPathNameCS : cs::PathNameCS) : Package[?] =
+ lookupPackageFrom(exporter, aPathNameCS.pathElements)
+
+def : lookupPackageFrom(exporter : Import, segments : OrderedSet(cs::PathElementCS)) : Package[?] =
+ if segments->size() = 1
+ then lookupPackageFrom(exporter, segments->first())
+ else let qualifierSegments = segments->subOrderedSet(1,segments->size()-1),
+ qualifier = lookupPackage(qualifierSegments)
+ in qualifier?.lookupQualifiedPackage(segments->last())
+ endif
context Package
def : _unqualified_env_Package(child : ocl::OclElement) : lookup::LookupEnvironment =
parentEnv_Package().nestedEnv()

Back to the top