Why do PSI element types have to have a separate interface and an implementation class?
I don't use GrammarKit BNF in my custom language parser, so I create the PSI element type classes manually, and I don't want to spend the effort creating two files for the same element type. Is there any reason or restriction?
In addition, I am writing a reference contributor, but PlatformPatterns.psiElement() is only matching the PsiComment elements in my file, where the PsiComments are the only non-custom element type used in my custom language (apart from whitespaces). I am not sure if this bug is related to not separating interfaces and implementations.
Please sign in to leave a comment.
There's no such restriction. One can use implementation classes directly.
Please add some snippets to illustrate the problems.
I even System.out.println() directly to check what elements I have traversed:
https://github.com/SOF3/libglocal-idea-plugin/blob/master/src/io/github/sof3/libglocal/idea/ref/LibglocalReferenceContributor.java#L19
No errors spotted in the event log, live idea.log (in IntelliJ's Run tool window) or main output. I'm using PhpStorm.
I used PsiViewer to make sure the file consists not only comment elements.
References are a completely different story.
Each psi implementation shall opt in for provided references explicitly.
See https://github.com/JetBrains/intellij-community/blob/master/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiLiteralExpressionImpl.java#L216
So the full steps are:
Thanks, this works.
But why aren't the first 2 steps mentioned in the tutorial?