Every time I try to access the context object in the ScopeProvider
, I'll get a "cyclic resolution of lazy links" error or my ScopeProvider
will be fully ignored and the default scope is used.
Heres a small example grammar:
grammar org.xtext.example.mydsl.MyDsl with org.eclipse.xtext.common.Terminals
generate myDsl "http://www.xtext.org/example/mydsl/MyDsl"
Model:
(greetings+=Greeting)*
(farewells+=Farewell)*;
Greeting:
'Hello' name=ID '!';
Farewell:
'Bye' name=[Greeting] '.';
This is the ScopeProvider:
class MyDslScopeProvider extends org.eclipse.xtext.scoping.impl.AbstractDeclarativeScopeProvider {
def scope_Farewell_name(Farewell context,EReference reference){
System.out.println(context.name);
return IScope::NULLSCOPE
}
}
Is there something wrong in my approach?
Why I want to access the context:
Im trying to create an Editor for the GLSL shading language. Ill need to distinguish between a struct member and a field selection operator: Example:
struct Test{
vec4 x;
};
Test s;
s.x.x=5.0;
The first x
is the struct member and the 2nd one is the x-coordinate of the vector.