Search code examples
eclipseeclipse-plugineditormarkers

Show error marker for external resource


I have written an eclipse editor that performs syntax checking and if it finds an error, it will display it in the editor.

Currently I am doing this by creating a marker in the respective IResource and that is working well until the user uses the File -> Open File... option in order to open a non-project file with that editor.

The problem is that the EditorInput is no longer an IFileEditorInput (it's a FileStoreEditorInput) that allowed me to retrieve the connected IResource via getFile() (on which I can add the marker via createMarker()). In fact the core problem is that the opned file isn't an IResource at all (at least that is what I'm guessing as it is not in the eclipse workspace).

Is there another way of showing the error markers in the editor? It doesn't need to be savable or anything... Just a way to tell the editor to create the same markers in the source code as if there were some IMarker attached to the opened IResource.


Solution

  • Okay the thing was that I was actually looking for the creation of an Annotation in the AnnotationModel of the DocumentProvider. There it could be added via addAnnotation.

    That approachs works fine. However I haven't found a list of available annotation types (as there are for Markers), so it's a little tricky to actually get the proper annotation...