禁用语法错误“ Symbol< id>”无法解决”使用CDT的Eclipse插件中的一些符号 [英] Disable Syntax Error "Symbol <id> could not be resolved" for some symbols in Eclipse Plugin using CDT

查看:90
本文介绍了禁用语法错误“ Symbol< id>”无法解决”使用CDT的Eclipse插件中的一些符号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的eclipse插件中,我想支持我的工具的语言,该语言用一些关键字和概念扩展了C ++。我的语言类,编辑器类和源解析器类都继承了C ++的CDT类。我可以解析关键字并将其节点添加到AST。但是我的一些关键字/命令编辑器将始终标记为无法解决符号。

In my eclipse plugin I want to support my tool's language which extends C++ with some keywords and concepts. My language class, editor class and source parser class are all inheriting CDT classes for C++. I can parse the keywords and add nodes for them to the AST. But some of my keywords/commands the editor will always mark as "Symbol could not be resolved".

示例:
有一个命令 @result wich返回最后一次计算的结果,作为在工具核心的某些头文件中定义的枚举值。

Example: There is a command "@result" wich returns the result of a last computation as an enum value that is defined in some header file in the tool's core.

typedef enum {
    OK = 0;
    WARNING = 1;
    ERROR = 2;
} errCode_t;

因此,命令 @result 返回0, 1或2。但是在编辑器中,命令标记为无法解析符号'@result'。不,我不想告诉索引器不要尝试解析此令牌。

So the command @result returns 0, 1 or 2. But inside the editor the command is marked as Symbol '@result' could not be resolved. No I want to tell the Indexer to not try to resolve this very token.

在Preprocessor类中,我可以将令牌类型从 IToken更改。 tIDENTIFIER 到例如50000。我试图达到的目标是

In the Preprocessor class I could change the token type from IToken.tIDENTIFIER to, say, 50000. What I try to achieve by that is something like

if (token.getType() == 50000) {
    // don't try to resolve symbol
    return null;
} else {
    return super.resolveSymbol();
}

有没有办法做到这一点?我认为我的第一个问题是我不了解由谁或什么负责语法错误标记(也许是索引器?)。

Is there a way to do that? I think my first problem is that I don't understand who or what is responsible for the Syntax Error Marking (maybe the Indexer?).

推荐答案

格式为 Symbol ...无法解决的错误由CDT的代码分析组件产生,特别是 ProblemBindingChecker ,它遍历AST并报告任何解析的 IASTName 的错误(通过 IASTName.resolveBinding())到 ProblemBinding

Errors of the form Symbol ... could not be resolved are produced by CDT's Code Analysis component, specifically ProblemBindingChecker, which traverses the AST and reports the error for any IASTName which resolves (via IASTName.resolveBinding()) to a ProblemBinding.

它只是 IASTName 节点解决绑定问题,因此,如果您的 @result 令牌出现此错误,则表明解析器正在构建 IASTName 它的节点。如果您更改了令牌类型,我不确定会如何发生,我想这取决于您如何在扩展解析器中处理新令牌类型。

It is only IASTName nodes which resolve to bindings, so if you are getting this error for your @result token, that suggests the parser is building an IASTName node for it. I'm not sure how that's happening if you've changed the token type, I suppose it depends on how you handle the new token type in your extended parser.

这篇关于禁用语法错误“ Symbol< id>”无法解决”使用CDT的Eclipse插件中的一些符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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