Getting information about problems reported by ecj [message #530211] |
Wed, 28 April 2010 16:40  |
Eclipse User |
|
|
|
Greetings. I'm new to eclipse development. I was pointed to this discussion as the proper place to ask my question.
I'm writing a tool that uses ecj to examine java source. I've extended ProblemReporter to get the problem report. When a problem is found ecj calls
public void record(CategorizedProblem p, CompilationResult cr, ReferenceContext ctxt)
to report the problem.
My problem is in trying to understand where the problem occurred. I can find the specific line that contains the error, but I'd like to know more. Specifically, I'd like to know if the error occurred in a static context or not.
Consider the code below. There are two parse warnings about passing null to varargs without a cast. The first warning is in a static context, and the second is non-static. But how can I read this from the problem and the context? The context seems to just say that both errors come in the context of defining a type, which doesn't give me the information I need.
Thanks,
Michael
public class RegressionTest24416 {
// parse warning here
static Method myStaticMethod = RegressionTest24416.getMethod(RegressionTest24416.class, "getIdentity", null); // static
// parse warning here
Method myMethod = RegressionTest24416.getMethod(RegressionTest24416.class, "getIdentity", null); // non-static
static Method getMethod(Class clazz, String name, Class ... parameterTypes) {
return null;
}
|
|
|
|
|
|
|
|
Re: Getting information about problems reported by ecj [message #531168 is a reply to message #531095] |
Mon, 03 May 2010 21:51  |
Eclipse User |
|
|
|
Using DOM/AST let you use only APIs which means that your code should run on any future versions of Eclipse.
Going inside internal code means that code might not run at all on a future version of Eclipse as this internal code might be change without any notice.
DOM/AST also gives you the ability to get the problems for the compilation unit and using a Node Finder it is simple to find out where a problem is reported.
Then you can work the AST to retrieve the context and find out if it is static.
Olivier
|
|
|
Powered by
FUDForum. Page generated in 0.03890 seconds