Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKarsten Thoms2019-10-28 16:43:18 +0000
committerMickael Istria2019-10-28 18:52:24 +0000
commit8797cf932e7412843f0b3b1eec68c5d299bc58b6 (patch)
tree8711bc838a8051d47285ae5094db64172a7cec25
parentdf9dfa9ffc21130c92f18bfe7b9a268121780c36 (diff)
downloadeclipse.platform.text-8797cf932e7412843f0b3b1eec68c5d299bc58b6.tar.gz
eclipse.platform.text-8797cf932e7412843f0b3b1eec68c5d299bc58b6.tar.xz
eclipse.platform.text-8797cf932e7412843f0b3b1eec68c5d299bc58b6.zip
sourceViewer.getAnnotationModel() might return null, which could cause a NPE when not guarded. Also set fOccurrenceAnnotations to null when no current annotation model is present. Change-Id: Id37edf61ddfb8bbfb329b4282386e30095400190 Signed-off-by: Karsten Thoms <karsten.thoms@itemis.de>
-rw-r--r--org.eclipse.ui.genericeditor/src/org/eclipse/ui/internal/genericeditor/DefaultWordHighlightStrategy.java24
1 files changed, 14 insertions, 10 deletions
diff --git a/org.eclipse.ui.genericeditor/src/org/eclipse/ui/internal/genericeditor/DefaultWordHighlightStrategy.java b/org.eclipse.ui.genericeditor/src/org/eclipse/ui/internal/genericeditor/DefaultWordHighlightStrategy.java
index d5bdcbadd..f7385d781 100644
--- a/org.eclipse.ui.genericeditor/src/org/eclipse/ui/internal/genericeditor/DefaultWordHighlightStrategy.java
+++ b/org.eclipse.ui.genericeditor/src/org/eclipse/ui/internal/genericeditor/DefaultWordHighlightStrategy.java
@@ -105,18 +105,22 @@ public class DefaultWordHighlightStrategy implements IReconcilingStrategy, IReco
}
IAnnotationModel annotationModel = sourceViewer.getAnnotationModel();
- synchronized (getLockObject(annotationModel)) {
- if (annotationModel instanceof IAnnotationModelExtension) {
- ((IAnnotationModelExtension) annotationModel).replaceAnnotations(fOccurrenceAnnotations, annotationMap);
- } else {
- removeOccurrenceAnnotations();
- Iterator<Entry<Annotation, Position>> iter = annotationMap.entrySet().iterator();
- while (iter.hasNext()) {
- Entry<Annotation, Position> mapEntry = iter.next();
- annotationModel.addAnnotation(mapEntry.getKey(), mapEntry.getValue());
+ if (annotationModel != null) {
+ synchronized (getLockObject(annotationModel)) {
+ if (annotationModel instanceof IAnnotationModelExtension) {
+ ((IAnnotationModelExtension) annotationModel).replaceAnnotations(fOccurrenceAnnotations, annotationMap);
+ } else {
+ removeOccurrenceAnnotations();
+ Iterator<Entry<Annotation, Position>> iter = annotationMap.entrySet().iterator();
+ while (iter.hasNext()) {
+ Entry<Annotation, Position> mapEntry = iter.next();
+ annotationModel.addAnnotation(mapEntry.getKey(), mapEntry.getValue());
+ }
}
+ fOccurrenceAnnotations = annotationMap.keySet().toArray(new Annotation[annotationMap.keySet().size()]);
}
- fOccurrenceAnnotations = annotationMap.keySet().toArray(new Annotation[annotationMap.keySet().size()]);
+ } else {
+ fOccurrenceAnnotations = null;
}
}

Back to the top