RewriteEvent event= getEvent(parent, MethodDeclaration.BODY_PROPERTY);
if (event != null) {
switch (event.getChangeKind()) {
case RewriteEvent.INSERTED: {
int endPos= parent.getStartPosition() + parent.getLength();
TextEditGroup editGroup= getEditGroup(event);
ASTNode body= (ASTNode) event.getNewValue();
doTextRemove(startPos, endPos - startPos, editGroup);
int indent= getIndent(parent.getStartPosition());
String prefix= this.formatter.METHOD_BODY.getPrefix(indent);
doTextInsert(startPos, prefix, editGroup);
doTextInsert(startPos, body, indent, true, editGroup);
return;
}
case RewriteEvent.REMOVED: {
TextEditGroup editGroup= getEditGroup(event);
ASTNode body= (ASTNode) event.getOriginalValue();
int endPos= parent.getStartPosition() + parent.getLength();
doTextRemoveAndVisit(startPos, endPos - startPos, body, editGroup);
doTextInsert(startPos, ";", editGroup); //$NON-NLS-1$
return;
}
case RewriteEvent.REPLACED: {
TextEditGroup editGroup= getEditGroup(event);
ASTNode body= (ASTNode) event.getOriginalValue();
doTextRemoveAndVisit(body.getStartPosition(), body.getLength(), body, editGroup);
doTextInsert(body.getStartPosition(), (ASTNode) event.getNewValue(), getIndent(body.getStartPosition()), true, editGroup);
return;
}