/** * Replace a node with the contents of a list. * * <p>Technically this will always work, but it really only makes sense if the replaced node is an * element of a list to begin with. */ public static void replaceWithContents(ASTNode<?> node, ast.List<?> source) { ASTNode<?> parent = node.getParent(); int index = parent.getIndexOfChild(node); node.getParent().removeChild(index); for (Object element : source) { parent.insertChild((ASTNode<?>) element, index++); } }