From 4088b51a273ba11341820026cd0206dc422eeef1 Mon Sep 17 00:00:00 2001 From: Markus Schorn Date: Tue, 22 Jun 2010 11:40:39 +0000 Subject: [PATCH] Bug 312666: Default filesystem on Mac is case insensitive. --- .../internal/core/pdom/indexer/FileExistsCache.java | 12 +++++++++--- .../pdom/indexer/ProjectIndexerInputAdapter.java | 11 ++++++++++- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/FileExistsCache.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/FileExistsCache.java index 0dca3387f23..b47af49a936 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/FileExistsCache.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/FileExistsCache.java @@ -38,8 +38,14 @@ public final class FileExistsCache { public BitSet fIsFile; } private Reference> fCache= null; - + private final boolean fCaseInSensitive; + public FileExistsCache() { + this(CASE_INSENSITIVE); + } + + public FileExistsCache(boolean caseInsensitive) { + fCaseInSensitive= caseInsensitive; fCache= new SoftReference>(new HashMap()); // before running out of memory the entire map will be thrown away. } @@ -54,7 +60,7 @@ public final class FileExistsCache { return false; String name= file.getName(); - if (CASE_INSENSITIVE) + if (fCaseInSensitive) name= name.toUpperCase(); Content avail= getExistsCache().get(parent); @@ -64,7 +70,7 @@ public final class FileExistsCache { avail= EMPTY_STRING_ARRAY; } else { - if (CASE_INSENSITIVE) { + if (fCaseInSensitive) { for (int i = 0; i < files.length; i++) { files[i]= files[i].toUpperCase(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/ProjectIndexerInputAdapter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/ProjectIndexerInputAdapter.java index 7d163a34405..f1f11568987 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/ProjectIndexerInputAdapter.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/ProjectIndexerInputAdapter.java @@ -35,6 +35,7 @@ import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.Path; +import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.content.IContentType; /** @@ -42,7 +43,9 @@ import org.eclipse.core.runtime.content.IContentType; * @since 5.0 */ public class ProjectIndexerInputAdapter extends IndexerInputAdapter { + private static final boolean CASE_INSENSITIVE_FILE_SYSTEM = new File("a").equals(new File("A")); //$NON-NLS-1$//$NON-NLS-2$ private static final AbstractLanguage[] NO_LANGUAGE = new AbstractLanguage[0]; + private final ICProject fCProject; private final HashMap fIflCache; private final FileExistsCache fExistsCache; @@ -59,7 +62,7 @@ public class ProjectIndexerInputAdapter extends IndexerInputAdapter { fProjectPrefix= cproject.getProject().getFullPath().toString() + IPath.SEPARATOR; if (useCache) { fIflCache= new HashMap(); - fExistsCache= new FileExistsCache(); + fExistsCache= new FileExistsCache(isCaseInsensitiveFileSystem()); } else { fIflCache= null; fExistsCache= null; @@ -74,6 +77,12 @@ public class ProjectIndexerInputAdapter extends IndexerInputAdapter { } } + private boolean isCaseInsensitiveFileSystem() { + if (Platform.OS_MACOSX.equals(Platform.getOS())) + return true; + return CASE_INSENSITIVE_FILE_SYSTEM; + } + @Override public IIndexFileLocation resolveASTPath(String astPath) { if (fIflCache == null) {