How to get the instance of the parser from an annotator?
Hi,
I'm developing a plugin for a custom language which has notions of "namespace" and "prefixed name", like in XML. I wanted to create an annotator which checks whether a given prefixed name uses an earlier defined namespace or the namespace has not been defined earlier in the file.
I could extend the parser to collect all defined namespaces in a map and then access this map from the annotator. However, I don't know how to access the instance of the parser which was used to build a PSI element given to the annotator.
Could you point me to an example where such mechanism is used? Or maybe there is another approach to implementing it?
Thank you in advance!
Please sign in to leave a comment.
Basically you need to implement a reference from namespace usage to a namespace declaration, like a local variable in some language.
And make an inspection which traverses your file and checks that every reference is successefully resolved.
References: http://www.jetbrains.org/intellij/sdk/docs/basics/architectural_overview/psi_references.html
Inspections: http://www.jetbrains.org/intellij/sdk/docs/tutorials/code_inspections.html