xtext importURI external file

旧时模样 提交于 2020-01-17 03:59:17

问题


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.


回答1:


You have to remove the ImportNamespacesScopingFragment. It configures your language to use name based scopes rather than file-based.

You may also want to dig into the IContainer.Manager which is configured with an implementation based on the Eclipse workspace and project concept, by default.




回答2:


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 {}


来源:https://stackoverflow.com/questions/17034734/xtext-importuri-external-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!