*/
public TextPresentation createPresentation(
TreeSet<HighlightedPosition> addedPositions,
List<HighlightedPosition> removedPositions) {
SourceViewer sourceViewer = fSourceViewer;
ATGPresentationReconciler presentationReconciler = fPresentationReconciler;
if (sourceViewer == null || presentationReconciler == null) {
return null;
}
if (isCanceled()) {
return null;
}
IDocument document = sourceViewer.getDocument();
if (document == null) {
return null;
}
int minStart = Integer.MAX_VALUE;
int maxEnd = Integer.MIN_VALUE;
for (HighlightedPosition h : removedPositions) {
int offset = h.getOffset();
minStart = Math.min(minStart, offset);
maxEnd = Math.max(maxEnd, offset + h.getLength());
}
for (HighlightedPosition h : addedPositions) {
int offset = h.getOffset();
minStart = Math.min(minStart, offset);
maxEnd = Math.max(maxEnd, offset + h.getLength());
}
if (minStart < maxEnd) {
try {
minStart = Math.min(minStart, document.getLength());
maxEnd = Math.min(maxEnd, document.getLength());
synchronized (getLockObject(document)) {
return presentationReconciler.createRepairDescription(
new Region(minStart, maxEnd - minStart), document);
}
} catch (RuntimeException e) {
// concurrent modification from UI thread
}