I am trying to use the Eclipse JDT AST model to replace one MethodInvocation with another. To take a trivial example - I'm trying to replace all calls with Log.(i/e/d/w) with calls to System.out.println() . I use ASTVisitor to find an interesting ASTNode and replace it with a new MethodInvocation node. Here is the code diagram:
class StatementVisitor extends ASTVisitor { @Override public boolean visit(ExpressionStatement node) {
This rewrite is then saved in the original document. All this works great, but for one small problem - the original statement:
Log.i("Hello There");
changes to:
System.out.println("Hello There")
NOTE : there is no semicolon at the end of the statement
QUESTION : how to insert a semicolon at the end of a new statement?
source share