Xtext 中的作用域和导入

发布于 2025-01-08 09:43:28 字数 845 浏览 3 评论 0原文

我有以下 Xtext 语法:

Model:
    'model' name = ID imports += Import* items += Item* rules += Rule*;

Import:
    'import' importURI = STRING;

Rule:
    'rule' name = ID '(' items += [Item]* ')';

Item:
    'item' name = ID;

打开编辑器时,Rule 中的所有 Item 引用如果位于同一文件中,都会正确突出显示,并且我可以跳转到使用 F3 进行声明。但是,如果我尝试从其他文件导入它们,这将不起作用。例如:

文件 first.mydsl

model first
import "second.mydsl"
rule myRule (second) 

文件 second.mydsl

model second
item second

假设这两个文件位于同一文件夹中,它仍然无法从导入的文件中找到“第二个”引用。如果我包含导入文件的文件扩展名或完整路径,它也不起作用。 如何让 Xtext 识别导入的文件?

(交叉发布到 http://www.eclipse.org/forums/index .php/m/805182/#msg_805182)

I've got the following Xtext grammar:

Model:
    'model' name = ID imports += Import* items += Item* rules += Rule*;

Import:
    'import' importURI = STRING;

Rule:
    'rule' name = ID '(' items += [Item]* ')';

Item:
    'item' name = ID;

When opening the editor, all Item references in Rules are hilighted correctly if they are in the same file, and I can jump to the declaration using F3. However, that doesn't work if I try to import them from other files. For example:

File first.mydsl

model first
import "second.mydsl"
rule myRule (second) 

File second.mydsl

model second
item second

Assuming these two files are in the same folder, it still won't find the 'second' reference from the imported file. It also doesn't work if I include the file extension for the imported file, or the full path.
How do I get Xtext to recognize the imported file?

(crossposted to http://www.eclipse.org/forums/index.php/m/805182/#msg_805182)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

油焖大侠 2025-01-15 09:43:28

请确保按如下方式配置您的工作流程

        // scoping and exporting API
        fragment = scoping.ImportURIScopingFragment {}
        fragment = exporting.SimpleNamesFragment {}

        // scoping and exporting API
        // fragment = scoping.ImportNamespacesScopingFragment {}
        // fragment = exporting.QualifiedNamesFragment {}
        // fragment = builder.BuilderIntegrationFragment {}
        ....
        // fragment = types.TypesGeneratorFragment {}

please make sure you configure your workflow as follows

        // scoping and exporting API
        fragment = scoping.ImportURIScopingFragment {}
        fragment = exporting.SimpleNamesFragment {}

        // scoping and exporting API
        // fragment = scoping.ImportNamespacesScopingFragment {}
        // fragment = exporting.QualifiedNamesFragment {}
        // fragment = builder.BuilderIntegrationFragment {}
        ....
        // fragment = types.TypesGeneratorFragment {}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文