Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » internal vs non-internal CompilationUnits(unexpectedly getting org.eclipse.jdt.internal.core.CompilationUnit )
internal vs non-internal CompilationUnits [message #1783506] Tue, 13 March 2018 17:08 Go to next message
Carlos Fuente is currently offline Carlos FuenteFriend
Messages: 1
Registered: March 2018
Junior Member
I want to invoke some
accept(ASTVisitor)
methods on some CompilationUnit s but I am interested in the class from the
org.eclipse.jdt.core.dom
package.

Specifically I want to call the accept method that
org.eclipse.jdt.core.dom.CompilationUnit
inherits from
org.eclipse.jdt.core.dom.ASTNode
.

However when I call "getCompilationUnits()" from
IPackageFragment
it returns objects of type org.eclipse.jdt.internal.core.CompilationUnit which I cannot cast to org.eclipse.jdt.core.dom.CompilationUnit.

How can I get the right
CompilationUnit
?
Re: internal vs non-internal CompilationUnits [message #1783674 is a reply to message #1783506] Thu, 15 March 2018 12:54 Go to previous message
Stephan Herrmann is currently offline Stephan HerrmannFriend
Messages: 1853
Registered: July 2009
Senior Member
IPackageFragment is part of the light-weight JavaModel, whereas everything below org.eclipse.jdt.core.dom.ASTNode is part of the full detailed AST. These are different structures.

To obtain a parsed AST please use class ASTParser.
Its method setSource(ITypeRoot) accepts org.eclipse.jdt.core.ICompilationUnit, the same type returned by IPackageFragmentRoot.getCompilationUnits().

HTH
Stephan
Previous Topic:Eclipse Application to standalone?
Next Topic:How to recognize implicit toString call?
Goto Forum:
  


Current Time: Thu Apr 25 19:59:39 GMT 2024

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

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

Back to the top