Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrey Loskutov2017-07-10 07:34:51 +0000
committerAndrey Loskutov2017-07-10 07:34:51 +0000
commit506916a97c81a0aa96091598addb3970c7acc28a (patch)
treea9777224c4d0d9f0d6ae8d2cf7e2151581cd5e8e /org.eclipse.ui.workbench.texteditor
parentbfbbd8e7a75d97ec80de6b4e95d7dc2ba7210943 (diff)
downloadeclipse.platform.text-506916a97c81a0aa96091598addb3970c7acc28a.tar.gz
eclipse.platform.text-506916a97c81a0aa96091598addb3970c7acc28a.tar.xz
eclipse.platform.text-506916a97c81a0aa96091598addb3970c7acc28a.zip
Bug 519426 - AbstractTextEditor should check result of getDocument() toI20170713-0615I20170712-2000I20170711-2000
avoid NPEs Change-Id: I356451fefac791eec7d52f0c7d020f3d9168c8a8 Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
Diffstat (limited to 'org.eclipse.ui.workbench.texteditor')
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/AbstractTextEditor.java19
1 files changed, 13 insertions, 6 deletions
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/AbstractTextEditor.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/AbstractTextEditor.java
index 64c72acccdd..f6b0dd2f1e2 100644
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/AbstractTextEditor.java
+++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/AbstractTextEditor.java
@@ -619,17 +619,21 @@ public abstract class AbstractTextEditor extends EditorPart implements ITextEdit
IDocument document= getDocumentProvider().getDocument(input);
if (fLocalLastEditPosition != null) {
- document.removePosition(fLocalLastEditPosition);
+ if (document != null) {
+ document.removePosition(fLocalLastEditPosition);
+ }
fLocalLastEditPosition= null;
}
if (sel instanceof ITextSelection && !sel.isEmpty()) {
ITextSelection s= (ITextSelection) sel;
fLocalLastEditPosition= new Position(s.getOffset(), s.getLength());
- try {
- document.addPosition(fLocalLastEditPosition);
- } catch (BadLocationException ex) {
- fLocalLastEditPosition= null;
+ if (document != null) {
+ try {
+ document.addPosition(fLocalLastEditPosition);
+ } catch (BadLocationException ex) {
+ fLocalLastEditPosition = null;
+ }
}
}
@@ -6911,7 +6915,10 @@ public abstract class AbstractTextEditor extends EditorPart implements ITextEdit
boolean currentAnnotation= false;
IDocument document= getDocumentProvider().getDocument(getEditorInput());
- int endOfDocument= document.getLength();
+ int endOfDocument = 0;
+ if (document != null) {
+ endOfDocument = document.getLength();
+ }
int distance= Integer.MAX_VALUE;
IAnnotationModel model= getDocumentProvider().getAnnotationModel(getEditorInput());

Back to the top