Xtext 交叉引用和作用域 [英] Xtext cross referencing and scoping

查看:29
本文介绍了Xtext 交叉引用和作用域的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 xtext 交叉引用方面遇到了一些问题这是一个非常简单的语法:

I have some problems with xtext cross referencing Here is a very simple grammer:

grammar org.xtext.example.mydsl1.Test with org.eclipse.xtext.common.Terminals
generate test "http://www.xtext.org/example/mydsl1/Test"
Model: block=Block? cs+=Company* ; 
Block:  '{' g=[Employee] '}';
Company: 'Company' name=ID
    '{' es+= Employee* '}';
Employee: 'Employee' name=ID ';' ;

这是我的 dsl :

{ Pooyan }
Company Sony{
    Employee Pooyan;
    Employee John;
}

它总是显示无法解析对员工‘Pooyan’的引用."有人可以帮我吗?我不知道...

It always shown that "Couldn't resolve reference to Employee 'Pooyan'." Could anyone please help me? I have no idea...

推荐答案

Pooyan 的完全限定名称是 Sony.Pooyan.由于块中的交叉引用g"是在另一个包含中定义的,因此您必须进行少量自定义以将其放入范围.

The fully qualified name of Pooyan is Sony.Pooyan. Since the cross reference 'g' in your block is defined in another contain, you have to do a minor customizing to put it onto the scope.

  1. 如果您的语言始终使用平面命名空间,您可以在语言生成器中启用 SimpleNamesFragment 并删除 QualifiedNamesFragment.这应该可以解决问题.
  2. 或者,您可以在范围提供程序中自定义具体引用g"的范围.

这篇关于Xtext 交叉引用和作用域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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