How to find the number of errors(marked in red) in an eclipse project programmatically?
I recommend going to your Problems view, selecting one of the errors, and hitting Ctrl-1 (quick fix). It should offer you the chance to fix all the errors of the selected type, in all files. You can also mouse over the error in the text editor and wait for a popup; it should say "fix 70 other errors of this type".
During development, you can browse and manipulate the platform log file using the Error Log view (Window > Show View > General > Error Log). You can also have the log file mirrored in the Java console by starting Eclipse with the -consoleLog command-line argument.
The “Problems” view in Eclipse lists errors and warnings in the workspace. In its default settings this view is not entirely helpful, but it is highly customizable. Today I want to show you how you can configure this view to shift the focus to the interesting errors and warnings in your current area of work.
There are two major steps:
You need an access to Eclipse API - write your own plugin for Eclipse or use a scripting plugin like Groovy Monkey
Using Eclipse API get problem markers for resource you intrested in - check this link: How to work with resource markers
If you want to retrieve only JDT error markers you should write something like this:
public static IMarker[] calculateCompilationErrorMarkers(IProject project)
{
ArrayList <IMarker> result = new ArrayList <IMarker>();
IMarker[] markers = null;
markers = project.findMarkers(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER, true, IResource.DEPTH_INFINITE);
for (IMarker marker: markers)
{
Integer severityType = (Integer) marker.getAttribute(IMarker.SEVERITY);
if (severityType.intValue() == IMarker.SEVERITY_ERROR)
result.add(marker);
}
return result.toArray(new IMarker[result.size()]);
}
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