I am currently developing an Intellij plugin and I'm facing a problem to highlight code in an efficient way.
I want to only highlight the code selected by the user in the editor and I want the highlighted elements ranges to be recalculated each times the document is edited. The highlighted element have not to be repeated in the other documents. I also need to have a tooltip on mouseover and a custom highlight color.
So, I went by creating an Annotator because it fits all my needs. I thought it was possible to create an annotation by calling the AnnotationHolder.newAnnotation() method manually on the desired PSI element.
In fact, the Annotator is called automatically by the IDE for each PSI element of the current document.
Can I have the Annotator to be called manually and is there a better way to do that ?