Creating hover popup windows for certain lines

Hello everyone!

 

I am new to the plugin development and I am currently working on a plugin for PyCharm IDE. Here I colorize during an Action some lines of code in the current Editor that is opened.

For this I use the RangeHighlighter class. After this, I have certain lines colorized. 

But now I would like to display a hover popup window with some text, if the mouse cursor is positioned on the colorized line for some time(e.g 500ms - like the setting for the JavaDoc in IntelliJ).

I have looked through similar questions/answers here and havent really found a solution for this. I am not sure if I have to create some PSIElement where the lines are and some Listener for it or what is the right, proper way to do this.

 

I will be very thankful for all your answers!

Thanks in advance

Jan 

5 comments
Comment actions Permalink

Hi,

do you need these highlightings to be visible after project reopen or how would you like to clear them?

 

Thanks,

Anna

0
Comment actions Permalink

Hello Anna!

 

So far which lines are to be colorized is determined by a standalone application which does the parsing of a log file and then sends the results. 

Right now I am clearing the colorization for the current editor via MarkupModel class removeAllHighlighters() method. As for all the others I am recolorizing the lines when a new Editor is opened, so I just stop this recolorization by removing the stored results as to what colorize. This way I remove the colorization of lines for all editors as of now.

(I would like this to be changed to editor tab change, not only when a editor is opened/reopened, as the editors in tabs are not colorized, only the one opened)

So I think that I dont need these highlightings to be visible after project reopen.

Best Regards,

Jan

0
Comment actions Permalink

Hello.

The easiest way is to write your own inspection which will create ProblemDescriptors for necessary places with showToolTip=true. Please see http://www.jetbrains.org/intellij/sdk/docs/tutorials/code_inspections.html for how to write inspections.

0
Comment actions Permalink

I doubt that removeAllHighlighters is a good idea - you would remove highlights which were provided by IDE or another plugin as well. 

As you use a standalone application to provide the data, it looks to me that com.intellij.lang.annotation.ExternalAnnotator could be an api you need. It's possible to start process to get results and then convert those results to IDEA's highlightings. You may configure if you want these coloring or not by storing some flag inside your annotator.

Anna

0
Comment actions Permalink

Thanks for the suggestion Alexey. I have some questions though.

Right now I want to create these hover popup boxes (or these ProblemDescriptors) when an Action registered in my plugin.xml is activated. The tokens which I want to search for in each file will be different for each file and each time the Action is activated, the tokens I want to find will change. 

So with this, will I be able to change this code inspection so it findes different tokens during runtime?

Also thank you Anna, I will look into it.

Best regards,

Jan

0

Please sign in to leave a comment.