Trace.entering(Activator.PLUGIN_ID, SyncDebugOptions.METHODS_ENTERING,
this.getClass(), "registerLocalChange", localChange); //$NON-NLS-1$
if (localChange instanceof IDocumentChange) {
final IDocumentChange docChange = (IDocumentChange) localChange;
final ColaDocumentChangeMessage colaMsg = new ColaDocumentChangeMessage(
new DocumentChangeMessage(docChange.getOffset(),
docChange.getLengthOfReplacedText(),
docChange.getText()), localOperationsCount,
remoteOperationsCount);
// If not replacement, we simply add to
// unacknowledgedLocalOperations and add message
// to results
if (!colaMsg.isReplacement()) {
unacknowledgedLocalOperations.add(colaMsg);
localOperationsCount++;
results.add(colaMsg);
} else {
// It *is a replacement message, so we add both a delete and an
// insert message
// First create/add a delete message (text set to "")...
ColaDocumentChangeMessage delMsg = new ColaDocumentChangeMessage(
new DocumentChangeMessage(docChange.getOffset(),
docChange.getLengthOfReplacedText(), ""),
localOperationsCount, remoteOperationsCount);
unacknowledgedLocalOperations.add(delMsg);
localOperationsCount++;
results.add(delMsg);
// Then create/add the insert message (length set to 0)
ColaDocumentChangeMessage insMsg = new ColaDocumentChangeMessage(
new DocumentChangeMessage(docChange.getOffset(), 0,
docChange.getText()), localOperationsCount,
remoteOperationsCount);
unacknowledgedLocalOperations.add(insMsg);
localOperationsCount++;
results.add(insMsg);