Guidance text for marker in Eclipse plugin

I have a special editor with problem markers. Markers are displayed correctly in the problem view using the icon, location, and text, and problem icons are displayed correctly in the left margin of the editor.

I would like to display the same error message text in a popup when I hovered over the problem marker icon on the border, as it does in the Java editor. There are no pop-ups right now.

Is there an easy way to achieve this?


Answer:

OK, it seems that the functionality is built into the marker system. It seems that the patch has been sent, so it will probably be added to a later version, but before that it is also quite easy to create manually.

  • Create a class that implements IAnnotationHoverand implements getHoverInfo().
  • Returns the class in method getAnnotationHover()c SourceViewerConfiguration.
  • In the getHoverInfo()method, call ISourceViewer.getAnnotationModel().getAnnotationIterator()to get all the tokens.
  • Select the marker (s) corresponding to the line number, and return the marker text.
+3
source share
2 answers

This error in the eclipse xtext plugin offers a patch to show a hint with a marker on hover and status bar. If you look at the attached fixes, you can find the answers you need.

+2
source

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 line markers in the text of the problem marker hover in the text editor fields.

+10

Source: https://habr.com/ru/post/1774545/


All Articles