Wrap Multiple Document Changes into one Compound Change

If multiple changes on a document of a TextViewer or SourceViewer should be undo/redo-able with a single action then it must be wrapped into a compound change.

IRewriteTarget target= viewer.getRewriteTarget();
target.beginCompoundChange();
try {
    ...
    doTheChanges();
    ...
} finally {
    target.endCompoundChange();
}