mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-08 02:06:01 +02:00
Fix the label provider for include refs
This commit is contained in:
parent
026a3fe1d5
commit
dba1ecfdc1
2 changed files with 18 additions and 11 deletions
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Add table
Reference in a new issue