Reputation: 209
I am making a very simple DSL with xtext. A project will contain files that either define a message name, or reference to one. I have included a simplified example:
Grammar:
Model:
statements+=(MessageDefinition | MessageUsage)*;
MessageDefinition:
'[MESSAGE_DEF]' name=ID;
MessageUsage:
'[MESSAGE_USAGE]' usage=[MessageDefinition];
File1.ex:
[MESSAGE_DEF] EXAMPLE_1
[MESSAGE_DEF] EXAMPLE_2
[MESSAGE_USAGE] EXAMPLE_1
File2.ex:
[MESSAGE_USAGE] EXAMPLE_2
In this example the cross-reference from EXAMPLE_1 works such that "Open Declaration" on the usage takes me to the definition. However, the cross-reference on EXAMPLE_2 does not work. I think the default scoping rules prevents different files from sharing references.
What do i need to add so that all the files in a project share the same global scope for cross-references?
Additional information:
The project was created using "Xtext Project" in the standard wizard, I have only edited the grammar from the pre-generated code, everything else is as-per the defaults. I thought I would need to add some custom scoping behaviour/rules to load all files into the global scope, but I am not sure how this is supposed to be done?
Upvotes: 1
Views: 1284
Reputation: 11868
it will work fine with your grammar and scoping if you
Upvotes: 2