Search code examples
eclipse-plugineclipse-cdt

How to update eclipse marker tooltip text?


I'm developing an Eclipse plug-in using CDT. In this plug-in I extended org.eclispe.core.resources.markers with super type org.eclipse.core.resources.problemmarker. The behavior of the marker is correct except that the text of the marker in the ruler and the one of the tooltip when hovering over the marked code is the same.

For example, here is the text of the marker in the ruler:

text of the marker in the ruler

and here is the text of of the tooltip when hovering over the code:

text of of the tooltip when hovering over the code.

What i would like to do in the above example is when hovering over the tooltip is to have different text "BBB".

How can I customize the text of the marker tooltip?

I could not adapt the solution in Hover text for Marker in Eclipse plugin to my need. It will be great to have more information regarding this.


Solution

  • Background

    In the first case, the tooltip is provided by the marker hovering over the ruler. In the second case the tooltip is provided as a hover.

    You can turn on/off various hovers with the Window -> Preferences -> C/C++ -> Editor -> Hovers. The hover you are seeing is provided by either Problem Description or Annotation Description (experiment by turning them on and off). The Combined Hover is a special one that combines all the other hovers together and tries to show you the most relevant one.

    Therefore, based on what I believe you are effectively requesting here is the answer on writing a new hover.

    Answer

    To create a custom hover that can interpret and present the hovered over data in a new and wonderful way, implement the org.eclipse.cdt.ui.textHovers extension point. In the CDT code base there are already a few uses that can be used as examples.

    You may want to extend AbstractAnnotationHover as a starting point.