Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » help on getting binding information in AST
help on getting binding information in AST [message #821718] Thu, 15 March 2012 18:33 Go to next message
b x is currently offline b xFriend
Messages: 16
Registered: February 2012
Junior Member
Hi, I'm using the eclipse JDT AST parser to process some Java code and get binding information e.g. ITypeBinding, but resolveBinding() returns null all the time.
Here are some relevant codes:
ASTParser parser = ASTParser.newParser(AST.JLS3);
parser.setKind(ASTParser.K_COMPILATION_UNIT);
parser.setSource(javaSource.toCharArray()); // the type of javasource is string
parser.setResolveBindings(true);
I found that maybe the reason is When source is supplied by setSource(char[]), the location must be established explicitly by setting an environment using setProject(IJavaProject) or setEnvironment(String[], String[], String[], boolean).
Can you give me any sample program to set the environment or get IJavaProject from the project or create an ICompilationUnit instance? Thank you.
Re: help on getting binding information in AST [message #822200 is a reply to message #821718] Fri, 16 March 2012 09:38 Go to previous message
Deepak Azad is currently offline Deepak AzadFriend
Messages: 543
Registered: July 2009
Senior Member
> get
> IJavaProject from the project or create an ICompilationUnit instance?

Use org.eclipse.jdt.core.IJavaElement.getJavaProject()

--
Deepak Azad
http://wiki.eclipse.org/JDT/FAQ
Previous Topic:[LTK Refactoring] How to control the order of Refactoring are executed
Next Topic:how I can add an external server?
Goto Forum:
  


Current Time: Thu Apr 25 18:05:59 GMT 2024

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

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

Back to the top