use of org.eclipse.jface.text.revisions.RevisionRange in project eclipse.platform.text by eclipse.
the class RevisionPainter method updateOverviewAnnotations.
/**
* Shows (or hides) the overview annotations.
*/
private void updateOverviewAnnotations() {
if (fAnnotationModel == null)
return;
Revision revision = fFocusRevision != null ? fFocusRevision : fSelectedRevision;
Map<Annotation, Position> added = null;
if (revision != null) {
added = new HashMap<>();
for (RevisionRange range : revision.getRegions()) {
try {
IRegion charRegion = toCharRegion(range);
Position position = new Position(charRegion.getOffset(), charRegion.getLength());
Annotation annotation = new RevisionAnnotation(revision.getId());
added.put(annotation, position);
} catch (BadLocationException x) {
// ignore - document was changed, show no annotations
}
}
}
if (fAnnotationModel instanceof IAnnotationModelExtension) {
IAnnotationModelExtension ext = (IAnnotationModelExtension) fAnnotationModel;
ext.replaceAnnotations(fAnnotations.toArray(new Annotation[fAnnotations.size()]), added);
} else {
for (Annotation annotation : fAnnotations) {
fAnnotationModel.removeAnnotation(annotation);
}
if (added != null) {
for (Entry<Annotation, Position> entry : added.entrySet()) {
fAnnotationModel.addAnnotation(entry.getKey(), entry.getValue());
}
}
}
fAnnotations.clear();
if (added != null)
fAnnotations.addAll(added.keySet());
}
use of org.eclipse.jface.text.revisions.RevisionRange in project eclipse.platform.text by eclipse.
the class RevisionPainter method getRanges.
/**
* Returns the sublist of all <code>RevisionRange</code>s that intersect with the given lines.
*
* @param lines the model based lines of interest
* @return elementType: RevisionRange
*/
private List<RevisionRange> getRanges(ILineRange lines) {
List<RevisionRange> ranges = getRangeCache();
// return the interesting subset
int end = end(lines);
int first = -1, last = -1;
for (int i = 0; i < ranges.size(); i++) {
RevisionRange range = ranges.get(i);
int rangeEnd = end(range);
if (first == -1 && rangeEnd > lines.getStartLine())
first = i;
if (first != -1 && rangeEnd > end) {
last = i;
break;
}
}
if (first == -1)
return Collections.emptyList();
if (last == -1)
// bottom index may be one too much
last = ranges.size() - 1;
return ranges.subList(first, last + 1);
}
Aggregations