Search in sources :

Example 1 with IAnnotationMap

use of org.eclipse.jface.text.source.IAnnotationMap in project eclipse.platform.text by eclipse.

the class AbstractMarkerAnnotationModel method updateMarkers.

/**
 * Updates the markers managed by this annotation model by calling
 * all registered marker updaters (<code>IMarkerUpdater</code>).
 *
 * @param document the document to which this model is currently connected
 * @throws CoreException if there is a problem updating the markers
 */
public void updateMarkers(IDocument document) throws CoreException {
    Assert.isTrue(fDocument == document);
    IAnnotationMap annotationMap = getAnnotationMap();
    if (annotationMap.size() == 0 && fDeletedAnnotations.size() == 0)
        return;
    if (fMarkerUpdaterSpecifications == null)
        installMarkerUpdaters();
    listenToMarkerChanges(false);
    try {
        // update all markers with the positions known by the annotation model
        for (Iterator<Annotation> e = getAnnotationIterator(false); e.hasNext(); ) {
            Object o = e.next();
            if (o instanceof MarkerAnnotation) {
                MarkerAnnotation a = (MarkerAnnotation) o;
                IMarker marker = a.getMarker();
                Position position = annotationMap.get(a);
                if (!updateMarker(marker, document, position)) {
                    if (!fDeletedAnnotations.contains(a))
                        fDeletedAnnotations.add(a);
                }
            }
        }
        if (!fDeletedAnnotations.isEmpty()) {
            removeAnnotations(fDeletedAnnotations, true, true);
            fDeletedAnnotations.clear();
        }
    } finally {
        listenToMarkerChanges(true);
    }
}
Also used : Position(org.eclipse.jface.text.Position) IMarker(org.eclipse.core.resources.IMarker) IAnnotationMap(org.eclipse.jface.text.source.IAnnotationMap) Annotation(org.eclipse.jface.text.source.Annotation)

Aggregations

IMarker (org.eclipse.core.resources.IMarker)1 Position (org.eclipse.jface.text.Position)1 Annotation (org.eclipse.jface.text.source.Annotation)1 IAnnotationMap (org.eclipse.jface.text.source.IAnnotationMap)1