Hi,
I want to perform some source code transformations using the class ASTRewrite. I want to insert some ASTNodes (lets say n1, n2, n3) after a known ASTNode (denoted by n) . I could do this with a ListRewrite if the ASTNode n was always in a Block or something like that. But I don't like this assumption and therefore I am searching for another possibility. Currently I am grouping the ASTNodes to a single node n0 with
ASTNode[] nodes = {n, n1, n2, n3};
n=ASTRewrite.createGroupNode(nodes);
Afterwards I replace the node n through n0 with
ASTRewrite.replace(n, n0, null);
That works fine for me in most cases. But sometimes there are nodes missing after the transformation (I do many of these in one CompilationUnit). I assume that the problem has to do with the grouped nodes. Can someone help me?
Thanks,
Jochen