IEditorInput editorInput= editor.getEditorInput();
if (editorInput == null)
return;
IAnnotationModel model= documentProvider.getAnnotationModel(editorInput);
if (model == null)
return;
IDocument document= documentProvider.getDocument(editorInput);
if (document == null)
return;
boolean supportsBatchReplace= (model instanceof IAnnotationModelExtension);
List toBeRemovedAnnotations= new ArrayList();
Iterator iter= model.getAnnotationIterator();
while (iter.hasNext()) {
Annotation annotation= (Annotation) iter.next();
if (SpellingAnnotation.TYPE.equals(annotation.getType())) {
boolean doRemove= word == null;
if (word == null)
doRemove= true;
else {
String annotationWord= null;
Position pos= model.getPosition(annotation);
try {
annotationWord= document.get(pos.getOffset(), pos.getLength());
} catch (BadLocationException e) {
continue;
}
doRemove= word.equals(annotationWord);
}
if (doRemove) {
if (supportsBatchReplace)
toBeRemovedAnnotations.add(annotation);
else
model.removeAnnotation(annotation);
}
}
}
if (supportsBatchReplace && !toBeRemovedAnnotations.isEmpty()) {