Skip to main content



      Home
Home » Language IDEs » Java Development Tools (JDT) » Getting information about problems reported by ecj
Getting information about problems reported by ecj [message #530211] Wed, 28 April 2010 16:40 Go to next message
Eclipse UserFriend
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 #530528 is a reply to message #530211] Thu, 29 April 2010 19:50 Go to previous messageGo to next message
Eclipse UserFriend
It looks like you are looking into internal code. Any reason for this ?

Olivier
Re: Getting information about problems reported by ecj [message #530725 is a reply to message #530528] Fri, 30 April 2010 12:04 Go to previous messageGo to next message
Eclipse UserFriend
Yes, I'm writing a static analysis tool. One of our sources of analysis defects is coming from embedded use of ecj which is why we are implementing a ProblemReporter.

When ecj issues warnings we'd like to be able to tell the user something about the problem. For the warning generated below I'd like to be able to know whether it is in a static context, or non-static, but I don't see how to get that information.

Thanks,

Michael
Re: Getting information about problems reported by ecj [message #530757 is a reply to message #530725] Fri, 30 April 2010 13:40 Go to previous messageGo to next message
Eclipse UserFriend
Equivalently, I would like to know if the defect is in a scoped or implicit static initializer, or in an implicit constructor that initializes instance fields. It does tell me if I'm in an explicit constructor, but not the other cases.
Re: Getting information about problems reported by ecj [message #531084 is a reply to message #530757] Mon, 03 May 2010 12:23 Go to previous messageGo to next message
Eclipse UserFriend
We don't have that information from the problem reporter. One way to get it would be to do a ast visitor that is using the reference context and the position of the problem to retrieve the context.
Not ideal, but doable.

Any reason why you are not using DOM/AST for your analysis tool ?

Olivier
Re: Getting information about problems reported by ecj [message #531095 is a reply to message #531084] Mon, 03 May 2010 13:04 Go to previous messageGo to next message
Eclipse UserFriend
Using the DOM/AST is a whole separate project. At the moment I'm just trying to pull out the parse warnings, so it seemed the the ProblemReport was the way to go. But maybe I can't get the information I need from it.

Thanks,

Michael
Re: Getting information about problems reported by ecj [message #531168 is a reply to message #531095] Mon, 03 May 2010 21:51 Go to previous message
Eclipse UserFriend
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
Previous Topic:JavaFX install problems
Next Topic:Eclipse Galileo on Ubuntu
Goto Forum:
  


Current Time: Thu Mar 27 17:18:47 EDT 2025

Powered by FUDForum. Page generated in 0.03890 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top