diff --git a/java/compiler/impl/src/com/intellij/compiler/CompileServerManager.java b/java/compiler/impl/src/com/intellij/compiler/CompileServerManager.java index f97ad79d2de0..d69e06a1298c 100644 --- a/java/compiler/impl/src/com/intellij/compiler/CompileServerManager.java +++ b/java/compiler/impl/src/com/intellij/compiler/CompileServerManager.java @@ -462,8 +462,9 @@ public class CompileServerManager implements ApplicationComponent{ private static RequestFuture sendSetupRequest(final @NotNull CompileServerClient client) throws Exception { final Map data = new HashMap(); - // need this for tests and when this macro is missing from PathMacros registry - data.put(PathMacrosImpl.APPLICATION_HOME_MACRO_NAME, FileUtil.toSystemIndependentName(PathManager.getHomePath())); + for (Map.Entry entry : PathMacrosImpl.getGlobalSystemMacros().entrySet()) { + data.put(entry.getKey(), FileUtil.toSystemIndependentName(entry.getValue())); + } final PathMacros pathVars = PathMacros.getInstance(); for (String name : pathVars.getAllMacroNames()) { diff --git a/platform/lang-impl/src/com/intellij/openapi/components/impl/ModulePathMacroManager.java b/platform/lang-impl/src/com/intellij/openapi/components/impl/ModulePathMacroManager.java index ebb4c9358668..693ebd26d06a 100644 --- a/platform/lang-impl/src/com/intellij/openapi/components/impl/ModulePathMacroManager.java +++ b/platform/lang-impl/src/com/intellij/openapi/components/impl/ModulePathMacroManager.java @@ -43,7 +43,8 @@ public class ModulePathMacroManager extends BasePathMacroManager { public ReplacePathToMacroMap getReplacePathMap() { ReplacePathToMacroMap result = super.getReplacePathMap(); if (!myModule.isDisposed()) { - addFileHierarchyReplacements(result, PathMacrosImpl.MODULE_DIR_MACRO_NAME, getModuleDir(myModule.getModuleFilePath()), getUserHome()); + addFileHierarchyReplacements(result, PathMacrosImpl.MODULE_DIR_MACRO_NAME, getModuleDir(myModule.getModuleFilePath()), PathMacrosImpl + .getUserHome()); } return result; } diff --git a/platform/platform-impl/src/com/intellij/application/options/PathMacrosImpl.java b/platform/platform-impl/src/com/intellij/application/options/PathMacrosImpl.java index bdf488d99fc6..27e2c6448614 100644 --- a/platform/platform-impl/src/com/intellij/application/options/PathMacrosImpl.java +++ b/platform/platform-impl/src/com/intellij/application/options/PathMacrosImpl.java @@ -18,6 +18,7 @@ package com.intellij.application.options; import com.google.common.collect.ImmutableSet; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.application.PathMacros; +import com.intellij.openapi.application.PathManager; import com.intellij.openapi.components.ApplicationComponent; import com.intellij.openapi.components.ExpandMacroToPathMap; import com.intellij.openapi.diagnostic.Logger; @@ -25,6 +26,8 @@ import com.intellij.openapi.util.InvalidDataException; import com.intellij.openapi.util.NamedJDOMExternalizable; import com.intellij.openapi.util.RoamingTypeDisabled; import com.intellij.openapi.util.WriteExternalException; +import com.intellij.openapi.util.text.StringUtil; +import com.intellij.util.SystemProperties; import com.intellij.util.concurrency.JBReentrantReadWriteLock; import com.intellij.util.concurrency.LockFactory; import com.intellij.util.containers.ContainerUtil; @@ -181,6 +184,13 @@ public class PathMacrosImpl extends PathMacros implements ApplicationComponent, if (!myIgnoredMacros.contains(name)) myIgnoredMacros.add(name); } + public static Map getGlobalSystemMacros() { + final Map map = new HashMap(); + map.put(APPLICATION_HOME_MACRO_NAME, PathManager.getHomePath()); + map.put(USER_HOME_MACRO_NAME, getUserHome()); + return map; + } + @Override public boolean isIgnoredMacroName(@NotNull String macro) { return myIgnoredMacros.contains(macro); @@ -348,4 +358,8 @@ public class PathMacrosImpl extends PathMacros implements ApplicationComponent, myLock.readLock().unlock(); } } + + public static String getUserHome() { + return StringUtil.trimEnd(SystemProperties.getUserHome(), "/"); + } } diff --git a/platform/platform-impl/src/com/intellij/openapi/components/impl/BasePathMacroManager.java b/platform/platform-impl/src/com/intellij/openapi/components/impl/BasePathMacroManager.java index d29b0c7b035a..c2bd7334b432 100644 --- a/platform/platform-impl/src/com/intellij/openapi/components/impl/BasePathMacroManager.java +++ b/platform/platform-impl/src/com/intellij/openapi/components/impl/BasePathMacroManager.java @@ -17,14 +17,12 @@ package com.intellij.openapi.components.impl; import com.intellij.application.options.PathMacrosImpl; import com.intellij.application.options.ReplacePathToMacroMap; -import com.intellij.openapi.application.PathManager; import com.intellij.openapi.components.ExpandMacroToPathMap; import com.intellij.openapi.components.PathMacroManager; import com.intellij.openapi.components.PathMacroMap; import com.intellij.openapi.components.TrackingPathMacroSubstitutor; import com.intellij.openapi.util.SystemInfo; import com.intellij.openapi.util.text.StringUtil; -import com.intellij.util.SystemProperties; import com.intellij.util.containers.FactoryMap; import org.jdom.Element; import org.jetbrains.annotations.NonNls; @@ -74,22 +72,18 @@ public class BasePathMacroManager extends PathMacroManager { public ExpandMacroToPathMap getExpandMacroMap() { ExpandMacroToPathMap result = new ExpandMacroToPathMap(); - result.addMacroExpand(PathMacrosImpl.APPLICATION_HOME_MACRO_NAME, PathManager.getHomePath()); - result.addMacroExpand(PathMacrosImpl.USER_HOME_MACRO_NAME, getUserHome()); + for (Map.Entry entry : PathMacrosImpl.getGlobalSystemMacros().entrySet()) { + result.addMacroExpand(entry.getKey(), entry.getValue()); + } getPathMacros().addMacroExpands(result); return result; } - protected static String getUserHome() { - return StringUtil.trimEnd(SystemProperties.getUserHome(), "/"); - } - - public ReplacePathToMacroMap getReplacePathMap() { ReplacePathToMacroMap result = new ReplacePathToMacroMap(); - - result.addMacroReplacement(PathManager.getHomePath(), PathMacrosImpl.APPLICATION_HOME_MACRO_NAME); - result.addMacroReplacement(getUserHome(), PathMacrosImpl.USER_HOME_MACRO_NAME); + for (Map.Entry entry : PathMacrosImpl.getGlobalSystemMacros().entrySet()) { + result.addMacroReplacement(entry.getValue(), entry.getKey()); + } getPathMacros().addMacroReplacements(result); return result; }