summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorszarnekow2008-12-24 09:14:12 (EST)
committer sefftinge2008-12-24 09:14:12 (EST)
commit34c6425f47028d82d87ebfb1076502a575517b37 (patch)
treedb957d6180d539d69df41abebd0b2de859c57fe2
parentfde13081f6014fdc3991035029d2dc414ab0e45f (diff)
downloadorg.eclipse.xtext-34c6425f47028d82d87ebfb1076502a575517b37.zip
org.eclipse.xtext-34c6425f47028d82d87ebfb1076502a575517b37.tar.gz
org.eclipse.xtext-34c6425f47028d82d87ebfb1076502a575517b37.tar.bz2
dont try to add model listener if document is null
-rw-r--r--plugins/org.eclipse.xtext.ui.core/src/org/eclipse/xtext/ui/core/editor/XtextSourceViewer.java15
1 files changed, 12 insertions, 3 deletions
diff --git a/plugins/org.eclipse.xtext.ui.core/src/org/eclipse/xtext/ui/core/editor/XtextSourceViewer.java b/plugins/org.eclipse.xtext.ui.core/src/org/eclipse/xtext/ui/core/editor/XtextSourceViewer.java
index 122ddde..310a97a 100644
--- a/plugins/org.eclipse.xtext.ui.core/src/org/eclipse/xtext/ui/core/editor/XtextSourceViewer.java
+++ b/plugins/org.eclipse.xtext.ui.core/src/org/eclipse/xtext/ui/core/editor/XtextSourceViewer.java
@@ -59,21 +59,30 @@ public class XtextSourceViewer extends ProjectionViewer implements IXtextSourceV
@Override
public void setDocument(IDocument document, IAnnotationModel annotationModel) {
+ if (getDocument() != null)
+ ((IXtextDocument) getDocument()).removeModelListener(this);
super.setDocument(document, annotationModel);
- ((IXtextDocument) getDocument()).addModelListener(this);
+ if (document != null)
+ ((IXtextDocument) getDocument()).addModelListener(this);
}
@Override
public void setDocument(IDocument document, IAnnotationModel annotationModel, int modelRangeOffset,
int modelRangeLength) {
+ if (getDocument() != null)
+ ((IXtextDocument) getDocument()).removeModelListener(this);
super.setDocument(document, annotationModel, modelRangeOffset, modelRangeLength);
- ((IXtextDocument) getDocument()).addModelListener(this);
+ if (document != null)
+ ((IXtextDocument) getDocument()).addModelListener(this);
}
@Override
public void setDocument(IDocument document, int visibleRegionOffset, int visibleRegionLength) {
+ if (getDocument() != null)
+ ((IXtextDocument) getDocument()).removeModelListener(this);
super.setDocument(document, visibleRegionOffset, visibleRegionLength);
- ((IXtextDocument) getDocument()).addModelListener(this);
+ if (document != null)
+ ((IXtextDocument) getDocument()).addModelListener(this);
}
/*