Add tooltips to highlights.
Hi,
I'm writing a plugin to analyze python code, where the user triggers the analysis by an action. The errors are generated and I highlight the error line and show it in the gutter. I have the highlights but i can't seem to find a way to show tooltips when the mouse is hovered over the highlights. I have looked at the external annotator but i want to show that highlights when the user presses the analyze bottom. Is there any way to do this. Thanks in advance.

Something like this. But on the red highlight on the "from" keyword.
Please sign in to leave a comment.
What API do you use to add the highlighting?
I'm adding RangeHighlighter to the MarkupModel.
AFAIU there is no reason to not use plain Annotator here, which has more powerful API (adding quickfixes etc).. The data can be calculated on demand only by invocation of action and stored e.g. in UserData of PsiFile to be retrieved by Annotator later.
Could please explain me how to add annotator without implementing externalAnnotator?
See com.intellij.lang.annotation.Annotator, http://www.jetbrains.org/intellij/sdk/docs/tutorials/custom_language_support/annotator.html
Your action will have to trigger re-highlighting of file explicitly to run annotator via com.intellij.codeInsight.daemon.DaemonCodeAnalyzer#restart(com.intellij.psi.PsiFile)
Thank you very much. Will update after implementing.
The annotator worked but not as expected. Is there a way to run the annotator only when i want because I have a certain number of errors that i want to annotate and not when there is a change.
If i put a loop inside the method and add annotations then the method will run wild and annotate my file more than once.
My annotate method.
Updated annotate method. This works.
Please obey the contract specified in javadoc:
* DO NOT STORE any state inside annotator.
Oh, ya. Will fix it. Thank you for the help.