问题
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".
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;
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.
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?).
回答1:
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
.
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.
来源:https://stackoverflow.com/questions/57112132/disable-syntax-error-symbol-id-could-not-be-resolved-for-some-symbols-in-ecl