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?
it will work fine with your grammar and scoping if you
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.