-
Notifications
You must be signed in to change notification settings - Fork 103
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Don't include declarations in usages (fixes #629). #649
Don't include declarations in usages (fixes #629). #649
Conversation
@bjansen Sorry for bothering you. I don't know who should I ping to approve the workflow. |
7227cbc
to
01ba5a6
Compare
I'll look into it this week, sorry for the delay |
@@ -29,6 +29,7 @@ public class ANTLRv4ASTFactory extends ASTFactory { | |||
ruleElementTypeToPsiFactory.put(ANTLRv4TokenTypes.RULE_ELEMENT_TYPES.get(ANTLRv4Parser.RULE_modeSpec), ModeSpecNode.Factory.INSTANCE); | |||
ruleElementTypeToPsiFactory.put(ANTLRv4TokenTypes.RULE_ELEMENT_TYPES.get(ANTLRv4Parser.RULE_action), AtAction.Factory.INSTANCE); | |||
ruleElementTypeToPsiFactory.put(ANTLRv4TokenTypes.RULE_ELEMENT_TYPES.get(ANTLRv4Parser.RULE_identifier), TokenSpecNode.Factory.INSTANCE); | |||
ruleElementTypeToPsiFactory.put(ANTLRv4TokenTypes.RULE_ELEMENT_TYPES.get(ANTLRv4Parser.RULE_tokensSpec), TokensSpecNode.Factory.INSTANCE); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
||
public class LexerRuleRefNode extends GrammarElementRefNode { | ||
public LexerRuleRefNode(IElementType type, CharSequence text) { | ||
super(type, text); | ||
} | ||
|
||
@Override | ||
public PsiReference getReference() { | ||
return new GrammarElementRef(this, getText()); | ||
protected boolean isDeclaration() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would have kept getReference()
here and simply add this snippet:
if (getParent() instanceof LexerRuleSpecNode || getParent() instanceof TokenSpecNode) {
// A declaration doesn't need to reference itself
return null;
}
(same in ParserRuleRefNode
)
Signed-off-by: Ilya Rodionov <[email protected]>
01ba5a6
to
9cb8554
Compare
@bjansen I've made the requested changes. Upd: I've also added |
Thanks for the contribution! |
No description provided.