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. 

0
9 comments
Official comment

What API do you use to add the highlighting?

Avatar
Permanently deleted user

I'm adding RangeHighlighter to the MarkupModel.

0

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.

1
Avatar
Permanently deleted user

Could please explain me how to add annotator without implementing externalAnnotator? 

0

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)

1
Avatar
Permanently deleted user

Thank you very much. Will update after implementing.

0
Avatar
Permanently deleted user

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.

0

Please obey the contract specified in javadoc:

* DO NOT STORE any state inside annotator.

1
Avatar
Permanently deleted user

Oh, ya. Will fix it. Thank you for the help.

0

Please sign in to leave a comment.