Get all ASTNodes in JDT Java Model [message #1066306] |
Tue, 02 July 2013 06:10  |
Eclipse User |
|
|
|
Hi,
I would like to make the jdt.core.dom Java model in another form. So is there a way to get access to all the ASTNodes so that I can loop through them? I would also like the access to methods on these nodes.
I thought of getting all the subclasses for ASTNode class. But that doesn't seem possible with Java.
Please let me know how this is possible. Using an ASTVisitor is specific to a AST pertaining to a compilation unit. I would like to get access to all possible ASTNodes.
Thanks
|
|
|
Re: Get all ASTNodes in JDT Java Model [message #1067218 is a reply to message #1066306] |
Sun, 07 July 2013 18:18  |
Eclipse User |
|
|
|
A few comments:
JDT distinguishes the "DOM AST" vs. the "Java Model", you seem to be asking about the former.
I don't see why you would want a list of all subclasses of ASTNode, that still wouldn't give you the desired instances, right?
If I understand correctly, the only thing you're missing seems to be how to iterate over all compilation units, right?
Do you want all compilation units of a given project, or all of the entire workspace?
You could either use an IResourceVisitor and check which visited resources correspond to Java compilation units,
or more systematically: start from an IJavaProject (this is the Java Model) and descend into its IPackageFragmentRoot's -> IPackageFragment's -> ICompilationUnit's
Note, that requesting ASTs for all files in the workspace is very expensive (time & memory), so you may actually have to revise your strategy.
HTH,
Stephan
|
|
|
Powered by
FUDForum. Page generated in 0.03205 seconds