Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: [cdt-dev] Modifying AST

Hi,
as indicated by the java-doc of 'ASTRewrite.rewriteAST()', the method has no immediate effect, it generates a change object:
 
  Change change= astRewriter.rewriteAST();
  change.perform(...);

Markus.



> -----Original Message-----
> From: cdt-dev-bounces@xxxxxxxxxxx 
> [mailto:cdt-dev-bounces@xxxxxxxxxxx] On Behalf Of Wolfgang
> Sent: Monday, June 07, 2010 5:37 PM
> To: cdt-dev@xxxxxxxxxxx
> Subject: [cdt-dev] Modifying AST
> Importance: Low
> 
> Hi all,
> 
> I want to know if there are some APIs for accessing/modifying 
> the AST exists.
> I figured out the API at 
> org.eclipse.cdt.core.dom.rewrite.ASTRewrite but it seems not working.
> 
> In my Example I want to delete something (here the Variable). 
> In my code i would do this:
> 
> public void deleteVar(IASTDeclarator decl) {
> 
>     IASTTranslationUnit ast = decl.getTranslationUnit();
>     IASTNode thisNode = (IASTNode) decl;
>     IASTNode parent = decl.getParent();
>     IASTNode pparentNode = thisNode.getParent().getParent();
>     
>     ASTRewrite astRewriter = ASTRewrite.create(nasted_ast);
> 
>     System.out.println("remove: " + pparentNode.getRawSignature());
>     System.out.println("remove: " + ASTPrinter.print(pparentNode));
>     
>     astRewriter.remove(pparentNode, null);
>     astRewriter.rewriteAST();
>     System.out.println(ast.getRawSignature());
> }
> 
> but it seems to have no effect...
> It runs without any error...
> 
> Your help will be appreciated.
> 
> Wolfgang
> --
> GMX DSL: Internet-, Telefon- und Handy-Flat ab 19,99 EUR/mtl.  
> Bis zu 150 EUR Startguthaben inklusive! 
> http://portal.gmx.net/de/go/dsl 
> _______________________________________________
> cdt-dev mailing list
> cdt-dev@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/cdt-dev
> 


Back to the top