/**
*/
protected void replaceSource(IStructuredDocumentRegion flatNode, int offset, int length, String source) {
if (flatNode == null)
return;
IStructuredDocument structuredDocument = flatNode.getParentDocument();
if (structuredDocument == null)
return;
if (source == null)
source = new String();
int startOffset = flatNode.getStartOffset();
if (structuredDocument.containsReadOnly(startOffset + offset, length))
return;
// We use 'structuredDocument' as the requester object just so this
// and the other
// format-related 'repalceText' (in replaceSource) can use the same
// requester.
// Otherwise, if requester is not identical,
// the undo group gets "broken" into multiple pieces based
// on the requesters being different. Technically, any unique, common
// requester object would work.
structuredDocument.replaceText(structuredDocument, startOffset + offset, length, source);
}