How can I indicate syntax errors (e.g. an illegal sequence of tokens) in an eclipse editor plugin just like in the eclipse Java editor, i.e. by red wriggly underlines, a red marker on the scrollbar that you can jump to, and an explanatory message when you hover over either one?
I'm writing an eclipse editor plugin for a custom file format (specifically, the "snake file format" of the Shark3D game engine). I have implemented a scanner to get syntax highlighting, and an outline.
IToken with a "wriggly underline" TextAttribute instead of the normal one, or is there a specific mechanism for marking syntax errors? IAnnotationModel the relevant interface here? If so, where do I register the implementation so that the markers appear? SourceViewerConfiguration.getAnnotationHover(), which would allow me to implement the hover behaviour, but only for the "annotation", which I suppose means the scrollbar markers - how do I implement the hover behaviour for the text itself?I'd be happy specific advice as well as an URL of a tutorial that covers this - the eclipse help documents and examples don't seem to.
Edit:
Markers are the best solutions to this. A working example of how to use them can be found in the plugin example code in org.eclipse.ui.examples.readmetool.AddReadmeMarkerAction
You should be using Markers.
An example derived from "The Java Developer's Guide to Eclipse" follows:
<extension point="org.eclipse.core.resources.markers"  
            id="snakesyntax"  
            name="Snake syntax error">  
    <super type="org.eclipse.core.resources.problemmarker" />  
    <super type="org.eclipse.core.resources.textmarker" />  
    <persistent value="true" />
<extension>
IMarker marker = res.createMarker("com.ibm.tool.resources.snakesyntax");
marker.setAttribute(IMarker.SEVERITY, 0);
marker.setAttribute(IMarker.CHAR_START, startOfSyntaxError);
marker.setAttribute(IMarker.CHAR_END, endOfSyntaxError);
marker.setAttribute(IMarker.LOCATION, "Snake file");
marker.setAttribute(IMarker.MESSAGE, "Syntax error");
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With