IAnnotationModel model = provider.getAnnotationModel(edit.getEditorInput());
if (model == null) {
return;
}
IAnnotationModelExtension modelExtension = (IAnnotationModelExtension) model;
List<Annotation> existing = new ArrayList<Annotation>();
Iterator<Annotation> it = model.getAnnotationIterator();
if (it == null) {
return;
}
while (it.hasNext()) {
existing.add(it.next());
}
IDocument doc = edit.getDocument();
IResource resource = AbstractBreakpointRulerAction.getResourceForDebugMarkers(edit);
IEditorInput externalFileEditorInput = AbstractBreakpointRulerAction.getExternalFileEditorInput(edit);
List<IMarker> markers = AbstractBreakpointRulerAction.getMarkersFromEditorResource(resource, doc,
externalFileEditorInput, 0, false, model);
Map<Annotation, Position> annotationsToAdd = new HashMap<Annotation, Position>();
for (IMarker m : markers) {
Position pos = AbstractBreakpointRulerAction.getMarkerPosition(doc, m, model);
MarkerAnnotation newAnnotation = new MarkerAnnotation(m);
annotationsToAdd.put(newAnnotation, pos);
}
//update all in a single step
modelExtension.replaceAnnotations(existing.toArray(new Annotation[0]), annotationsToAdd);
}