Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/api/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Antlr Xtext:将快速修复重写为引用_Antlr_Xtext - Fatal编程技术网

Antlr Xtext:将快速修复重写为引用

Antlr Xtext:将快速修复重写为引用,antlr,xtext,Antlr,Xtext,我试图检测赋值的右侧是否是一个可能的十六进制值,而不是另一个变量引用。比如说 myvariable = 2 a = 4 /* the c reference does not exist therefore the user may mean hex C add in a quickfix to change to 0xc */ b = c /* The user most probably means a hex number therefore add in a quickfix for

我试图检测赋值的右侧是否是一个可能的十六进制值,而不是另一个变量引用。比如说

myvariable = 2

a = 4
/* the c reference does not exist therefore the user may mean hex C
add in a quickfix to change to 0xc
*/
b = c
/* The user most probably means a hex number therefore add in a quickfix for
converting it to 0xc1234 */
d = c1234
因此,右边可以是(a-f)或(a-z)(a-z | 0-9 | | | | |)+实际上是一个ID。当变量不存在时,有一个快速修复程序,它表示“更改为存在的任何其他变量”。是否有方法覆盖此选项并添加其他选项

编辑: 我从这一点出发,进行了自己的自定义验证,以检查while循环中是否存在如下引用:

try{
    while(variable != null) {
        variable = variable.reference
    }
catch(Exception e) {
   error("No such reference exists",
         ....
   )
}
由于变量为null,因此在访问variable.reference时引发异常。然而,我无法在右边得到参考的名称。 例如:

c = 1
a = x
然后当访问引用x时,我得到一个空值,我不知道如何获得名称“x”。似乎xtext已经找到并解析了引用,我找不到一种方法来获取引用的名称(解析时除外)


是否有方法获取引用的变量名(在解析之前)?

请查看org.eclipse.xtext.ui.editor.quickfix.DefaultQuickfixProvider.getResolutionsForLinkingIssue(问题)