How can I show the Problem Marker properly? It is not displayed Text Editor and Problem View
I got many ideas from previous question (How to display an error sign on the Package when the Package has wrong information?)
But the Problem Marker is not displayed.
The resource I'm interested in, is an XML file.
So I added a listener for PRE_BUILD, using the following code:
It works fine. Now I'm trying to add a Problem Marker.
IMarker marker = file.createMarker(PROBLEM_ID); marker.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_ERROR); marker.setAttribute(IMarker.MESSAGE, "Error Message"); marker.setAttribute(IMarker.CHAR_START, 5); marker.setAttribute(IMarker.CHAR_END, 6); marker.setAttribute(IMarker.LINE_NUMBER, 5);
Above code is executed. But the Problem Marker is not displayed on the Editor and Problem views. How can I show the Problem Marker properly?
If you add your marker upon IResourceChangeEvent.PRE_BUILD I could imagine the problem is that before a build, all markers are cleared - so perhaps your new markers are cleared immediately so you don't even see them. I'd give it a try with IResourceChangeEvent.POST_BUILD.
Also, are you using the correct problem ID when creating the marker? Because in your code you use createMarker(PROBLEM_ID), not createMarker(IMarker.PROBLEM).