You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While the referencing element and the referenced element both may have a name, only the element which introduces the name (e.g., the definition int x = 42) needs to implement PsiNamedElement. The referencing element at the point of usage (e.g., the x in the expression x + 1) should not implement PsiNamedElement since it does not have a name.
I based my leaf node implementations on IdentifierPSINode, so I had my leaves implement PsiNamedElement. I just realized that this was causing a bug with "Find Usages". When searching for usages from a declaration, there were no results. Changing my leaves to not implement this interface fixed this problem.
Before I found this fix, I found the following workaround. I had my declaration be a reference to itself. In this case, "right-click -> Find Usages" works correctly, but "right-click -> Go To -> Declaration or Usages" does not. If there was only one usage, then the correct behavior would be to go to that usage. Instead, the behavior in this case is that the cursor moves to the beginning of the declaration (which is the current behavior for the current ANTLR plugin antlr/intellij-plugin-v4#580).
The text was updated successfully, but these errors were encountered:
IdentifierPSINode
is a leaf node in your AST, and it implementsPsiNamedElement
.jetbrains-plugin-sample/src/main/java/org/antlr/jetbrains/sample/psi/IdentifierPSINode.java
Line 39 in 0b8d515
It should not implement
PsiNamedElement
.The Custom Language tutorial says
I based my leaf node implementations on
IdentifierPSINode
, so I had my leaves implementPsiNamedElement
. I just realized that this was causing a bug with "Find Usages". When searching for usages from a declaration, there were no results. Changing my leaves to not implement this interface fixed this problem.Before I found this fix, I found the following workaround. I had my declaration be a reference to itself. In this case, "right-click -> Find Usages" works correctly, but "right-click -> Go To -> Declaration or Usages" does not. If there was only one usage, then the correct behavior would be to go to that usage. Instead, the behavior in this case is that the cursor moves to the beginning of the declaration (which is the current behavior for the current ANTLR plugin antlr/intellij-plugin-v4#580).
The text was updated successfully, but these errors were encountered: