I started developing an XText DSL, which has now two sub-languages, which reference each other (to be more precise, A refers to B). They each have their own plugins, and generator workflow.
The relevant part of looks something like this:
Language A:
ARoot:
'rootOfB:' (foos+=Foo)*;
Foo:
'foo' name=ID;
Language B:
import 'url-of-a' as A
BRoot:
'rootOfA:' (bars+=Bar)*;
Bar:
'bar' name=ID 'for' foo=[A::Foo] ;
Now I try to provide a scope provider, so that in language B foo elements are recognized, but i did not find a way yet to get access to the parsed elements of A.
I did some debugging, and it looks like neither the parameter foo, nor the eReference has any kind of connection to the elements of language A:
class MyScopeProvider extends AbstractDeclarativeScopeProvider {
def IScope scope_Bar_foo(Bar bar, EReference eReference){
// How should i reference and return all the Foo objects here?
}
}
Foo elements also have a full-qualified name provider, so that shouldn't be a problem, i tested it from another scope, while still working on plugin A:
class MyQualifiedNameProvider extends DefaultDeclarativeQualifiedNameProvider {
override qualifiedName(Object o) {
if (o instanceof Foo) {
val f = o as Foo
return QualifiedName.create(f.name)
}
super.qualifiedName(o);
}
}
So my question is: How would i get the parsed EObjects in the a different plugin?
Example usage:
Contents of a file, that uses grammar A:
rootOfA
foo firstFoo
foo secondFoo
Contents of a file, that uses grammar B:
rootOfB
bar firstBar for [i would like reference firstFoo or secondFoo here]