From ce38a78449c73a93c2055d08d8bc2eda64cf9371 Mon Sep 17 00:00:00 2001 From: peter Date: Wed, 26 Sep 2012 09:36:17 +0200 Subject: [PATCH] minor movement --- .../options/ReplacePathToMacroMap.java | 15 +++++++++ .../components/impl/BasePathMacroManager.java | 31 +++++-------------- 2 files changed, 22 insertions(+), 24 deletions(-) diff --git a/platform/projectModel-impl/src/com/intellij/application/options/ReplacePathToMacroMap.java b/platform/projectModel-impl/src/com/intellij/application/options/ReplacePathToMacroMap.java index 5ac71a254941..7e3d7d592c79 100644 --- a/platform/projectModel-impl/src/com/intellij/application/options/ReplacePathToMacroMap.java +++ b/platform/projectModel-impl/src/com/intellij/application/options/ReplacePathToMacroMap.java @@ -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 diff --git a/platform/projectModel-impl/src/com/intellij/openapi/components/impl/BasePathMacroManager.java b/platform/projectModel-impl/src/com/intellij/openapi/components/impl/BasePathMacroManager.java index 6160e7d6baca..5042d02cd35d 100644 --- a/platform/projectModel-impl/src/com/intellij/openapi/components/impl/BasePathMacroManager.java +++ b/platform/projectModel-impl/src/com/intellij/openapi/components/impl/BasePathMacroManager.java @@ -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 entry : PathMacrosImpl.getGlobalSystemMacros().entrySet()) {