From dba1ecfdc17e09f97466371e3effbd35b04e5b18 Mon Sep 17 00:00:00 2001 From: Alain Magloire Date: Thu, 26 Aug 2004 19:24:54 +0000 Subject: [PATCH] Fix the label provider for include refs --- .../ui/cview/CViewContentProvider.java | 21 +++++++++++++------ .../internal/ui/cview/CViewLabelProvider.java | 8 +++---- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewContentProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewContentProvider.java index 4bc53b6f69b..5846b7858b0 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewContentProvider.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewContentProvider.java @@ -23,6 +23,7 @@ import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.core.model.IIncludeReference; import org.eclipse.cdt.core.model.ILibraryReference; import org.eclipse.cdt.ui.CElementContentProvider; +import org.eclipse.core.resources.IContainer; import org.eclipse.core.runtime.IPath; /** @@ -73,10 +74,15 @@ public class CViewContentProvider extends CElementContentProvider { } public Object[] getIncludeReferenceChildren(IIncludeReference ref) throws CModelException { + // We do not want to show children for Include paths that are inside the workspace. + // no need to that since they can access elsewhere and that simplifies the + // CView code. IPath location = ref.getPath(); - IPath rootPath = ref.getCModel().getWorkspace().getRoot().getLocation(); - if (rootPath.isPrefixOf(location)) { - return NO_CHILDREN; + IContainer[] containers = ref.getCModel().getWorkspace().getRoot().findContainersForLocation(location); + for (int i = 0; i < containers.length; ++i) { + if (containers[i].isAccessible()) { + return NO_CHILDREN; + } } return ref.getChildren(); } @@ -185,10 +191,13 @@ public class CViewContentProvider extends CElementContentProvider { } else if (element instanceof IIncludeReference) { IIncludeReference ref = (IIncludeReference)element; IPath location = ref.getPath(); - IPath rootPath = ref.getCModel().getWorkspace().getRoot().getLocation(); - if (rootPath.isPrefixOf(location)) { - return false; + IContainer[] containers = ref.getCModel().getWorkspace().getRoot().findContainersForLocation(location); + for (int i = 0; i < containers.length; ++i) { + if (containers[i].isAccessible()) { + return false; + } } + } return super.hasChildren(element); } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewLabelProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewLabelProvider.java index c78476ce165..d011a276aa9 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewLabelProvider.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewLabelProvider.java @@ -54,11 +54,9 @@ public class CViewLabelProvider extends StandardCElementLabelProvider { return p.toString(); } IPath location = ref.getPath(); - IPath rootPath = ref.getCModel().getWorkspace().getRoot().getLocation(); - if (rootPath.isPrefixOf(location)) { - location = location.setDevice(null); - location = location.removeFirstSegments(rootPath.segmentCount()); - return location.toString(); + IContainer[] containers = ref.getCModel().getWorkspace().getRoot().findContainersForLocation(location); + if (containers.length > 0) { + return containers[0].getFullPath().makeRelative().toString(); } } return super.getText(element);