Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » Get all ASTNodes in JDT Java Model(Trying to get all ASTNodes in JDT JavaModel - not specific to an AST)
Get all ASTNodes in JDT Java Model [message #1066306] Tue, 02 July 2013 06:10 Go to next message
A B is currently offline A B
Messages: 1
Registered: July 2013
Junior Member
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 Smile
Re: Get all ASTNodes in JDT Java Model [message #1067218 is a reply to message #1066306] Sun, 07 July 2013 18:18 Go to previous message
Stephan Herrmann is currently offline Stephan Herrmann
Messages: 1007
Registered: July 2009
Senior Member
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
Previous Topic:"Run As" Context not working
Next Topic:Eclipse hanging Ubuntu desktop - process ID?
Goto Forum:
  


Current Time: Thu Oct 02 10:40:41 GMT 2014

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

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