minor movement

This commit is contained in:
peter
2012-09-26 22:37:37 +02:00
parent eb099cc167
commit ce38a78449
2 changed files with 22 additions and 24 deletions
@@ -51,6 +51,21 @@ public class ReplacePathToMacroMap extends PathMacroMap {
}
}
public void putIfAbsent(@NonNls final String pathWithPrefix,
@NonNls final String substitutionWithPrefix,
final boolean check) {
if (check && containsPath(pathWithPrefix))
return;
if (StringUtil.endsWithChar(pathWithPrefix, '/')) {
myMacroMap.put(pathWithPrefix, substitutionWithPrefix + "/");
myMacroMap.put(pathWithPrefix.substring(0, pathWithPrefix.length() - 1), substitutionWithPrefix);
}
else {
myMacroMap.put(pathWithPrefix, substitutionWithPrefix);
}
}
public String substitute(String text, boolean caseSensitive) {
if (text == null) {
//noinspection ConstantConditions
@@ -30,7 +30,6 @@ import com.intellij.openapi.vfs.VirtualFileManager;
import com.intellij.openapi.vfs.VirtualFileSystem;
import com.intellij.util.containers.FactoryMap;
import org.jdom.Element;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.Nullable;
import java.util.*;
@@ -68,14 +67,14 @@ public class BasePathMacroManager extends PathMacroManager {
path = StringUtil.trimEnd(FileUtil.toSystemIndependentName(path), "/");
boolean check = false;
while (StringUtil.isNotEmpty(path) && path.contains("/")) {
putIfAbsent(result, "file:" + path, "file:" + macro, check);
putIfAbsent(result, "file:/" + path, "file:/" + macro, check);
putIfAbsent(result, "file://" + path, "file://" + macro, check);
putIfAbsent(result, "jar:" + path, "jar:" + macro, check);
putIfAbsent(result, "jar:/" + path, "jar:/" + macro, check);
putIfAbsent(result, "jar://" + path, "jar://" + macro, check);
result.putIfAbsent("file:" + path, "file:" + macro, check);
result.putIfAbsent("file:/" + path, "file:/" + macro, check);
result.putIfAbsent("file://" + path, "file://" + macro, check);
result.putIfAbsent("jar:" + path, "jar:" + macro, check);
result.putIfAbsent("jar:/" + path, "jar:/" + macro, check);
result.putIfAbsent("jar://" + path, "jar://" + macro, check);
if (!path.equalsIgnoreCase("e:/") && !path.equalsIgnoreCase("r:/") && !path.equalsIgnoreCase("p:/")) {
putIfAbsent(result, path, macro, check);
result.putIfAbsent(path, macro, check);
}
if (path.equals(stopAt)) {
@@ -93,22 +92,6 @@ public class BasePathMacroManager extends PathMacroManager {
return VirtualFileManager.getInstance().getFileSystem(StandardFileSystems.FILE_PROTOCOL);
}
private static void putIfAbsent(final ReplacePathToMacroMap result,
@NonNls final String pathWithPrefix,
@NonNls final String substitutionWithPrefix,
final boolean check) {
if (check && result.containsPath(pathWithPrefix))
return;
if (StringUtil.endsWithChar(pathWithPrefix, '/')) {
result.put(pathWithPrefix, substitutionWithPrefix + "/");
result.put(pathWithPrefix.substring(0, pathWithPrefix.length()-1), substitutionWithPrefix);
}
else {
result.put(pathWithPrefix, substitutionWithPrefix);
}
}
protected ExpandMacroToPathMap getExpandMacroMap() {
ExpandMacroToPathMap result = new ExpandMacroToPathMap();
for (Map.Entry<String, String> entry : PathMacrosImpl.getGlobalSystemMacros().entrySet()) {