public final void replace(ASTNode node, ASTNode replacement, TextEditGroup editGroup) {
if (node == null) {
throw new IllegalArgumentException();
}
StructuralPropertyDescriptor property;
ASTNode parent;
if (RewriteEventStore.isNewNode(node)) { // replace a new node, bug 164862
PropertyLocation location= this.eventStore.getPropertyLocation(node, RewriteEventStore.NEW);
if (location != null) {
property= location.getProperty();
parent= location.getParent();
} else {
throw new IllegalArgumentException("Node is not part of the rewriter's AST"); //$NON-NLS-1$
}
} else {
property= node.getLocationInParent();
parent= node.getParent();
}
if (property.isChildListProperty()) {
getListRewrite(parent, (ChildListPropertyDescriptor) property).replace(node, replacement, editGroup);
} else {
set(parent, property, replacement, editGroup);
}
}