Custom Language Documentation for non existent Element
Answered
I want to implement the documentation provider for my custom language.
I understand how to use links to refer to another elements documentation, inside of a documentation.
In my case I need to navigate to a different documentation window for better readability. E.g. a explanation for a custom type.
Is there a way I can achieve this? Creating and returning new LeafPsiElements from DocumentationProvider.getDocumentationElementForLink does not work since the new LeafPsiElement does not have a parent element.
Please sign in to leave a comment.
It's hard to guess what you're looking for, and a small code example in your language explaining what you are trying to achieve would be helpful. The getDocumentationElementForLink method is not supposed to create PSI elements but rather navigate and return the correct one. A readable example can be found in, e.g., in PyDocumentationLink.kt#L83-L92.
However, your explanation sounds similar to something I did in the past. Basically, my language has a massive set of built-in function names like Table, Find, Sqrt, etc., but I cannot navigate to the definition because the built-in's are a black box. Still, I wanted to give all "usages" of these built-in functions a common PSI element so that the IntelliJ Platform knows all usages of e.g. Table resolve to the exact same PSI element. For that, I used com.intellij.psi.impl.light.LightElement which doesn't need a parent, children or text-ranges.
That being said, you might also want to check out com.intellij.psi.impl.FakePsiElement which I have seen being used in similar situations. Maybe using these will help. If not, please provide a concise example so that it's absolutely clear what you try to achieve and where it goes wrong.
Hi Patrick,
LightElement was the class I needed and didn't know it existed.
Thank you!