|
Re: How to get the java markers (IMarker) as Eclipse editor sees them? [message #667767 is a reply to message #666965] |
Mon, 02 May 2011 07:09 |
Dani Megert Messages: 3802 Registered: July 2009 |
Senior Member |
|
|
On 25.04.2011 09:16, Kivanc Muslu wrote:
> Hi all,
>
> Currently to get the compilation error markers in a file (or project),
> I use the following code:
>
>
> public static IMarker [] calculateCompilationErrorMarkers(IProject
> project)
> {
> ArrayList <IMarker> result = new ArrayList <IMarker>();
> IMarker [] markers = null;
> markers =
> project.findMarkers(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARK ER, 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()]);
> }
>
>
> The above code works well, however the problem with this code is that
> it requires all files in the project to be saved and project to be
> built before requesting the markers.
> Q1: Does building the project create the markers?
Yes, the builder keeps track of the markers.
> Q2: Is there any other way to create the markers without saving or
> building the project
You can create markers without building a project, e.g. search result
markers but the official way to manage problem markers is via builders.
> (actually Eclipse itself does this since it show me compilation error
> markers (and quick fixes) even before I save my file)?
Those are not markers but lightweight annotations created by the editor
from the result of the Java reconciler.
>
> What I need is to get the most recent marker information as Eclipse
> editor (and user) sees it without saving or building the user project.
> Is this possible? If yes, I would appreciate a starting point or an
> API very much.
If you are only interested in the current state (marker/annotations) in
the editor then you might want to take a look at:
org.eclipse.jface.text.source.IAnnotationModelExtension2.get AnnotationIterator(int,
int, boolean, boolean)
Dani
>
> Thanks in advance, best regards,
|
|
|
Powered by
FUDForum. Page generated in 0.02700 seconds