Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[jdt-dev] AST rewrite on other AST.

Hi, I'm trying to fix a bug where a modification needs to be done on a Node (oldNode), that is in another CompilationUnit currently not in scope for the ChangeProposal.

Currently I tried with:

    ASTNode newOldNode= ASTNode.copySubtree(newNode.getAST(), oldNode);

to create the newOldNode and connect it to the AST, but if I add changes to newOldNode it doesn't update the CompilationUnit.

I've also tried with:

    CompilationUnit oldNodeCompilationUnit= ASTResolving.findParentCompilationUnit(oldNode);     ASTRewrite oldNodeRewrite= ASTRewrite.create(oldNodeCompilationUnit.getAST());

and work with oldNodeRewrite, but that doesn't work either.

I've read the article "Abstract Syntax Tree", and it states to use a TextEdit and manipulate files using ITextFileBufferManager, But I hope there a a shorter path to do what I want.


All help appreciated.

Regards,

Kenneth




Back to the top