xtext importURI外部文件 [英] xtext importURI external file

查看:318
本文介绍了xtext importURI外部文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我非常失望,导入全球范围是如何工作的。我正在为一个井结构语言编写一个带有xtext的解析器,我不能依赖于工作空间或项目概念。在我的语言中,我有包含可以具有另一个文件的相对或相似路径的语句。我需要能够引用在这个其他文件中定义的对象。我尝试使用importURI,但它不工作。我试过的是添加这个规则:

  Include:
'INCLUDE''='importURI = STRING' '
;

并更改了这些部分的MWE2文件:

  //范围和导出API 
fragment = scoping.ImportURIScopingFragment {}
// fragment = exporting.SimpleNamesFragment {}

//范围和导出API
fragment = scoping.ImportNamespacesScopingFragment {}
fragment = exporting.QualifiedNamesFragment {}

但是这在编辑器中没有任何影响。我仍然可以引用在每个文件中定义的对象,具有相同的扩展名,而没有include语句,我仍然不能在项目之外包含文件。

解决方案

解决方案是从工作流程中删除这两个。

  //为java类型集成提供必要的绑定
// fragment = types.TypesGeneratorFragment {}

//只有当语法从Xbase
继承时才产生所需的绑定// fragment = xbase.XbaseGeneratorFragment {}


i am very lost with how importing global scope is working. I am writing a parser with xtext for a well structure language and I cannot depend on workspace or project concepts. In my language I have include statements which can have relative or absoloute paths of another file. I need to be able to reference objects defined in this other file. I tried using importURI but it doesn't work. All I tried was to add this rule:

Include:
    'INCLUDE' '='  importURI=STRING ';'
;

and changed the MWE2 file in these parts:

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

                // scoping and exporting API
                fragment = scoping.ImportNamespacesScopingFragment {}
                fragment = exporting.QualifiedNamesFragment {}

But this doesn't make any effect in my editor. I still can refer to objects defined in every file with the same extension without having the include statements, and I still cannot include files outside of the project.

解决方案

the solution was to remove these two from workflow.

 // provides the necessary bindings for java types integration
 // fragment = types.TypesGeneratorFragment {}

 // generates the required bindings only if the grammar inherits from Xbase
 //fragment = xbase.XbaseGeneratorFragment {}

这篇关于xtext importURI外部文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆