1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-05 08:46:02 +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) {
IEditorInput input = editor.getEditorInput();
final IEditorInput input= editor.getEditorInput();
IPath path= null;
if (input instanceof FileEditorInput) {
FileEditorInput fileInput = (FileEditorInput)input;
return fileInput.getFile().getLocation().toOSString();
final FileEditorInput fileInput = (FileEditorInput)input;
path= fileInput.getFile().getLocation();
} else if (input instanceof ExternalEditorInput) {
ExternalEditorInput extInput = (ExternalEditorInput)input;
return extInput.getStorage().getFullPath().toOSString();
final ExternalEditorInput extInput = (ExternalEditorInput)input;
path= extInput.getStorage().getFullPath();
} else if (input instanceof IStorageEditorInput) {
try {
IStorage storage = ((IStorageEditorInput)input).getStorage();
if (storage.getFullPath() != null) {
return storage.getFullPath().toOSString();
}
} catch (CoreException exc) {
// ignore
}
try {
final IStorage storage= ((IStorageEditorInput)input).getStorage();
path= storage.getFullPath();
} catch (CoreException exc) {
// ignore
}
} else if (input instanceof IPathEditorInput) {
IPath path= ((IPathEditorInput)input).getPath();
path= ((IPathEditorInput)input).getPath();
} else {
ILocationProvider provider= (ILocationProvider) input.getAdapter(ILocationProvider.class);
if (provider != null) {
path= provider.getPath(input);
}
}
if (path != null)
return path.toOSString();
}
ILocationProvider provider= (ILocationProvider) input.getAdapter(ILocationProvider.class);
if (provider != null) {
IPath path= provider.getPath(input);
return path.toOSString();
}
return null;
}