if (DEBUG) {
System.out.println("no document provider"); //$NON-NLS-1$
}
return;
}
IAnnotationModel annotationModel = documentProvider.getAnnotationModel(textEditor.getEditorInput());
if (annotationModel == null) {
if (DEBUG) {
System.out.println("no annotation model"); //$NON-NLS-1$
}
return;
}
Iterator annotationIterator = annotationModel.getAnnotationIterator();
List oldAnnotations = new ArrayList();
while (annotationIterator.hasNext()) {
Annotation annotation = (Annotation) annotationIterator.next();
if (ANNOTATION_TYPE.equals(annotation.getType())) {
annotation.markDeleted(true);
/**
* Sometimes it is supported, sometime's it is not. Confusing.
*/
try {
annotationIterator.remove();
}
catch (UnsupportedOperationException e) {
oldAnnotations.add(annotation);
}
if (DEBUG) {
System.out.println("removed " + annotation); //$NON-NLS-1$
}
if (!allMatching)
break;
}
}
if (!oldAnnotations.isEmpty()) {
int size = oldAnnotations.size();
for (int i = 0; i < size; i++) {
annotationModel.removeAnnotation((Annotation) oldAnnotations.get(i));
}
}
}