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:
parent
c465508c81
commit
279038ad18
5 changed files with 19 additions and 12 deletions
|
@ -33,12 +33,13 @@ import org.eclipse.core.runtime.Path;
|
|||
*/
|
||||
public class StandaloneIndexerInputAdapter extends IndexerInputAdapter {
|
||||
private final HashMap<String, IIndexFileLocation> fIflCache= new HashMap<String, IIndexFileLocation>();
|
||||
private final FileExistsCache fExistsCache = new FileExistsCache();
|
||||
private final FileExistsCache fExistsCache;
|
||||
|
||||
private final StandaloneIndexer fIndexer;
|
||||
|
||||
public StandaloneIndexerInputAdapter(StandaloneIndexer indexer) {
|
||||
fIndexer= indexer;
|
||||
fExistsCache= new FileExistsCache(isCaseInsensitiveFileSystem());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -184,4 +185,11 @@ public class StandaloneIndexerInputAdapter extends IndexerInputAdapter {
|
|||
return true;
|
||||
return fIndexer.getValidSourceUnitNames().contains(path.getFileExtension());
|
||||
}
|
||||
|
||||
@SuppressWarnings("nls")
|
||||
@Override
|
||||
public boolean isCaseInsensitiveFileSystem() {
|
||||
return new File("a").equals(new File("A"));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -49,4 +49,9 @@ public abstract class ASTFilePathResolver {
|
|||
* Returns the size of the file in bytes, or -1 if it cannot be determined
|
||||
*/
|
||||
public abstract long getFileSize(String astFilePath);
|
||||
|
||||
/**
|
||||
* Returns whether the file-system is case insensitive.
|
||||
*/
|
||||
public abstract boolean isCaseInsensitiveFileSystem();
|
||||
}
|
||||
|
|
|
@ -26,7 +26,6 @@ import java.util.Map;
|
|||
*/
|
||||
public final class FileExistsCache {
|
||||
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 class Content {
|
||||
|
@ -40,10 +39,6 @@ public final class FileExistsCache {
|
|||
private Reference<Map<String,Content>> fCache= null;
|
||||
private final boolean fCaseInSensitive;
|
||||
|
||||
public FileExistsCache() {
|
||||
this(CASE_INSENSITIVE);
|
||||
}
|
||||
|
||||
public FileExistsCache(boolean 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.
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.pdom.indexer;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
@ -33,16 +32,15 @@ import org.eclipse.core.runtime.Path;
|
|||
public class ProjectIndexerIncludeResolutionHeuristics implements IIncludeFileResolutionHeuristics {
|
||||
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[] fProjects;
|
||||
private final ASTFilePathResolver fResolver;
|
||||
private final boolean fIgnoreCase;
|
||||
|
||||
public ProjectIndexerIncludeResolutionHeuristics(IProject project, ASTFilePathResolver resolver) {
|
||||
fProject= project;
|
||||
fResolver= resolver;
|
||||
fIgnoreCase= resolver.isCaseInsensitiveFileSystem();
|
||||
}
|
||||
|
||||
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)
|
||||
return null;
|
||||
|
||||
|
|
|
@ -79,7 +79,8 @@ public class ProjectIndexerInputAdapter extends IndexerInputAdapter {
|
|||
}
|
||||
}
|
||||
|
||||
private boolean isCaseInsensitiveFileSystem() {
|
||||
@Override
|
||||
public boolean isCaseInsensitiveFileSystem() {
|
||||
if (Platform.OS_MACOSX.equals(Platform.getOS()))
|
||||
return true;
|
||||
return CASE_INSENSITIVE_FILE_SYSTEM;
|
||||
|
|
Loading…
Add table
Reference in a new issue