Hello everyone,
I'd like to know how the default generated scoping provider class is supposed to be used. Earlier versions of XText used AbstractDeclarativeScopeProvider and that was quite easy to understand and use.
Let's say I have the following grammar:
grammar org.xtext.example.mydsl.MyDsl with org.eclipse.xtext.common.Terminals
generate myDsl "http://www.eclipse.org/example/mydsl/MyDsl"
Model:
((things+=Thing) | (refs+=Reference))*
;
Thing:
'thing' name=ID '{'
stuff += Stuff*
'}'
;
Stuff:
'stuff' name=ID
;
Reference:
'reference' thing=[Thing] stuff=[Stuff]
;
For the Reference clause to work, I need a scope provider.
XText 2.9 generates the following scope provider code for you (in MyDslScopeProvider.xtend):
class MyDslScopeProvider extends AbstractMyDslScopeProvider {
}
AbstractMyDslScopeProvider has no methods of it's own, it just inherits from DelegatingScopeProvider.
I can't wrap my head around how this works or where the code for the scope lookup should go. The "documentation" doesn't really help, because there's only useless code snippets instead of a complete working example.
Pre 2.9 it would have been:
class MyDslScopeProvider extends AbstractDeclarativeScopeProvider {
def IScope scope_Reference_stuff(Reference reference, EReference ref) {
scopeFor(reference.thing.stuff)
}
}
Can someone please enlighten me on how the new scope provider mechanism is supposed to be used?