Cheapest way to traverse a model [message #1694602] |
Wed, 06 May 2015 11:08  |
Eclipse User |
|
|
|
Hi all,
I've calculated my local-scope inside of modelled operations with recursive dispatched methods by traversion the eContainer-reference.
This works like this:
def dispatch IScope defBefore(LocalVar var, EObject o){
val scopeList = newArrayList().add(var)
//walk upwards
Scopes::scopeFor(scopeList, var.eContainer.defBefore(o) )
}
def dispatch IScope defBefore(EObject obj, o){
Scopes::scopeFor(scopeList, obj.eContainer.defBefore(o) )
}
def dispatch IScope defBefore(Operation op, EObject o){
val scopeList = op.params
// end of recursion
Scopes::scopeFor(scopeList)
}
Now I recognized that I need some more elements in my scope, which are outside of operations ( for ex. Datatypes). I thought about adding an other dispatched rule, which walks until the root-element and then call the:
Scopes::scopeFor(EcoreUtil2.getAllContentsOfType(modelRoot, typeof(Datatype)))
But I'm not sure how expensive this operation will be for me, cause the scope (lokal) is build after every model-change...
Some advices would be great!
~Alex
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03987 seconds