1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

guard against possible NPEs

This commit is contained in:
Andrew Niefer 2004-06-02 21:40:22 +00:00
parent 29789baba4
commit 47cf73d0b6

View file

@ -133,8 +133,11 @@ public class SelectionParseAction extends Action {
//TODO: Change this to work with qualified identifiers //TODO: Change this to work with qualified identifiers
public SelSearchNode getSelection( int fPos ) { public SelSearchNode getSelection( int fPos ) {
IDocumentProvider prov = fEditor.getDocumentProvider(); IDocumentProvider prov = ( fEditor != null ) ? fEditor.getDocumentProvider() : null;
IDocument doc = prov.getDocument(fEditor.getEditorInput()); IDocument doc = ( prov != null ) ? prov.getDocument(fEditor.getEditorInput()) : null;
if( doc == null )
return null;
int pos= fPos; int pos= fPos;
char c; char c;
@ -182,7 +185,7 @@ public class SelectionParseAction extends Action {
String seltext = textSelection.getText(); String seltext = textSelection.getText();
SelSearchNode sel = null; SelSearchNode sel = null;
if (seltext.length() == 0 ) { if ( seltext == null || seltext.length() == 0 ) {
int selStart = textSelection.getOffset(); int selStart = textSelection.getOffset();
sel = getSelection(selStart); sel = getSelection(selStart);
} else { } else {
@ -196,7 +199,7 @@ public class SelectionParseAction extends Action {
protected ISelection getSelection() { protected ISelection getSelection() {
ISelection sel = null; ISelection sel = null;
if (fSite != null){ if (fSite != null && fSite.getSelectionProvider() != null ){
sel = fSite.getSelectionProvider().getSelection(); sel = fSite.getSelectionProvider().getSelection();
} }