Only one element received by SQL annotator
It could just be that I've completely misunderstood the `Annotator` interface, but I'm not seeing it receive as many psi elements as expected - I expected to receive one for each SQL statement (or part of one), instead I only ever receive one, top-level `PsiFile` SQL element.
I have a really simple annotator, designed to create an annotation for every element it receives, in order to explore their structure:
class LoggingAnnotator : Annotator {
override fun annotate(element: PsiElement, holder: AnnotationHolder) {
holder.createAnnotation(HighlightSeverity.ERROR, TextRange.from(0, 12), element::class.toString() + element.textRange)
}
}
I then register it in the plugin.xml for postgres (I have my IDE set up to assume SQL code is Postgres):
<annotator implementationClass="LoggingAnnotator " language="PostgreSQL"/>
I then load up the plugin with a file open with several Psi elements:

What I expected to see: an annotation where the annotator has received each of the psi elements displayed in the psi viewer, eg a SQL_DELETE_DML_INSTRUCTION, a PsiElement(FROM), etc etc.
What I actually see: Only one annotation, where the annotator has received the whole sql file:

I have tried to trigger re-annotation of the file by editing the DELETE statement, but still the Annotator only ever receives one psi element
Have I just misunderstood this interface? Should I perform annotations just by inspecting the children of the `PsiElement` representing the whole file at once?
Please sign in to leave a comment.