Skip to main content



      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 14:33 Go to next message
Eclipse UserFriend
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 05:38 Go to previous message
Eclipse UserFriend
> 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: Tue May 20 19:09:46 EDT 2025

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

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

Back to the top