[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[news.eclipse.tools.jdt] Re: Question on Marker use (APT vs. JavaModel)

Walter Harley wrote:
"Mike Yawn" <myawn@xxxxxxxx> wrote in message news:fbpcnd$4qj$1@xxxxxxxxxxxxxxxxxxxx
Question 1: Is there a way to retrieve the markers created by EclipseMessager.printFixableError starting from an ICompilationUnit?

Hmm. It must be possible to pull them off the resource in some way; after all, the JDT Problems view manages to do so. In my experience the challenge is to tell them apart from the other JDT compilation problem markers.


Take a look at AbstractImageBuilder.storeProblemsFor(), and IncrementalImageBuilder.updateProblemsFor(), in org.eclipse.jdt.internal.core.builder; and at APTProblem.getMarkerType(), in org.eclipse.jdt.apt.core.internal.env.


You're right; I was thinking they must be visible since the problems view shows them. I think I was trying to see them as I typed; they don't actually become visible to the Problems view (or in my action code until I save the file after making the edit that results in the error.

And then, as you indicate, getting at the content to distinguish the error is an issue.

I looked the at code that creates the markers (EclipseMessager implementation), and it appears that what I'm creating _ought_ to be an APTProbem -- which implements IProblem, so I should be able to cast it to an IProblem, and then use getArguments to retrieve the plugin id & error id. However, what I'm seeing from .findMarkers is just an org.eclipse.core.internal.resources.Marker, and if I try to cast it to an IProblem I get a ClassCastException. The Marker errorids seem to be random (they are sequential and unrelated to the errorId I passed in at creation time).

Any ideas of how I can retrieve these markers in a way that allows them to be cast to IProblems (or some other clever way to get at the content -- I'm not sure what lurks behind marker.getAttribute for those who have the attribute name decoder ring)

Mike