From e43c9eb5a9f7e1ebc49b1f5a6d3d60201189ee97 Mon Sep 17 00:00:00 2001 From: Markus Schorn Date: Wed, 17 Sep 2008 09:15:13 +0000 Subject: [PATCH] Follow up for symbolic links in include search path, bug 246524. --- .../cdt/core/index/IndexLocationFactory.java | 49 ++++++++++--------- 1 file changed, 25 insertions(+), 24 deletions(-) diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/IndexLocationFactory.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/IndexLocationFactory.java index 5c21dca6af7..70d2197279f 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/IndexLocationFactory.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/IndexLocationFactory.java @@ -114,36 +114,37 @@ public class IndexLocationFactory { */ public static IIndexFileLocation getIFLExpensive(ICProject cproject, String absolutePath) { IFile[] files = ResourcesPlugin.getWorkspace().getRoot().findFilesForLocation(new Path(absolutePath)); - switch(files.length) { - case 0: - return getExternalIFL(absolutePath); - case 1: - return getWorkspaceIFL(files[0]); - } - - Arrays.sort(files, new FILE_COMPARATOR()); - final IProject preferredProject= cproject == null ? null : cproject.getProject(); - IFile fileInCProject= null; - for (IFile file : files) { - // check for preferred project - final IProject project = file.getProject(); - if (preferredProject != null && preferredProject.equals(project)) + if (files.length==1) { + IFile file = files[0]; + if (file.exists()) return getWorkspaceIFL(file); - - if (fileInCProject == null) { - try { - if (project.hasNature(CProjectNature.C_NATURE_ID)) { - fileInCProject= file; + } else { + Arrays.sort(files, new FILE_COMPARATOR()); + final IProject preferredProject= cproject == null ? null : cproject.getProject(); + IFile fileInCProject= null; + for (IFile file : files) { + if (file.exists()) { + // check for preferred project + final IProject project = file.getProject(); + if (preferredProject != null && preferredProject.equals(project)) + return getWorkspaceIFL(file); + + if (fileInCProject == null) { + try { + if (project.hasNature(CProjectNature.C_NATURE_ID)) { + fileInCProject= file; + } + } catch (CoreException e) { + // treat as non-c project + } } - } catch (CoreException e) { - // treat as non-c project } } + if (fileInCProject != null) + return getWorkspaceIFL(fileInCProject); } - if (fileInCProject != null) - return getWorkspaceIFL(fileInCProject); - return getWorkspaceIFL(files[0]); + return getExternalIFL(absolutePath); } /**