bindings are null [message #506290] |
Wed, 06 January 2010 14:33  |
Eclipse User |
|
|
|
Hi Everyone,
I'm trying to retrieve the type and method bindings in each of the appropriate endVisit() methods in my ASTVisitor class, but I'm not having any luck and the bindings are consistently null. The interesting thing is that the bindings work on the same code with the eclipse ASTView plugin. What am I doing wrong?
Here are some relevant code snippets which will hopefully help someone figure out what is going on!
ASTParser parser = ASTParser.newParser(AST.JLS3);
parser.setKind(ASTParser.K_COMPILATION_UNIT);
parser.setSource(source);
parser.setResolveBindings(true);
CompilationUnit unit = (CompilationUnit) parser.createAST(null);
GenericVisitor visitor = new GenericVisitor(outDir + "//" + file.getName() + ".xml");
visitor.process(unit);
public class GenericVisitor extends ASTVisitor
{
public void endVisit(FieldDeclaration node)
{
String bindingInfo = "";
ITypeBinding binding = node.getType().resolveBinding();
if(binding == null)
{
System.out.println("field declaration binding = null");
}
else
{
bindingInfo = binding.getQualifiedName();
}
endVisitNode(node, bindingInfo);
}
public void endVisit(MethodInvocation node)
{
String bindingInfo = "";
IMethodBinding binding = node.resolveMethodBinding();
if(binding == null)
{
System.out.println("method binding = null");
}
else
{
bindingInfo = binding.toString();
}
endVisitNode(node, bindingInfo);
}
}
Thanks in advance,
Shirley
|
|
|
|
|
|
|
Re: bindings are null [message #506649 is a reply to message #506462] |
Fri, 08 January 2010 04:04  |
Eclipse User |
|
|
|
Le 2010-01-07 10:41, Shirley Cohen a écrit :
> So, what you're saying is that an IProject cannot be created for an
> existing java project that resides in a separate eclipse workspace?
> What I am trying to do is parse the contents of various third party
> software, which already exist somewhere else on the file system in their
> own workspaces. I don't want to have to import every single one into my
> own workspace where the parsing is done. Does this help? Do you need
> more info?
Are you running your code from within Eclipse or on a command line?
What you are trying to do is not simple to achieve.
--
Olivier
|
|
|
Powered by
FUDForum. Page generated in 0.01824 seconds