Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMilos Kleint2011-02-09 10:26:40 -0500
committerMilos Kleint2011-02-09 10:26:40 -0500
commitd61b0c8c16c8205f19e6c3ac1293c8f19539db0d (patch)
tree15485756f9767cefdb6ba744f62db2a277ae3440 /org.eclipse.m2e.editor.xml
parentc144d865e7ae89420104bf30a8286a7d952cc426 (diff)
downloadm2e-core-d61b0c8c16c8205f19e6c3ac1293c8f19539db0d.tar.gz
m2e-core-d61b0c8c16c8205f19e6c3ac1293c8f19539db0d.tar.xz
m2e-core-d61b0c8c16c8205f19e6c3ac1293c8f19539db0d.zip
fix test
Diffstat (limited to 'org.eclipse.m2e.editor.xml')
-rw-r--r--org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/PomTextHover.java18
1 files changed, 11 insertions, 7 deletions
diff --git a/org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/PomTextHover.java b/org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/PomTextHover.java
index 8b5ac6c3..6c7b8442 100644
--- a/org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/PomTextHover.java
+++ b/org.eclipse.m2e.editor.xml/src/main/java/org/eclipse/m2e/editor/xml/PomTextHover.java
@@ -31,6 +31,7 @@ import org.eclipse.jface.text.ITextHoverExtension2;
import org.eclipse.jface.text.ITextViewer;
import org.eclipse.jface.text.Position;
import org.eclipse.jface.text.source.Annotation;
+import org.eclipse.jface.text.source.IAnnotationModel;
import org.eclipse.jface.text.source.ISourceViewer;
import org.eclipse.jface.viewers.StyledString;
import org.eclipse.osgi.util.NLS;
@@ -161,13 +162,16 @@ public class PomTextHover implements ITextHover, ITextHoverExtension, ITextHover
}
if (textViewer instanceof ISourceViewer) {
ISourceViewer sourceViewer = (ISourceViewer) textViewer;
- Iterator<Annotation> it = sourceViewer.getAnnotationModel().getAnnotationIterator();
- while (it.hasNext()) {
- Annotation ann = it.next();
- if (ann instanceof MarkerAnnotation) {
- Position pos = sourceViewer.getAnnotationModel().getPosition(ann);
- if (pos.includes(offset)) {
- toRet.addRegion( new MarkerRegion(pos.getOffset(), pos.getLength(), (MarkerAnnotation)ann));
+ IAnnotationModel model = sourceViewer.getAnnotationModel();
+ if (model != null) { //eg. in tests
+ Iterator<Annotation> it = model.getAnnotationIterator();
+ while (it.hasNext()) {
+ Annotation ann = it.next();
+ if (ann instanceof MarkerAnnotation) {
+ Position pos = sourceViewer.getAnnotationModel().getPosition(ann);
+ if (pos.includes(offset)) {
+ toRet.addRegion( new MarkerRegion(pos.getOffset(), pos.getLength(), (MarkerAnnotation)ann));
+ }
}
}
}

Back to the top