Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hover text for Marker in Eclipse plugin

I have a custom editor with problem markers. The markers display correctly in the "problems" view with icon, location and text, and the problem icons display correctly in the left margin of the editor.

I would like to display the same error message text in a popup when hovering over the problem marker icon in the margin, just as it happens in the Java editor. Right now there in no popup.

Is there an easy way to achieve this?


Answer :

OK, it doesn't look like the functionality is built-in in the marker-system. It seems a patch have been submitted, so it will probably be added in a later version, but until then it is also pretty easy create by hand.

  1. Create an class that implements IAnnotationHover and implement getHoverInfo().
  2. Return the class in getAnnotationHover() method in the SourceViewerConfiguration.
  3. In getHoverInfo() method, call ISourceViewer.getAnnotationModel().getAnnotationIterator() to get all markers.
  4. Select the marker(s) that correspond to the line number, and return the marker text.
like image 218
JacquesB Avatar asked May 22 '26 12:05

JacquesB


1 Answers

In your class that extends org.eclipse.jface.text.source.SourceViewerConfiguration, just include the following:

@Override
public IAnnotationHover getAnnotationHover(ISourceViewer sourceViewer) {
    return new DefaultAnnotationHover();
}

this includes the text of all markers of a line in the hover text of the problem marker in the margins of the text editor.

like image 122
Dennis Hendriks Avatar answered May 30 '26 15:05

Dennis Hendriks



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!