RewriteEvent event= getEvent(parent, property);
if (event != null) {
switch (event.getChangeKind()) {
case RewriteEvent.INSERTED: {
ASTNode node= (ASTNode) event.getNewValue();
TextEditGroup editGroup= getEditGroup(event);
String[] strings= context.getPrefixAndSuffix(indent, node, this.eventStore);
doTextInsert(offset, strings[0], editGroup);
doTextInsert(offset, node, indent, true, editGroup);
doTextInsert(offset, strings[1], editGroup);
return offset;
}
case RewriteEvent.REMOVED: {
ASTNode node= (ASTNode) event.getOriginalValue();
if (endPos == -1) {
endPos= getExtendedEnd(node);
}
TextEditGroup editGroup= getEditGroup(event);
// if there is a prefix, remove the prefix as well
int len= endPos - offset;
doTextRemoveAndVisit(offset, len, node, editGroup);
return endPos;
}
case RewriteEvent.REPLACED: {
ASTNode node= (ASTNode) event.getOriginalValue();
boolean insertNewLine = false;
if (endPos == -1) {
int previousEnd = node.getStartPosition() + node.getLength();
endPos= getExtendedEnd(node);
if (endPos != previousEnd) {
// check if the end is a comment
int token = TokenScanner.END_OF_FILE;
try {
token = getScanner().readNext(previousEnd, false);
} catch(CoreException e) {
// ignore
}
if (token == TerminalTokens.TokenNameCOMMENT_LINE) {
insertNewLine = true;
}
}
}
TextEditGroup editGroup= getEditGroup(event);
int nodeLen= endPos - offset;
ASTNode replacingNode= (ASTNode) event.getNewValue();
String[] strings= context.getPrefixAndSuffix(indent, replacingNode, this.eventStore);
doTextRemoveAndVisit(offset, nodeLen, node, editGroup);