How can I load a .java file into a CompilationUnit? For example, lets say I have a A.java file in my current project. I would like to load it into a CompilationUnit and then pass it to the ASTParser. It is not an option just to load it as a plain text since it seems that in that case I will not get the binding information in the AST.
Share
You can load the projects using
jdtandeclipse corelibraries.Using the following code you can load all the projects in the workspace.
Then you can get packages and in turn the java files.
Then you can use this ICompilationUnit object for getting the CompilationUnit
This CompilationUnit object can be passed on to the ASTParser.