mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 22:52:11 +02:00
Fix for 193088 by Gerhard Schaber, NPE using workspace-root as include entry.
This commit is contained in:
parent
e9f535bcfa
commit
2912b67a36
2 changed files with 14 additions and 9 deletions
|
@ -402,23 +402,25 @@ public class CCommandDSC {
|
|||
}
|
||||
|
||||
private static IResource findResource(IProject project, IPath path) {
|
||||
IResource resource = project.findMember(path, true);
|
||||
IResource resource = project.findMember(path, false);
|
||||
if (resource == null) {
|
||||
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
|
||||
resource = root.findMember(path, true);
|
||||
resource = root.findMember(path, false);
|
||||
if (resource == null) {
|
||||
IResource[] resources = root.findFilesForLocation(path);
|
||||
if (resources != null) {
|
||||
if (project != null) {
|
||||
for (int i = 0; i < resources.length; i++) {
|
||||
if (resources[i].getProject() == project) {
|
||||
final IProject myProject = resources[i].getProject();
|
||||
// resource could be root, then myProject is null.
|
||||
if (myProject != null && myProject.equals(project)) {
|
||||
resource = resources[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
// make a relative path to another project (better than an absolute path)
|
||||
if (resource == null && resources.length > 0) {
|
||||
resource = resources[0];
|
||||
}
|
||||
}
|
||||
// make a relative path to another project (better than an absolute path)
|
||||
if (resource == null && resources.length > 0) {
|
||||
resource = resources[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
package org.eclipse.cdt.internal.ui.cview;
|
||||
|
||||
import org.eclipse.core.resources.IContainer;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.ResourcesPlugin;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.jface.resource.ImageDescriptor;
|
||||
|
@ -52,7 +53,9 @@ public class CViewLabelProvider extends AppearanceAwareLabelProvider {
|
|||
if (prj != null) {
|
||||
for (int i = 0; i < containers.length; i++) {
|
||||
final IContainer container = containers[i];
|
||||
if (container.getProject().equals(prj.getProject())) {
|
||||
final IProject project = container.getProject();
|
||||
// in case the path is empty, the container is the workspace root and project is null.
|
||||
if (project != null && project.equals(prj.getProject())) {
|
||||
return container.getFullPath().makeRelative().toString();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue