Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core')
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/InternalParserUtil.java9
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOMManager.java28
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/ProjectIndexerInputAdapter.java18
3 files changed, 39 insertions, 16 deletions
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/InternalParserUtil.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/InternalParserUtil.java
index d6e30fa5dd7..96c9d03588b 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/InternalParserUtil.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/InternalParserUtil.java
@@ -18,6 +18,7 @@ import java.io.InputStream;
import org.eclipse.cdt.core.index.IIndexFileLocation;
import org.eclipse.cdt.core.parser.CodeReader;
import org.eclipse.cdt.core.parser.ParserFactory;
+import org.eclipse.cdt.internal.core.resources.PathCanonicalizationStrategy;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IResourceStatus;
@@ -49,10 +50,10 @@ public class InternalParserUtil extends ParserFactory {
public static CodeReader createExternalFileReader(String externalLocation, CodeReaderLRUCache cache) throws IOException {
File includeFile = new File(externalLocation);
if (includeFile.isFile()) {
- //use the canonical path so that in case of non-case-sensitive OSs
- //the CodeReader always has the same name as the file on disk with
- //no differences in case.
- final String path = includeFile.getCanonicalPath();
+ // Use the canonical path so that in case of non-case-sensitive OSs
+ // the CodeReader always has the same name as the file on disk with
+ // no differences in case.
+ final String path = PathCanonicalizationStrategy.getCanonicalPath(includeFile);
if (cache != null) {
CodeReader result= cache.get(path);
if (result != null)
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOMManager.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOMManager.java
index d7c4d04c59b..9c11bbb352b 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOMManager.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOMManager.java
@@ -82,6 +82,7 @@ import org.eclipse.cdt.internal.core.pdom.indexer.PDOMUpdateTask;
import org.eclipse.cdt.internal.core.pdom.indexer.ProjectIndexerInputAdapter;
import org.eclipse.cdt.internal.core.pdom.indexer.TranslationUnitCollector;
import org.eclipse.cdt.internal.core.pdom.indexer.TriggerNotificationTask;
+import org.eclipse.cdt.internal.core.resources.PathCanonicalizationStrategy;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
@@ -150,6 +151,14 @@ public class PDOMManager implements IWritableIndexManager, IListener {
};
/**
+ * Boolean preference controlling whether paths to non-workspace files are stored in canonical
+ * form or not.
+ */
+ // TODO(sprigogin): Move to CPreferencesConstants and add UI support.
+ public static final String PREFERENCES_CONSTANT_PATH_CANONICALIZATION =
+ CCorePlugin.PLUGIN_ID + ".path_canonicalization"; //$NON-NLS-1$
+
+ /**
* Protects fIndexerJob, fCurrentTask and fTaskQueue.
*/
private final LinkedList<IPDOMIndexerTask> fTaskQueue = new LinkedList<IPDOMIndexerTask>();
@@ -158,7 +167,7 @@ public class PDOMManager implements IWritableIndexManager, IListener {
private int fSourceCount, fHeaderCount, fTickCount;
/**
- * Stores mapping from pdom to project, used to serialize\ creation of new pdoms.
+ * Stores mapping from pdom to project, used to serialize creation of new pdoms.
*/
private Map<IProject, IPDOM> fProjectToPDOM= new HashMap<IProject, IPDOM>();
private Map<File, ICProject> fFileToProject= new HashMap<File, ICProject>();
@@ -187,6 +196,7 @@ public class PDOMManager implements IWritableIndexManager, IListener {
private ArrayList<IndexerSetupParticipant> fSetupParticipants= new ArrayList<IndexerSetupParticipant>();
private HashSet<ICProject> fPostponedProjects= new HashSet<ICProject>();
private int fLastNotifiedState= IndexerStateEvent.STATE_IDLE;
+ private PathCanonicalizationStrategy fPathCanonicalizationStrategy;
public PDOMManager() {
PDOM.sDEBUG_LOCKS= "true".equals(Platform.getDebugOption(CCorePlugin.PLUGIN_ID + "/debug/index/locks")); //$NON-NLS-1$//$NON-NLS-2$
@@ -225,6 +235,7 @@ public class PDOMManager implements IWritableIndexManager, IListener {
new InstanceScope().getNode(CCorePlugin.PLUGIN_ID).addPreferenceChangeListener(fPreferenceChangeListener);
Job.getJobManager().addJobChangeListener(fJobChangeListener);
adjustCacheSize();
+ updatePathCanonicalizationStrategy();
fIndexProviderManager.startup();
final CoreModel model = CoreModel.getDefault();
@@ -273,6 +284,9 @@ public class PDOMManager implements IWritableIndexManager, IListener {
prop.equals(CCorePreferenceConstants.TODO_TASK_PRIORITIES) ||
prop.equals(CCorePreferenceConstants.TODO_TASK_CASE_SENSITIVE)) {
reindexAll();
+ } else if (prop.equals(PREFERENCES_CONSTANT_PATH_CANONICALIZATION)) {
+ updatePathCanonicalizationStrategy();
+ reindexAll();
}
}
@@ -287,6 +301,18 @@ public class PDOMManager implements IWritableIndexManager, IListener {
ChunkCache.getSharedInstance().setMaxSize(m2);
}
+ private void updatePathCanonicalizationStrategy() {
+ IPreferencesService prefs = Platform.getPreferencesService();
+ boolean canonicalize = prefs.getBoolean(CCorePlugin.PLUGIN_ID, PREFERENCES_CONSTANT_PATH_CANONICALIZATION, true, null);
+ synchronized (this) {
+ fPathCanonicalizationStrategy = PathCanonicalizationStrategy.getStrategy(canonicalize);
+ }
+ }
+
+ public synchronized PathCanonicalizationStrategy getPathCanonicalizationStrategy() {
+ return fPathCanonicalizationStrategy;
+ }
+
public IndexProviderManager getIndexProviderManager() {
return fIndexProviderManager;
}
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 18924c31dc1..052bbce203f 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
@@ -7,11 +7,11 @@
*
* Contributors:
* Markus Schorn - initial API and implementation
+ * Sergey Prigogin (Google)
*******************************************************************************/
package org.eclipse.cdt.internal.core.pdom.indexer;
import java.io.File;
-import java.io.IOException;
import java.util.HashMap;
import org.eclipse.cdt.core.CCorePlugin;
@@ -29,6 +29,7 @@ import org.eclipse.cdt.core.parser.CodeReader;
import org.eclipse.cdt.core.parser.IScannerInfo;
import org.eclipse.cdt.core.parser.ScannerInfo;
import org.eclipse.cdt.internal.core.pdom.IndexerInputAdapter;
+import org.eclipse.cdt.internal.core.resources.PathCanonicalizationStrategy;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
@@ -99,16 +100,11 @@ public class ProjectIndexerInputAdapter extends IndexerInputAdapter {
if (result == null) {
result = doResolveASTPath(includePath);
if (result.getFullPath() == null) {
- try {
- File location= new File(includePath);
- String canonicalPath= location.getCanonicalPath();
- if (!includePath.equals(canonicalPath)) {
- result= IndexLocationFactory.getExternalIFL(canonicalPath);
- fIflCache.put(canonicalPath, result);
- }
- }
- catch (IOException e) {
- // just use the original
+ File location= new File(includePath);
+ String canonicalPath= PathCanonicalizationStrategy.getCanonicalPath(location);
+ if (!includePath.equals(canonicalPath)) {
+ result= IndexLocationFactory.getExternalIFL(canonicalPath);
+ fIflCache.put(canonicalPath, result);
}
}
fIflCache.put(includePath, result);

Back to the top