Skip to main content



      Home
Home » Language IDEs » Java Development Tools (JDT) » Keeping Track of AST after ASTRewrite
Keeping Track of AST after ASTRewrite [message #259691] Thu, 23 April 2009 09:55
Eclipse UserFriend
I have working code that uses ASTRewrite to save changes to a java source
file.
What I would like to do now, is check the state of the AST after I have
made some changes, but BEFORE I write the changes back to the file.

So, for example, let's say I add an argument to a method:

ListRewrite listRewrite = astRewrite.getListRewrite(method,
MethodInvocation.ARGUMENTS_PROPERTY);
listRewrite.insertLast(arg, null);

I can now write my change to file:
TextEdit astRewriteTextEdit = astRewrite.rewriteAST(document, null);
astRewriteTextEdit.apply(document);

This works.

Now, I would like to see the list of arguments in the MethodInvocation,
reflecting my change, before writing it out. I tried this:
astRewrite.rewriteAST();
But my MethodInvocation object was unchanged. I tried running a new
Visitor on the ASTNode that was returned by the original parser.createAST
call, but it also appears unmodified.

Any suggestions about how to see the state of the AST without writing to
file and reloading?

Thanks.
Previous Topic:HELP - JavaModelException
Next Topic:org.eclipse.ant.core.antTasks extension ponit @library
Goto Forum:
  


Current Time: Wed Jul 16 18:30:33 EDT 2025

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

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

Back to the top