Q:

Eclipse add errors to "Problems" tab

How can I add errors to the Problems tab?
I'm trying to create an external builder will run before building the Java project and do some processing to the source files, then I need to add the errors to the "Problems" tab.

A:

You need to add an IMarker to the IFile resource. Something like:
IMarker marker = file.createMarker(IMarker.PROBLEM);

marker.setAttribute(IMarker.LINE_NUMBER, line number of the error);
marker.setAttribute(IMarker.MESSAGE, "your error message");
marker.setAttribute(IMarker.PRIORITY, IMarker.PRIORITY_HIGH);
marker.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_ERROR);

This code needs to be run in an Eclipse plugin. 

