[英]Xtext cross-reference across all files in project
I am making a very simple DSL with xtext. 我正在用xtext做一个非常简单的DSL。 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: File1.ex:
[MESSAGE_DEF] EXAMPLE_1
[MESSAGE_DEF] EXAMPLE_2
[MESSAGE_USAGE] EXAMPLE_1
File2.ex: 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. 在此示例中,EXAMPLE_1的交叉引用的工作方式是使用法上的“打开声明”将我带到定义。 However, the cross-reference on EXAMPLE_2 does not work.
但是,EXAMPLE_2上的交叉引用无效。 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. 该项目是使用标准向导中的“ Xtext Project”创建的,我只从预生成的代码中编辑了语法,其他所有内容均与默认设置相同。 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 如果您的语法和作用域很好,它将很好地工作
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.