blob: 1a10e71e94627852068e110fc83c783aca6873f0 [file] [log] [blame]
import cs : '/resource/org.eclipse.ocl.xtext.base/model/BaseCS.ecore#/'
import as : 'Pivot.ecore#/'
import 'Lookup.ecore'
import 'PivotCS2ASHelpers.ocl'
package pivot
context OclElement
-- Domain specific default functionality
def : unqualified_env_Variable() : lookup::LookupEnvironment[1] =
_unqualified_env_Variable(null)
def : unqualified_env_Class() : lookup::LookupEnvironment[1] =
_unqualified_env_Class(null)
def : unqualified_env_Behavior() : lookup::LookupEnvironment[1] =
_unqualified_env_Behavior(null)
def : unqualified_env_Operation() : lookup::LookupEnvironment[1] =
_unqualified_env_Operation(null)
def : unqualified_env_Package() : lookup::LookupEnvironment[1] =
_unqualified_env_Package(null)
def : unqualified_env_Precedence() : lookup::LookupEnvironment[1] =
_unqualified_env_Precedence(null)
def : unqualified_env_EnumerationLiteral() : lookup::LookupEnvironment[1] =
_unqualified_env_EnumerationLiteral(null)
def : unqualified_env_Property() : lookup::LookupEnvironment[1] =
_unqualified_env_Property(null)
def : unqualified_env_Namespace() : lookup::LookupEnvironment[1] =
_unqualified_env_Namespace(null)
def : _unqualified_env_Variable(child : OclElement) : lookup::LookupEnvironment[1] =
parentEnv_Variable()
def : _unqualified_env_Class(child : OclElement) : lookup::LookupEnvironment[1] =
parentEnv_Class()
def : _unqualified_env_Behavior(child : OclElement) : lookup::LookupEnvironment[1] =
parentEnv_Behavior()
def : _unqualified_env_Operation(child : OclElement) : lookup::LookupEnvironment[1] =
parentEnv_Operation()
def : _unqualified_env_Package(child : OclElement) : lookup::LookupEnvironment[1] =
parentEnv_Package()
def : _unqualified_env_Precedence(child : OclElement) : lookup::LookupEnvironment[1] =
parentEnv_Precedence()
def : _unqualified_env_EnumerationLiteral(child : OclElement) : lookup::LookupEnvironment[1] =
parentEnv_EnumerationLiteral()
def : _unqualified_env_Property(child : OclElement) : lookup::LookupEnvironment[1] =
parentEnv_Property()
def : _unqualified_env_Namespace(child : OclElement) : lookup::LookupEnvironment[1] =
parentEnv_Namespace()
def : parentEnv_Variable() : lookup::LookupEnvironment[1] =
let parent = oclContainer() in if parent = null then lookup::LookupEnvironment { } else parent._unqualified_env_Variable(self) endif
def : parentEnv_Class() : lookup::LookupEnvironment[1] =
let parent = oclContainer() in if parent = null then lookup::LookupEnvironment { } else parent._unqualified_env_Class(self) endif
def : parentEnv_Behavior() : lookup::LookupEnvironment[1] =
let parent = oclContainer() in if parent = null then lookup::LookupEnvironment { } else parent._unqualified_env_Behavior(self) endif
def : parentEnv_Operation() : lookup::LookupEnvironment[1] =
let parent = oclContainer() in if parent = null then lookup::LookupEnvironment { } else parent._unqualified_env_Operation(self) endif
def : parentEnv_Package() : lookup::LookupEnvironment[1] =
let parent = oclContainer() in if parent = null then lookup::LookupEnvironment { } else parent._unqualified_env_Package(self) endif
def : parentEnv_Precedence() : lookup::LookupEnvironment[1] =
let parent = oclContainer() in if parent = null then lookup::LookupEnvironment { } else parent._unqualified_env_Precedence(self) endif
def : parentEnv_EnumerationLiteral() : lookup::LookupEnvironment[1] =
let parent = oclContainer() in if parent = null then lookup::LookupEnvironment { } else parent._unqualified_env_EnumerationLiteral(self) endif
def : parentEnv_Property() : lookup::LookupEnvironment[1] =
let parent = oclContainer() in if parent = null then lookup::LookupEnvironment { } else parent._unqualified_env_Property(self) endif
def : parentEnv_Namespace() : lookup::LookupEnvironment[1] =
let parent = oclContainer() in if parent = null then lookup::LookupEnvironment { } else parent._unqualified_env_Namespace(self) endif
def : _exported_env_Class(importer : OclElement) : lookup::LookupEnvironment[1] =
lookup::LookupEnvironment { }
def : _exported_env_Operation(importer : OclElement) : lookup::LookupEnvironment[1] =
lookup::LookupEnvironment { }
def : _exported_env_Package(importer : OclElement) : lookup::LookupEnvironment[1] =
lookup::LookupEnvironment { }
def : _qualified_env_Class(qualifier : OclElement) : lookup::LookupEnvironment[1] =
lookup::LookupEnvironment { }
def : _qualified_env_Operation(qualifier : OclElement) : lookup::LookupEnvironment[1] =
lookup::LookupEnvironment { }
def : _qualified_env_Package(qualifier : OclElement) : lookup::LookupEnvironment[1] =
lookup::LookupEnvironment { }
def : _qualified_env_Property(qualifier : OclElement) : lookup::LookupEnvironment[1] =
lookup::LookupEnvironment { }
def : _qualified_env_Namespace(qualifier : OclElement) : lookup::LookupEnvironment[1] =
lookup::LookupEnvironment { }
-- End of domain specific default functionality
endpackage
package lookup
-- Some common lookup functionality
context LookupEnvironment
def : nestedEnv() : LookupEnvironment[1] =
LookupEnvironment {
parentEnv = self
}
-- End of common lookup functionality
endpackage
package as
context Namespace
def : _lookupQualifiedNamespace(nName : String) : Namespace[?] =
let foundNamespace = _lookupNamespace(_qualified_env_Namespace(), nName)
in if foundNamespace->isEmpty()
then null
else foundNamespace->first()
endif
def : _qualified_env_Namespace() : lookup::LookupEnvironment =
let env = lookup::LookupEnvironment{}
-- FIXME manually modified
in env -- TODO TO be overriden
-- ENDOF manual addition
def : lookupQualifiedNamespace(aPathElementCS : cs::PathElementCS) : Namespace[?] =
_lookupQualifiedNamespace(aPathElementCS.name)
context Class
def : _lookupQualifiedProperty(pName : String) : Property[?] =
let foundProperty = _lookupProperty(_qualified_env_Property(), pName)
in if foundProperty->isEmpty()
then null
else foundProperty->first()
endif
def : _qualified_env_Property() : lookup::LookupEnvironment =
let env = lookup::LookupEnvironment{}
in env
.addElements(ownedProperties)
def : lookupQualifiedProperty(aPathElementCS : cs::PathElementCS) : Property[?] =
_lookupQualifiedProperty(aPathElementCS.name)
def : _lookupQualifiedNamespace(nName : String) : Namespace[?] =
let foundNamespace = _lookupNamespace(_qualified_env_Namespace(), nName)
in if foundNamespace->isEmpty()
then null
else foundNamespace->first()
endif
def : _qualified_env_Namespace() : lookup::LookupEnvironment =
let env = lookup::LookupEnvironment{}
in env
.addElements(ownedProperties)
-- FIXME manually added -> Fix the CS2AS OclGen
.addElements(ownedOperations)
-- END OF manual addition
def : lookupQualifiedNamespace(aPathElementCS : cs::PathElementCS) : Namespace[?] =
_lookupQualifiedNamespace(aPathElementCS.name)
def : _lookupQualifiedOperation(oName : String, argTypes : OrderedSet(Type)) : Operation[?] =
let foundOperation = _lookupOperation(_qualified_env_Operation(), oName, argTypes)
in if foundOperation->isEmpty()
then null
else foundOperation->first()
endif
def : _qualified_env_Operation() : lookup::LookupEnvironment =
let env = lookup::LookupEnvironment{}
in env
.addElements(ownedOperations)
def : lookupQualifiedOperation(aPathElementCS : cs::PathElementCS, argTypes : OrderedSet(Type)) : Operation[?] =
_lookupQualifiedOperation(aPathElementCS.name, argTypes)
-- FIXME Code suppressed since it's unnecessarily generated twice -> Fix the CS2AS OclGen
-- END OF SUPRESSION
def : _unqualified_env_Property(child : ocl::OclElement) : lookup::LookupEnvironment =
parentEnv_Property().nestedEnv()
.addElements(let allSuperClasses = self->closure(superClasses)
in allSuperClasses.ownedProperties->select(not isStatic)
)
.nestedEnv()
.addElements(ownedProperties->select(not isStatic))
-- FIXME The following might be improved in the generator.
def : _unqualified_env_Namespace(child : ocl::OclElement) : lookup::LookupEnvironment =
parentEnv_Namespace().nestedEnv()
.addElements(let allSuperClasses = self->closure(superClasses)
in allSuperClasses.ownedProperties->select(not isStatic)
)
.nestedEnv()
.addElements(ownedProperties->select(not isStatic))
.addElements(let allSuperClasses = self->closure(superClasses)
in allSuperClasses.ownedOperations->select(not isStatic)
)
.nestedEnv()
.addElements(ownedOperations->select(not isStatic))
.addElements(let allSuperClasses = self->closure(superClasses)
in allSuperClasses.ownedBehaviors
)
.nestedEnv()
.addElements(ownedBehaviors)
def : _unqualified_env_Operation(child : ocl::OclElement) : lookup::LookupEnvironment =
parentEnv_Operation().nestedEnv()
.addElements(let allSuperClasses = self->closure(superClasses)
in allSuperClasses.ownedOperations->select(not isStatic)
)
.nestedEnv()
.addElements(ownedOperations->select(not isStatic))
def : _unqualified_env_Behavior(child : ocl::OclElement) : lookup::LookupEnvironment =
parentEnv_Behavior().nestedEnv()
.addElements(let allSuperClasses = self->closure(superClasses)
in allSuperClasses.ownedBehaviors
)
.nestedEnv()
.addElements(ownedBehaviors)
def : _exported_env_Operation(importer : ocl::OclElement) : lookup::LookupEnvironment =
let env = lookup::LookupEnvironment {}
in env
.addElements(let allSuperClasses = self->closure(superClasses)
in allSuperClasses.ownedOperations->select(not isStatic)
)
.nestedEnv()
.addElements(ownedOperations->select(not isStatic))
def : _lookupExportedOperation(importer : ocl::OclElement, oName : String, argTypes : OrderedSet(Type)) : Operation[?] =
let foundOperation = _lookupOperation(_exported_env_Operation(importer), oName, argTypes)
in if foundOperation->isEmpty()
then null
else foundOperation->first()
endif
def : lookupExportedOperation(importer : ocl::OclElement, aPathElementCS : cs::PathElementCS, argTypes : OrderedSet(Type)) : Operation[?] =
_lookupExportedOperation(importer, aPathElementCS.name, argTypes)
context DataType
def : _unqualified_env_Property(child : ocl::OclElement) : lookup::LookupEnvironment =
parentEnv_Property().nestedEnv()
.addElements(let allSuperClasses = self->closure(superClasses)
in allSuperClasses.ownedProperties->select(not isStatic)
)
.nestedEnv()
.addElements(ownedProperties->select(not isStatic))
def : _unqualified_env_Namespace(child : ocl::OclElement) : lookup::LookupEnvironment =
parentEnv_Namespace().nestedEnv()
.addElements(let allSuperClasses = self->closure(superClasses)
in allSuperClasses.ownedProperties->select(not isStatic)
)
.nestedEnv()
.addElements(ownedProperties->select(not isStatic))
.addElements(let allSuperClasses = self->closure(superClasses)
in allSuperClasses.ownedOperations->select(not isStatic)
)
.nestedEnv()
.addElements(ownedOperations->select(not isStatic))
def : _unqualified_env_Operation(child : ocl::OclElement) : lookup::LookupEnvironment =
parentEnv_Operation().nestedEnv()
.addElements(let allSuperClasses = self->closure(superClasses)
in allSuperClasses.ownedOperations->select(not isStatic)
)
.nestedEnv()
.addElements(ownedOperations->select(not isStatic))
context Enumeration
def : _unqualified_env_EnumerationLiteral(child : ocl::OclElement) : lookup::LookupEnvironment =
parentEnv_EnumerationLiteral().nestedEnv()
.addElements(ownedLiterals)
def : _unqualified_env_Property(child : ocl::OclElement) : lookup::LookupEnvironment =
parentEnv_Property().nestedEnv()
.addElements(ownedProperties->select(not isStatic))
def : _unqualified_env_Operation(child : ocl::OclElement) : lookup::LookupEnvironment =
parentEnv_Operation().nestedEnv()
.addElements(ownedOperations->select(not isStatic))
def : _unqualified_env_Behavior(child : ocl::OclElement) : lookup::LookupEnvironment =
parentEnv_Behavior().nestedEnv()
.addElements(ownedBehaviors)
context ExpressionInOCL
def : _unqualified_env_Variable(child : ocl::OclElement) : lookup::LookupEnvironment =
parentEnv_Variable().nestedEnv()
.addElements(ownedContext->asSequence())
.addElements(ownedParameters)
.addElements(ownedResult->asSequence())
context IterateExp
def : _unqualified_env_Variable(child : ocl::OclElement) : lookup::LookupEnvironment =
if ownedIterators->includes(child)
then parentEnv_Variable().nestedEnv()
.addElements(ownedResult->asSequence())
.addElements(ownedIterators->select(x | self.ownedIterators->indexOf(x) < self.ownedIterators->indexOf(child)))
else parentEnv_Variable().nestedEnv()
.addElements(ownedIterators)
endif
context IteratorExp
def : _unqualified_env_Variable(child : ocl::OclElement) : lookup::LookupEnvironment =
if ownedIterators->includes(child)
then parentEnv_Variable().nestedEnv()
.addElements(ownedIterators->select(x | self.ownedIterators->indexOf(x) < self.ownedIterators->indexOf(child)))
else parentEnv_Variable().nestedEnv()
.addElements(ownedIterators)
endif
context LetExp
def : _unqualified_env_Variable(child : ocl::OclElement) : lookup::LookupEnvironment =
if ownedIn->includes(child)
then parentEnv_Variable().nestedEnv()
.addElements(ownedVariable->asSequence())
else parentEnv_Variable()
endif
context Library
def : _unqualified_env_Package(child : ocl::OclElement) : lookup::LookupEnvironment =
parentEnv_Package().nestedEnv()
.addElements(ownedPackages)
def : _unqualified_env_Class(child : ocl::OclElement) : lookup::LookupEnvironment =
parentEnv_Class().nestedEnv()
.addElements(ownedClasses)
def : _unqualified_env_Precedence(child : ocl::OclElement) : lookup::LookupEnvironment =
parentEnv_Precedence().nestedEnv()
.addElements(ownedPrecedences)
context Model
def : _unqualified_env_Package(child : ocl::OclElement) : lookup::LookupEnvironment =
parentEnv_Package().nestedEnv()
.addElements(ownedPackages)
def : _unqualified_env_Namespace(child : ocl::OclElement) : lookup::LookupEnvironment =
parentEnv_Namespace().nestedEnv()
.addElements(ownedPackages)
.addElements(ownedImports.importedNamespace)
def : _exported_env_Package(importer : ocl::OclElement) : lookup::LookupEnvironment =
let env = lookup::LookupEnvironment {}
in env
.addElements(ownedPackages)
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, aPathElementCS : cs::PathElementCS) : Package[?] =
_lookupExportedPackage(importer, aPathElementCS.name)
context Operation
def : _appliesFilter_Operation(argTypes : OrderedSet(Type)) : Boolean =
matchesArgs(argTypes)
def : _unqualified_env_Variable(child : ocl::OclElement) : lookup::LookupEnvironment =
if not (ownedParameters->includes(child)
)
then parentEnv_Variable().nestedEnv()
.addElements(ownedParameters)
else parentEnv_Variable()
endif
context Package
def : _lookupQualifiedClass(cName : String) : Class[?] =
let foundClass = _lookupClass(_qualified_env_Class(), cName)
in if foundClass->isEmpty()
then null
else foundClass->first()
endif
def : _qualified_env_Class() : lookup::LookupEnvironment =
let env = lookup::LookupEnvironment{}
in env
.addElements(ownedClasses)
def : lookupQualifiedClass(aPathElementCS : cs::PathElementCS) : Class[?] =
_lookupQualifiedClass(aPathElementCS.name)
def : _lookupQualifiedNamespace(nName : String) : Namespace[?] =
let foundNamespace = _lookupNamespace(_qualified_env_Namespace(), nName)
in if foundNamespace->isEmpty()
then null
else foundNamespace->first()
endif
def : _qualified_env_Namespace() : lookup::LookupEnvironment =
let env = lookup::LookupEnvironment{}
in env
.addElements(ownedClasses)
-- FIXME manual addition -> Fix the CS2AS OclGen
.addElements(ownedPackages)
-- END OF manual addition
def : lookupQualifiedNamespace(aPathElementCS : cs::PathElementCS) : Namespace[?] =
_lookupQualifiedNamespace(aPathElementCS.name)
def : _lookupQualifiedPackage(pName : String) : Package[?] =
let foundPackage = _lookupPackage(_qualified_env_Package(), pName)
in if foundPackage->isEmpty()
then null
else foundPackage->first()
endif
def : _qualified_env_Package() : lookup::LookupEnvironment =
let env = lookup::LookupEnvironment{}
in env
.addElements(ownedPackages)
def : lookupQualifiedPackage(aPathElementCS : cs::PathElementCS) : Package[?] =
_lookupQualifiedPackage(aPathElementCS.name)
-- FIXME Code suppressed since it's unnecessarily generated twice -> Fix the CS2AS OclGen
-- END OF SUPRESSION
def : _unqualified_env_Class(child : ocl::OclElement) : lookup::LookupEnvironment =
parentEnv_Class().nestedEnv()
.addElements(ownedClasses)
def : _unqualified_env_Namespace(child : ocl::OclElement) : lookup::LookupEnvironment =
parentEnv_Namespace().nestedEnv()
.addElements(ownedClasses)
def : _exported_env_Class(importer : ocl::OclElement) : lookup::LookupEnvironment =
let env = lookup::LookupEnvironment {}
in env
.addElements(ownedClasses)
def : _exported_env_Package(importer : ocl::OclElement) : lookup::LookupEnvironment =
let env = lookup::LookupEnvironment {}
in env
.addElements(ownedPackages)
def : _lookupExportedClass(importer : ocl::OclElement, cName : String) : Class[?] =
let foundClass = _lookupClass(_exported_env_Class(importer), cName)
in if foundClass->isEmpty()
then null
else foundClass->first()
endif
def : lookupExportedClass(importer : ocl::OclElement, aPathElementCS : cs::PathElementCS) : Class[?] =
_lookupExportedClass(importer, aPathElementCS.name)
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, aPathElementCS : cs::PathElementCS) : Package[?] =
_lookupExportedPackage(importer, aPathElementCS.name)
context Visitable
-- Variable lookup
def : _lookupVariable(env : lookup::LookupEnvironment, vName : String) : OrderedSet(Variable) =
let foundVariable = env.namedElements->selectByKind(Variable)->select(name = vName)
in if foundVariable->isEmpty() and not (env.parentEnv = null)
then _lookupVariable(env.parentEnv, vName)
else foundVariable
endif
-- Note: when calling this method, the source element of the argument passed to this method, will be the contextual
-- object on which error reports will be handled
def : _lookupUnqualifiedVariable(vName : String) : Variable[?] =
let foundVariable = _lookupVariable(unqualified_env_Variable(), vName)
in if foundVariable->isEmpty()
then null
else foundVariable->first() -- LookupVisitor will report ambiguous result
endif
def : lookupVariable(aPathElementCS : cs::PathElementCS) : Variable[?] =
_lookupUnqualifiedVariable(aPathElementCS.name)
-- FIXME manually added
def : lookupVariable(vName : String) : Variable[?] =
_lookupUnqualifiedVariable(vName)
-- END OF manual addition
-- Namespace lookup
def : _lookupNamespace(env : lookup::LookupEnvironment, nName : String) : OrderedSet(Namespace) =
let foundNamespace = env.namedElements->selectByKind(Namespace)->select(name = nName)
in if foundNamespace->isEmpty() and not (env.parentEnv = null)
then _lookupNamespace(env.parentEnv, nName)
else foundNamespace
endif
-- Note: when calling this method, the source element of the argument passed to this method, will be the contextual
-- object on which error reports will be handled
def : _lookupUnqualifiedNamespace(nName : String) : Namespace[?] =
let foundNamespace = _lookupNamespace(unqualified_env_Namespace(), nName)
in if foundNamespace->isEmpty()
then null
else foundNamespace->first() -- LookupVisitor will report ambiguous result
endif
def : lookupNamespace(aPathElementCS : cs::PathElementCS) : Namespace[?] =
_lookupUnqualifiedNamespace(aPathElementCS.name)
-- FIXME manually modified
-- QN Namespace lookup
def : lookupNamespace(aPathNameCS : cs::PathNameCS) : Namespace[?] =
lookupNamespace(aPathNameCS .ownedPathElements)
def : lookupNamespace(segments : OrderedSet(cs::PathElementCS)) : Namespace[?] =
if segments->size() = 1
then lookupNamespace(segments->first())
else let qualifierSegments = segments->subOrderedSet(1,segments->size()-1),
qualifier = lookupNamespace(qualifierSegments)
in qualifier?.lookupQualifiedNamespace(segments->last())
endif
-- ENDOF manual modification
-- Behavior lookup
def : _lookupBehavior(env : lookup::LookupEnvironment, bName : String) : OrderedSet(Behavior) =
let foundBehavior = env.namedElements->selectByKind(Behavior)->select(name = bName)
in if foundBehavior->isEmpty() and not (env.parentEnv = null)
then _lookupBehavior(env.parentEnv, bName)
else foundBehavior
endif
-- Note: when calling this method, the source element of the argument passed to this method, will be the contextual
-- object on which error reports will be handled
def : _lookupUnqualifiedBehavior(bName : String) : Behavior[?] =
let foundBehavior = _lookupBehavior(unqualified_env_Behavior(), bName)
in if foundBehavior->isEmpty()
then null
else foundBehavior->first() -- LookupVisitor will report ambiguous result
endif
def : lookupBehavior(aPathElementCS : cs::PathElementCS) : Behavior[?] =
_lookupUnqualifiedBehavior(aPathElementCS.name)
-- Class lookup
def : _lookupClass(env : lookup::LookupEnvironment, cName : String) : OrderedSet(Class) =
let foundClass = env.namedElements->selectByKind(Class)->select(name = cName)
in if foundClass->isEmpty() and not (env.parentEnv = null)
then _lookupClass(env.parentEnv, cName)
else foundClass
endif
-- Note: when calling this method, the source element of the argument passed to this method, will be the contextual
-- object on which error reports will be handled
def : _lookupUnqualifiedClass(cName : String) : Class[?] =
let foundClass = _lookupClass(unqualified_env_Class(), cName)
in if foundClass->isEmpty()
then null
else foundClass->first() -- LookupVisitor will report ambiguous result
endif
def : lookupClass(aPathElementCS : cs::PathElementCS) : Class[?] =
_lookupUnqualifiedClass(aPathElementCS.name)
-- FIXME manually added
def : lookupClass(cName : String) : Class[?] =
_lookupUnqualifiedClass(cName)
-- END OF manual addition
-- QN Class lookup
def : lookupClass(aPathNameCS : cs::PathNameCS) : Class[?] =
lookupClass(aPathNameCS .ownedPathElements)
def : lookupClass(segments : OrderedSet(cs::PathElementCS)) : Class[?] =
if segments->size() = 1
then lookupClass(segments->first())
else let qualifierSegments = segments->subOrderedSet(1,segments->size()-1),
qualifier = lookupPackage(qualifierSegments)
in qualifier?.lookupQualifiedClass(segments->last())
endif
-- Class exports Operation
def : lookupOperationFrom(exporter : Class, aPathElementCS : cs::PathElementCS, argTypes : OrderedSet(Type)) : Operation[?] =
exporter.lookupExportedOperation(self, aPathElementCS, argTypes)
def : lookupOperationFrom(exporter : Class, aPathNameCS : cs::PathNameCS, argTypes : OrderedSet(Type)) : Operation[?] =
lookupOperationFrom(exporter, aPathNameCS.ownedPathElements, argTypes)
def : lookupOperationFrom(exporter : Class, segments : OrderedSet(cs::PathElementCS), argTypes : OrderedSet(Type)) : Operation[?] =
if segments->size() = 1
then lookupOperationFrom(exporter, segments->first(), argTypes)
else let qualifierSegments = segments->subOrderedSet(1,segments->size()-1),
qualifier = lookupClass(qualifierSegments)
in qualifier?.lookupQualifiedOperation(segments->last(), argTypes)
endif
-- EnumerationLiteral lookup
def : _lookupEnumerationLiteral(env : lookup::LookupEnvironment, eName : String) : OrderedSet(EnumerationLiteral) =
let foundEnumerationLiteral = env.namedElements->selectByKind(EnumerationLiteral)->select(name = eName)
in if foundEnumerationLiteral->isEmpty() and not (env.parentEnv = null)
then _lookupEnumerationLiteral(env.parentEnv, eName)
else foundEnumerationLiteral
endif
-- Note: when calling this method, the source element of the argument passed to this method, will be the contextual
-- object on which error reports will be handled
def : _lookupUnqualifiedEnumerationLiteral(eName : String) : EnumerationLiteral[?] =
let foundEnumerationLiteral = _lookupEnumerationLiteral(unqualified_env_EnumerationLiteral(), eName)
in if foundEnumerationLiteral->isEmpty()
then null
else foundEnumerationLiteral->first() -- LookupVisitor will report ambiguous result
endif
def : lookupEnumerationLiteral(aPathElementCS : cs::PathElementCS) : EnumerationLiteral[?] =
_lookupUnqualifiedEnumerationLiteral(aPathElementCS.name)
-- Model exports Package
def : lookupPackageFrom(exporter : Model, aPathElementCS : cs::PathElementCS) : Package[?] =
exporter.lookupExportedPackage(self, aPathElementCS)
def : lookupPackageFrom(exporter : Model, aPathNameCS : cs::PathNameCS) : Package[?] =
lookupPackageFrom(exporter, aPathNameCS.ownedPathElements)
def : lookupPackageFrom(exporter : Model, 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
-- Operation lookup
def : _lookupOperation(env : lookup::LookupEnvironment, oName : String, argTypes : OrderedSet(Type)) : OrderedSet(Operation) =
let foundOperation = env.namedElements->selectByKind(Operation)->select(name = oName)
->select(_appliesFilter_Operation(argTypes))
in if foundOperation->isEmpty() and not (env.parentEnv = null)
then _lookupOperation(env.parentEnv, oName, argTypes)
else foundOperation
endif
-- Note: when calling this method, the source element of the argument passed to this method, will be the contextual
-- object on which error reports will be handled
def : _lookupUnqualifiedOperation(oName : String, argTypes : OrderedSet(Type)) : Operation[?] =
let foundOperation = _lookupOperation(unqualified_env_Operation(), oName, argTypes)
in if foundOperation->isEmpty()
then null
else foundOperation->first() -- LookupVisitor will report ambiguous result
endif
def : lookupOperation(aPathElementCS : cs::PathElementCS, argTypes : OrderedSet(Type)) : Operation[?] =
_lookupUnqualifiedOperation(aPathElementCS.name, argTypes)
-- QN Operation lookup
def : lookupOperation(aPathNameCS : cs::PathNameCS, argTypes : OrderedSet(Type)) : Operation[?] =
lookupOperation(aPathNameCS .ownedPathElements, argTypes)
def : lookupOperation(segments : OrderedSet(cs::PathElementCS), argTypes : OrderedSet(Type)) : Operation[?] =
if segments->size() = 1
then lookupOperation(segments->first(), argTypes)
else let qualifierSegments = segments->subOrderedSet(1,segments->size()-1),
qualifier = lookupClass(qualifierSegments)
in qualifier?.lookupQualifiedOperation(segments->last(), argTypes)
endif
-- Package lookup
def : _lookupPackage(env : lookup::LookupEnvironment, pName : String) : OrderedSet(Package) =
let foundPackage = env.namedElements->selectByKind(Package)->select(name = pName)
in if foundPackage->isEmpty() and not (env.parentEnv = null)
then _lookupPackage(env.parentEnv, pName)
else foundPackage
endif
-- Note: when calling this method, the source element of the argument passed to this method, will be the contextual
-- object on which error reports will be handled
def : _lookupUnqualifiedPackage(pName : String) : Package[?] =
let foundPackage = _lookupPackage(unqualified_env_Package(), pName)
in if foundPackage->isEmpty()
then null
else foundPackage->first() -- LookupVisitor will report ambiguous result
endif
def : lookupPackage(aPathElementCS : cs::PathElementCS) : Package[?] =
_lookupUnqualifiedPackage(aPathElementCS.name)
-- QN Package lookup
def : lookupPackage(aPathNameCS : cs::PathNameCS) : Package[?] =
lookupPackage(aPathNameCS .ownedPathElements)
def : lookupPackage(segments : OrderedSet(cs::PathElementCS)) : Package[?] =
if segments->size() = 1
then lookupPackage(segments->first())
else let qualifierSegments = segments->subOrderedSet(1,segments->size()-1),
qualifier = lookupPackage(qualifierSegments)
in qualifier?.lookupQualifiedPackage(segments->last())
endif
-- Package exports Class
def : lookupClassFrom(exporter : Package, aPathElementCS : cs::PathElementCS) : Class[?] =
exporter.lookupExportedClass(self, aPathElementCS)
def : lookupClassFrom(exporter : Package, aPathNameCS : cs::PathNameCS) : Class[?] =
lookupClassFrom(exporter, aPathNameCS.ownedPathElements)
def : lookupClassFrom(exporter : Package, segments : OrderedSet(cs::PathElementCS)) : Class[?] =
if segments->size() = 1
then lookupClassFrom(exporter, segments->first())
else let qualifierSegments = segments->subOrderedSet(1,segments->size()-1),
qualifier = lookupPackage(qualifierSegments)
in qualifier?.lookupQualifiedClass(segments->last())
endif
-- Package exports Package
def : lookupPackageFrom(exporter : Package, aPathElementCS : cs::PathElementCS) : Package[?] =
exporter.lookupExportedPackage(self, aPathElementCS)
def : lookupPackageFrom(exporter : Package, aPathNameCS : cs::PathNameCS) : Package[?] =
lookupPackageFrom(exporter, aPathNameCS.ownedPathElements)
def : lookupPackageFrom(exporter : Package, 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
-- Precedence lookup
def : _lookupPrecedence(env : lookup::LookupEnvironment, pName : String) : OrderedSet(Precedence) =
let foundPrecedence = env.namedElements->selectByKind(Precedence)->select(name = pName)
in if foundPrecedence->isEmpty() and not (env.parentEnv = null)
then _lookupPrecedence(env.parentEnv, pName)
else foundPrecedence
endif
-- Note: when calling this method, the source element of the argument passed to this method, will be the contextual
-- object on which error reports will be handled
def : _lookupUnqualifiedPrecedence(pName : String) : Precedence[?] =
let foundPrecedence = _lookupPrecedence(unqualified_env_Precedence(), pName)
in if foundPrecedence->isEmpty()
then null
else foundPrecedence->first() -- LookupVisitor will report ambiguous result
endif
def : lookupPrecedence(aPathElementCS : cs::PathElementCS) : Precedence[?] =
_lookupUnqualifiedPrecedence(aPathElementCS.name)
-- Property lookup
def : _lookupProperty(env : lookup::LookupEnvironment, pName : String) : OrderedSet(Property) =
let foundProperty = env.namedElements->selectByKind(Property)->select(name = pName)
in if foundProperty->isEmpty() and not (env.parentEnv = null)
then _lookupProperty(env.parentEnv, pName)
else foundProperty
endif
-- Note: when calling this method, the source element of the argument passed to this method, will be the contextual
-- object on which error reports will be handled
def : _lookupUnqualifiedProperty(pName : String) : Property[?] =
let foundProperty = _lookupProperty(unqualified_env_Property(), pName)
in if foundProperty->isEmpty()
then null
else foundProperty->first() -- LookupVisitor will report ambiguous result
endif
def : lookupProperty(aPathElementCS : cs::PathElementCS) : Property[?] =
_lookupUnqualifiedProperty(aPathElementCS.name)
-- QN Property lookup
def : lookupProperty(aPathNameCS : cs::PathNameCS) : Property[?] =
lookupProperty(aPathNameCS .ownedPathElements)
def : lookupProperty(segments : OrderedSet(cs::PathElementCS)) : Property[?] =
if segments->size() = 1
then lookupProperty(segments->first())
else let qualifierSegments = segments->subOrderedSet(1,segments->size()-1),
qualifier = lookupClass(qualifierSegments)
in qualifier?.lookupQualifiedProperty(segments->last())
endif
endpackage