1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-08 10:16:03 +02:00

Fix the label provider for include refs

This commit is contained in:
Alain Magloire 2004-08-26 19:24:54 +00:00
parent 026a3fe1d5
commit dba1ecfdc1
2 changed files with 18 additions and 11 deletions

View file

@ -23,6 +23,7 @@ import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.core.model.IIncludeReference; import org.eclipse.cdt.core.model.IIncludeReference;
import org.eclipse.cdt.core.model.ILibraryReference; import org.eclipse.cdt.core.model.ILibraryReference;
import org.eclipse.cdt.ui.CElementContentProvider; import org.eclipse.cdt.ui.CElementContentProvider;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IPath;
/** /**
@ -73,11 +74,16 @@ public class CViewContentProvider extends CElementContentProvider {
} }
public Object[] getIncludeReferenceChildren(IIncludeReference ref) throws CModelException { 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 location = ref.getPath();
IPath rootPath = ref.getCModel().getWorkspace().getRoot().getLocation(); IContainer[] containers = ref.getCModel().getWorkspace().getRoot().findContainersForLocation(location);
if (rootPath.isPrefixOf(location)) { for (int i = 0; i < containers.length; ++i) {
if (containers[i].isAccessible()) {
return NO_CHILDREN; return NO_CHILDREN;
} }
}
return ref.getChildren(); return ref.getChildren();
} }
@ -185,11 +191,14 @@ public class CViewContentProvider extends CElementContentProvider {
} else if (element instanceof IIncludeReference) { } else if (element instanceof IIncludeReference) {
IIncludeReference ref = (IIncludeReference)element; IIncludeReference ref = (IIncludeReference)element;
IPath location = ref.getPath(); IPath location = ref.getPath();
IPath rootPath = ref.getCModel().getWorkspace().getRoot().getLocation(); IContainer[] containers = ref.getCModel().getWorkspace().getRoot().findContainersForLocation(location);
if (rootPath.isPrefixOf(location)) { for (int i = 0; i < containers.length; ++i) {
if (containers[i].isAccessible()) {
return false; return false;
} }
} }
}
return super.hasChildren(element); return super.hasChildren(element);
} }
} }

View file

@ -54,11 +54,9 @@ public class CViewLabelProvider extends StandardCElementLabelProvider {
return p.toString(); return p.toString();
} }
IPath location = ref.getPath(); IPath location = ref.getPath();
IPath rootPath = ref.getCModel().getWorkspace().getRoot().getLocation(); IContainer[] containers = ref.getCModel().getWorkspace().getRoot().findContainersForLocation(location);
if (rootPath.isPrefixOf(location)) { if (containers.length > 0) {
location = location.setDevice(null); return containers[0].getFullPath().makeRelative().toString();
location = location.removeFirstSegments(rootPath.segmentCount());
return location.toString();
} }
} }
return super.getText(element); return super.getText(element);