1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-07 17:56:01 +02:00

NPE in C/C++-search, bug 192205

This commit is contained in:
Markus Schorn 2008-06-18 07:42:51 +00:00
parent 4b6912f7b5
commit db60b3f7b1

View file

@ -67,31 +67,32 @@ public class PDOMSearchResult extends AbstractTextSearchResult implements IEdito
} }
private String getFileName(IEditorPart editor) { private String getFileName(IEditorPart editor) {
IEditorInput input = editor.getEditorInput(); final IEditorInput input= editor.getEditorInput();
IPath path= null;
if (input instanceof FileEditorInput) { if (input instanceof FileEditorInput) {
FileEditorInput fileInput = (FileEditorInput)input; final FileEditorInput fileInput = (FileEditorInput)input;
return fileInput.getFile().getLocation().toOSString(); path= fileInput.getFile().getLocation();
} else if (input instanceof ExternalEditorInput) { } else if (input instanceof ExternalEditorInput) {
ExternalEditorInput extInput = (ExternalEditorInput)input; final ExternalEditorInput extInput = (ExternalEditorInput)input;
return extInput.getStorage().getFullPath().toOSString(); path= extInput.getStorage().getFullPath();
} else if (input instanceof IStorageEditorInput) { } else if (input instanceof IStorageEditorInput) {
try { try {
IStorage storage = ((IStorageEditorInput)input).getStorage(); final IStorage storage= ((IStorageEditorInput)input).getStorage();
if (storage.getFullPath() != null) { path= storage.getFullPath();
return storage.getFullPath().toOSString();
}
} catch (CoreException exc) { } catch (CoreException exc) {
// ignore // ignore
} }
} else if (input instanceof IPathEditorInput) { } else if (input instanceof IPathEditorInput) {
IPath path= ((IPathEditorInput)input).getPath(); path= ((IPathEditorInput)input).getPath();
return path.toOSString(); } else {
}
ILocationProvider provider= (ILocationProvider) input.getAdapter(ILocationProvider.class); ILocationProvider provider= (ILocationProvider) input.getAdapter(ILocationProvider.class);
if (provider != null) { if (provider != null) {
IPath path= provider.getPath(input); path= provider.getPath(input);
return path.toOSString();
} }
}
if (path != null)
return path.toOSString();
return null; return null;
} }