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:
parent
29789baba4
commit
47cf73d0b6
1 changed files with 7 additions and 4 deletions
|
@ -133,8 +133,11 @@ public class SelectionParseAction extends Action {
|
|||
|
||||
//TODO: Change this to work with qualified identifiers
|
||||
public SelSearchNode getSelection( int fPos ) {
|
||||
IDocumentProvider prov = fEditor.getDocumentProvider();
|
||||
IDocument doc = prov.getDocument(fEditor.getEditorInput());
|
||||
IDocumentProvider prov = ( fEditor != null ) ? fEditor.getDocumentProvider() : null;
|
||||
IDocument doc = ( prov != null ) ? prov.getDocument(fEditor.getEditorInput()) : null;
|
||||
|
||||
if( doc == null )
|
||||
return null;
|
||||
|
||||
int pos= fPos;
|
||||
char c;
|
||||
|
@ -182,7 +185,7 @@ public class SelectionParseAction extends Action {
|
|||
|
||||
String seltext = textSelection.getText();
|
||||
SelSearchNode sel = null;
|
||||
if (seltext.length() == 0 ) {
|
||||
if ( seltext == null || seltext.length() == 0 ) {
|
||||
int selStart = textSelection.getOffset();
|
||||
sel = getSelection(selStart);
|
||||
} else {
|
||||
|
@ -196,7 +199,7 @@ public class SelectionParseAction extends Action {
|
|||
|
||||
protected ISelection getSelection() {
|
||||
ISelection sel = null;
|
||||
if (fSite != null){
|
||||
if (fSite != null && fSite.getSelectionProvider() != null ){
|
||||
sel = fSite.getSelectionProvider().getSelection();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue