1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-04 14:55:41 +02:00

Bug 312666: Default file system on Mac is case insensitive.

This commit is contained in:
Markus Schorn 2010-11-04 10:05:08 +00:00
parent c465508c81
commit 279038ad18
5 changed files with 19 additions and 12 deletions

View file

@ -33,12 +33,13 @@ import org.eclipse.core.runtime.Path;
*/ */
public class StandaloneIndexerInputAdapter extends IndexerInputAdapter { public class StandaloneIndexerInputAdapter extends IndexerInputAdapter {
private final HashMap<String, IIndexFileLocation> fIflCache= new HashMap<String, IIndexFileLocation>(); private final HashMap<String, IIndexFileLocation> fIflCache= new HashMap<String, IIndexFileLocation>();
private final FileExistsCache fExistsCache = new FileExistsCache(); private final FileExistsCache fExistsCache;
private final StandaloneIndexer fIndexer; private final StandaloneIndexer fIndexer;
public StandaloneIndexerInputAdapter(StandaloneIndexer indexer) { public StandaloneIndexerInputAdapter(StandaloneIndexer indexer) {
fIndexer= indexer; fIndexer= indexer;
fExistsCache= new FileExistsCache(isCaseInsensitiveFileSystem());
} }
@Override @Override
@ -184,4 +185,11 @@ public class StandaloneIndexerInputAdapter extends IndexerInputAdapter {
return true; return true;
return fIndexer.getValidSourceUnitNames().contains(path.getFileExtension()); return fIndexer.getValidSourceUnitNames().contains(path.getFileExtension());
} }
@SuppressWarnings("nls")
@Override
public boolean isCaseInsensitiveFileSystem() {
return new File("a").equals(new File("A"));
}
} }

View file

@ -49,4 +49,9 @@ public abstract class ASTFilePathResolver {
* Returns the size of the file in bytes, or -1 if it cannot be determined * Returns the size of the file in bytes, or -1 if it cannot be determined
*/ */
public abstract long getFileSize(String astFilePath); public abstract long getFileSize(String astFilePath);
/**
* Returns whether the file-system is case insensitive.
*/
public abstract boolean isCaseInsensitiveFileSystem();
} }

View file

@ -26,7 +26,6 @@ import java.util.Map;
*/ */
public final class FileExistsCache { public final class FileExistsCache {
private static final Content EMPTY_STRING_ARRAY= new Content(new String[0]); private static final Content EMPTY_STRING_ARRAY= new Content(new String[0]);
private static final boolean CASE_INSENSITIVE = new File("a").equals(new File("A")); //$NON-NLS-1$ //$NON-NLS-2$
private static boolean BYPASS_CACHE= Boolean.getBoolean("CDT_INDEXER_BYPASS_FILE_EXISTS_CACHE"); //$NON-NLS-1$ private static boolean BYPASS_CACHE= Boolean.getBoolean("CDT_INDEXER_BYPASS_FILE_EXISTS_CACHE"); //$NON-NLS-1$
private static class Content { private static class Content {
@ -40,10 +39,6 @@ public final class FileExistsCache {
private Reference<Map<String,Content>> fCache= null; private Reference<Map<String,Content>> fCache= null;
private final boolean fCaseInSensitive; private final boolean fCaseInSensitive;
public FileExistsCache() {
this(CASE_INSENSITIVE);
}
public FileExistsCache(boolean caseInsensitive) { public FileExistsCache(boolean caseInsensitive) {
fCaseInSensitive= caseInsensitive; fCaseInSensitive= caseInsensitive;
fCache= new SoftReference<Map<String,Content>>(new HashMap<String, Content>()); // before running out of memory the entire map will be thrown away. fCache= new SoftReference<Map<String,Content>>(new HashMap<String, Content>()); // before running out of memory the entire map will be thrown away.

View file

@ -10,7 +10,6 @@
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.pdom.indexer; package org.eclipse.cdt.internal.core.pdom.indexer;
import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
@ -33,16 +32,15 @@ import org.eclipse.core.runtime.Path;
public class ProjectIndexerIncludeResolutionHeuristics implements IIncludeFileResolutionHeuristics { public class ProjectIndexerIncludeResolutionHeuristics implements IIncludeFileResolutionHeuristics {
private static final String TRUE = "true"; //$NON-NLS-1$ private static final String TRUE = "true"; //$NON-NLS-1$
@SuppressWarnings("nls")
private static final boolean IGNORE_CASE = new File("a").equals(new File("A"));
private IProject fProject; private IProject fProject;
private IProject[] fProjects; private IProject[] fProjects;
private final ASTFilePathResolver fResolver; private final ASTFilePathResolver fResolver;
private final boolean fIgnoreCase;
public ProjectIndexerIncludeResolutionHeuristics(IProject project, ASTFilePathResolver resolver) { public ProjectIndexerIncludeResolutionHeuristics(IProject project, ASTFilePathResolver resolver) {
fProject= project; fProject= project;
fResolver= resolver; fResolver= resolver;
fIgnoreCase= resolver.isCaseInsensitiveFileSystem();
} }
public String findInclusion(String include, String currentFile) { public String findInclusion(String include, String currentFile) {
@ -68,7 +66,7 @@ public class ProjectIndexerIncludeResolutionHeuristics implements IIncludeFileRe
} }
} }
IFile[] files= ResourceLookup.findFilesByName(new Path(include), fProjects, IGNORE_CASE); IFile[] files= ResourceLookup.findFilesByName(new Path(include), fProjects, fIgnoreCase);
if (files.length == 0) if (files.length == 0)
return null; return null;

View file

@ -79,7 +79,8 @@ public class ProjectIndexerInputAdapter extends IndexerInputAdapter {
} }
} }
private boolean isCaseInsensitiveFileSystem() { @Override
public boolean isCaseInsensitiveFileSystem() {
if (Platform.OS_MACOSX.equals(Platform.getOS())) if (Platform.OS_MACOSX.equals(Platform.getOS()))
return true; return true;
return CASE_INSENSITIVE_FILE_SYSTEM; return CASE_INSENSITIVE_FILE_SYSTEM;