[Custom Language] How to create reference contributor for an element with stub
已回答
In the stub tutorial, if i want to create a stub for an element, the element need extend StubBasedPsiElementBase<XXXElementStub>. But the reference contributor tutorial tells the element need extend XXXNamedElementImpl. Is this conflict?
The stub tutorial: Stub Indexes | IntelliJ Platform Plugin SDK (jetbrains.com)
The reference tutorial: 10. Reference Contributor | IntelliJ Platform Plugin SDK (jetbrains.com)
请先登录再写评论。
Hi,
Please clarify what you mean. StubBasedPsiElementBase is a class, and PsiNameIdentifierOwner is an interface. You can extend a class and implement an interface at the same time. I don't see any conflict.
If it's not what you mean, then clarify the case.
Hi karol,
Yes, the PsiNameIdentifierOwner is an interface, but the tutorial i need to create an abstract class to implement it.
in the reference contributor tutorial, i add the "mixin" to my code and generate.
Then the element extends SimpleNamedElementImpl. At the same time, the element need extend StubBasedPsiElementBase to accomplish the stub index
Implement a stub class, make your mixin extend StubBasedPsiElementBase<...>, and include stub class to the property rule:
Can I ask for what the functional result of this is? I'm not using gammar-kit anymore and encountered the same issue.
MyPsiElement implements PsiNamedElement for reference and within MyStubElementType I'm not sure how to implement
In regular cases this is solved as MyPsiElement extends StubBasedPsiElementBase that has constructor accepting a stub
But since I'm extending PsiNamedElement I cannot extend StubBasedElementBase and have no idea how to implement that createPsi