mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-22 22:22:11 +02:00
Made PathCanonicalizationStrategy friendlier to standalone indexer.
This commit is contained in:
parent
88633a03ea
commit
9c73a9327a
2 changed files with 29 additions and 18 deletions
|
@ -196,7 +196,6 @@ 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$
|
||||
|
@ -304,13 +303,7 @@ public class PDOMManager implements IWritableIndexManager, IListener {
|
|||
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;
|
||||
PathCanonicalizationStrategy.setPathCanonicalization(canonicalize);
|
||||
}
|
||||
|
||||
public IndexProviderManager getIndexProviderManager() {
|
||||
|
|
|
@ -13,20 +13,34 @@ package org.eclipse.cdt.internal.core.resources;
|
|||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.internal.core.pdom.PDOMManager;
|
||||
|
||||
/**
|
||||
* Configurable strategy for canonicalizing file paths. File paths can be canonicalized by calling
|
||||
* either File.getCanonicalPath or File.getAbsolutePath. File.getCanonicalPath resolves symbolic
|
||||
* links and guarantees path uniqueness. File.getAbsolutePath can be used when resolution of
|
||||
* symbolic links is undesirable. The default is to use File.getCanonicalPath.
|
||||
*/
|
||||
public abstract class PathCanonicalizationStrategy {
|
||||
private static PathCanonicalizationStrategy instance;
|
||||
|
||||
public static String getCanonicalPath(File file) {
|
||||
PathCanonicalizationStrategy strategy =
|
||||
((PDOMManager) CCorePlugin.getIndexManager()).getPathCanonicalizationStrategy();
|
||||
return strategy.getCanonicalPathInternal(file);
|
||||
static {
|
||||
setPathCanonicalization(true);
|
||||
}
|
||||
|
||||
public static PathCanonicalizationStrategy getStrategy(boolean canonicalize) {
|
||||
public static String getCanonicalPath(File file) {
|
||||
return getInstance().getCanonicalPathInternal(file);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets path canonicalization strategy. If <code>canonicalize</code> is <code>true</code>,
|
||||
* file paths will be canonicalized by calling File.getCanonicalPath, otherwise
|
||||
* File.getAbsolutePath is used.
|
||||
*
|
||||
* @param canonicalize <code>true</code> to use File.getCanonicalPath, <code>false</code>
|
||||
* to use File.getAbsolutePath.
|
||||
*/
|
||||
public static synchronized void setPathCanonicalization(boolean canonicalize) {
|
||||
if (canonicalize) {
|
||||
return new PathCanonicalizationStrategy() {
|
||||
instance = new PathCanonicalizationStrategy() {
|
||||
@Override
|
||||
protected String getCanonicalPathInternal(File file) {
|
||||
try {
|
||||
|
@ -37,7 +51,7 @@ public abstract class PathCanonicalizationStrategy {
|
|||
}
|
||||
};
|
||||
} else {
|
||||
return new PathCanonicalizationStrategy() {
|
||||
instance = new PathCanonicalizationStrategy() {
|
||||
@Override
|
||||
protected String getCanonicalPathInternal(File file) {
|
||||
return file.getAbsolutePath();
|
||||
|
@ -46,5 +60,9 @@ public abstract class PathCanonicalizationStrategy {
|
|||
}
|
||||
}
|
||||
|
||||
private static synchronized PathCanonicalizationStrategy getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
protected abstract String getCanonicalPathInternal(File file);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue