}
Object data= curr.data;
if (data instanceof TextEditGroup) { // tracking a node
// need to split and create 2 edits as tracking node can surround replaced node.
TextEdit edit= new RangeMarker(insertOffset, 0);
addEditGroup((TextEditGroup) data, edit);
addEdit(edit);
if (curr.length != 0) {
int end= offset + curr.length;
int k= i + 1;
while (k < markers.size() && ((NodeMarker) markers.get(k)).offset < end) {
k++;
}
curr.offset= end;
curr.length= 0;
markers.add(k, curr); // add again for end position
}
currPos= offset;
} else {
String destIndentString= this.formatter.getIndentString(getCurrentLine(formatted, offset));
if (data instanceof CopyPlaceholderData) { // replace with a copy/move target
CopySourceInfo copySource= ((CopyPlaceholderData) data).copySource;
int srcIndentLevel= getIndent(copySource.getNode().getStartPosition());
TextEdit sourceEdit= getCopySourceEdit(copySource);
doTextCopy(sourceEdit, insertOffset, srcIndentLevel, destIndentString, editGroup);
currPos= offset + curr.length; // continue to insert after the replaced string
if (needsNewLineForLineComment(copySource.getNode(), formatted, currPos)) {
doTextInsert(insertOffset, getLineDelimiter(), editGroup);
}