1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Fix for 192707, presentation of include nodes with duplicate (linked) resources.

This commit is contained in:
Markus Schorn 2007-06-15 09:27:30 +00:00
parent 3025d9e338
commit d94281c9ff

View file

@ -8,15 +8,18 @@
* Contributors: * Contributors:
* QNX Software Systems - Initial API and implementation * QNX Software Systems - Initial API and implementation
* Anton Leherbauer (Wind River Systems) * Anton Leherbauer (Wind River Systems)
* Markus Schorn (Wind River Systems)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.ui.cview; package org.eclipse.cdt.internal.ui.cview;
import org.eclipse.core.resources.IContainer; import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IPath;
import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.swt.graphics.Image; import org.eclipse.swt.graphics.Image;
import org.eclipse.cdt.core.model.ICElement; import org.eclipse.cdt.core.model.ICElement;
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.ITranslationUnit; import org.eclipse.cdt.core.model.ITranslationUnit;
import org.eclipse.cdt.ui.CElementImageDescriptor; import org.eclipse.cdt.ui.CElementImageDescriptor;
@ -40,10 +43,20 @@ public class CViewLabelProvider extends AppearanceAwareLabelProvider {
*/ */
public String getText(Object element) { public String getText(Object element) {
if (element instanceof IncludeReferenceProxy) { if (element instanceof IncludeReferenceProxy) {
IIncludeReference ref = ((IncludeReferenceProxy)element).getReference(); final IIncludeReference ref = ((IncludeReferenceProxy)element).getReference();
IPath location = ref.getPath(); final IPath location = ref.getPath();
IContainer[] containers = ref.getCModel().getWorkspace().getRoot().findContainersForLocation(location); final IContainer[] containers= ResourcesPlugin.getWorkspace().getRoot().findContainersForLocation(location);
if (containers.length > 0) { if (containers.length > 0) {
// bug 192707, prefer the project the reference belongs to.
final ICProject prj= ref.getCProject();
if (prj != null) {
for (int i = 0; i < containers.length; i++) {
final IContainer container = containers[i];
if (container.getProject().equals(prj.getProject())) {
return container.getFullPath().makeRelative().toString();
}
}
}
return containers[0].getFullPath().makeRelative().toString(); return containers[0].getFullPath().makeRelative().toString();
} }
} else if (element instanceof IIncludeReference) { } else if (element instanceof IIncludeReference) {