parseCompilationUnit problem with passing in true [message #121875] |
Tue, 25 November 2003 15:19  |
Eclipse User |
|
|
|
When I call AST.parseCompilationUnit( cu, true ), I get back AST that does
not have anyting inside of the method bodies.
When I call AST.parseCompilationUnit( cu, false ), I get back full AST,
but, obviously, can't resolve any bindings.
I get the same behaivior in 3.0 M4 and M5.
Am I missing something here or is this a bug?
Thank you,
Alex
|
|
|
|
|
|
|
|
|
|
Re: parseCompilationUnit problem with passing in true [message #122367 is a reply to message #122345] |
Wed, 26 November 2003 09:21  |
Eclipse User |
|
|
|
I think that I found the problem.
I get error message java.lang.Object can not be resolved,
this is happening because RT.jar is not added to the Classpath by
default.
Alex
Alex Iskold wrote:
> Markus,
> Where can I find ASTFlattener?
> I am not sure if it will help, because this code:
> astRoot.accept( new ASTVisitor() {
> public void preVisit( ASTNode node ) {
> if ( node instanceof MethodDeclaration ) {
> MethodDeclaration md = (MethodDeclaration)node;
> Block b = md.getBody();
> List l = b.statements();
> System.out.println( l.size() );
> }
> }
> public boolean visit( Block b ) {
> System.out.println( b.statements().size() );
> return true;
> }
> } );
> Prints:
> 0
> 0
> Alex
> Markus Keller wrote:
> > Alex Iskold wrote:
> > [..]
> > > ICompilationUnit cu= pkg.createCompilationUnit("E.java", buf.toString(),
> > > false, null);
> > > CompilationUnit astRoot= AST.parseCompilationUnit(cu, true);
> > > astRoot.accept( new ASTVisitor() {
> > > public void preVisit( ASTNode node ){System.out.println(
> > > node.toString() );
> > > }
> > > } );
> > [..]
> > > As you can see no method body...
> > The AST is there. ASTNode#toString() just doesn't flatten the whole AST.
> > Use e.g. ASTFlattener to flatten the AST.
> > Markus
|
|
|
Powered by
FUDForum. Page generated in 0.07402 seconds