Skip to main content

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

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


Back to the top