mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-07 17:56:01 +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 ArrayList<IndexerSetupParticipant> fSetupParticipants= new ArrayList<IndexerSetupParticipant>();
|
||||||
private HashSet<ICProject> fPostponedProjects= new HashSet<ICProject>();
|
private HashSet<ICProject> fPostponedProjects= new HashSet<ICProject>();
|
||||||
private int fLastNotifiedState= IndexerStateEvent.STATE_IDLE;
|
private int fLastNotifiedState= IndexerStateEvent.STATE_IDLE;
|
||||||
private PathCanonicalizationStrategy fPathCanonicalizationStrategy;
|
|
||||||
|
|
||||||
public PDOMManager() {
|
public PDOMManager() {
|
||||||
PDOM.sDEBUG_LOCKS= "true".equals(Platform.getDebugOption(CCorePlugin.PLUGIN_ID + "/debug/index/locks")); //$NON-NLS-1$//$NON-NLS-2$
|
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() {
|
private void updatePathCanonicalizationStrategy() {
|
||||||
IPreferencesService prefs = Platform.getPreferencesService();
|
IPreferencesService prefs = Platform.getPreferencesService();
|
||||||
boolean canonicalize = prefs.getBoolean(CCorePlugin.PLUGIN_ID, PREFERENCES_CONSTANT_PATH_CANONICALIZATION, true, null);
|
boolean canonicalize = prefs.getBoolean(CCorePlugin.PLUGIN_ID, PREFERENCES_CONSTANT_PATH_CANONICALIZATION, true, null);
|
||||||
synchronized (this) {
|
PathCanonicalizationStrategy.setPathCanonicalization(canonicalize);
|
||||||
fPathCanonicalizationStrategy = PathCanonicalizationStrategy.getStrategy(canonicalize);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public synchronized PathCanonicalizationStrategy getPathCanonicalizationStrategy() {
|
|
||||||
return fPathCanonicalizationStrategy;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public IndexProviderManager getIndexProviderManager() {
|
public IndexProviderManager getIndexProviderManager() {
|
||||||
|
|
|
@ -13,20 +13,34 @@ package org.eclipse.cdt.internal.core.resources;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
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 {
|
public abstract class PathCanonicalizationStrategy {
|
||||||
|
private static PathCanonicalizationStrategy instance;
|
||||||
|
|
||||||
public static String getCanonicalPath(File file) {
|
static {
|
||||||
PathCanonicalizationStrategy strategy =
|
setPathCanonicalization(true);
|
||||||
((PDOMManager) CCorePlugin.getIndexManager()).getPathCanonicalizationStrategy();
|
|
||||||
return strategy.getCanonicalPathInternal(file);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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) {
|
if (canonicalize) {
|
||||||
return new PathCanonicalizationStrategy() {
|
instance = new PathCanonicalizationStrategy() {
|
||||||
@Override
|
@Override
|
||||||
protected String getCanonicalPathInternal(File file) {
|
protected String getCanonicalPathInternal(File file) {
|
||||||
try {
|
try {
|
||||||
|
@ -37,7 +51,7 @@ public abstract class PathCanonicalizationStrategy {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
return new PathCanonicalizationStrategy() {
|
instance = new PathCanonicalizationStrategy() {
|
||||||
@Override
|
@Override
|
||||||
protected String getCanonicalPathInternal(File file) {
|
protected String getCanonicalPathInternal(File file) {
|
||||||
return file.getAbsolutePath();
|
return file.getAbsolutePath();
|
||||||
|
@ -46,5 +60,9 @@ public abstract class PathCanonicalizationStrategy {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static synchronized PathCanonicalizationStrategy getInstance() {
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
protected abstract String getCanonicalPathInternal(File file);
|
protected abstract String getCanonicalPathInternal(File file);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue