under USER_HOME, prefer storing paths relatively MODULE_DIR unless the common ancesto...
authorpeter <peter.gromov@jetbrains.com>
Wed, 15 Sep 2010 22:05:16 +0000 (23:05 +0100)
committerpeter <peter.gromov@jetbrains.com>
Wed, 15 Sep 2010 22:51:20 +0000 (23:51 +0100)
platform/lang-impl/src/com/intellij/openapi/components/impl/ModulePathMacroManager.java
platform/platform-impl/src/com/intellij/openapi/components/impl/BasePathMacroManager.java

index a5ed8206ea55dbc109fc63f17dd2340bc71c4b0c..b51364ca829f9324b7ed995a23332a2c69d59cc5 100644 (file)
@@ -49,7 +49,14 @@ public class ModulePathMacroManager extends BasePathMacroManager {
       if (projectDir != null) {
         projectDir = projectDir.replace('/', File.separatorChar);
       }
-      addFileHierarchyReplacements(result, PathMacrosImpl.MODULE_DIR_MACRO_NAME, getModuleDir(myModule.getModuleFilePath()), projectDir);
+      String stopAt = projectDir;
+
+      final String userHome = getUserHome();
+      if (stopAt != null && stopAt.startsWith(userHome)) {
+        stopAt = userHome;
+      }
+
+      addFileHierarchyReplacements(result, PathMacrosImpl.MODULE_DIR_MACRO_NAME, getModuleDir(myModule.getModuleFilePath()), stopAt);
     }
     return result;
   }
index b06b4219704056f661fbdf8340c930f0b9622371..6cd1318ef1f84c25396e8009e7f75e337a561365 100644 (file)
@@ -75,17 +75,21 @@ 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, SystemProperties.getUserHome());
+    result.addMacroExpand(PathMacrosImpl.USER_HOME_MACRO_NAME, getUserHome());
     getPathMacros().addMacroExpands(result);
     return result;
   }
 
+  protected static String getUserHome() {
+    return SystemProperties.getUserHome();
+  }
+
 
   public ReplacePathToMacroMap getReplacePathMap() {
     ReplacePathToMacroMap result = new ReplacePathToMacroMap();
 
     result.addMacroReplacement(PathManager.getHomePath(), PathMacrosImpl.APPLICATION_HOME_MACRO_NAME);
-    result.addMacroReplacement(SystemProperties.getUserHome(), PathMacrosImpl.USER_HOME_MACRO_NAME);
+    result.addMacroReplacement(getUserHome(), PathMacrosImpl.USER_HOME_MACRO_NAME);
     getPathMacros().addMacroReplacements(result);
     return result;
   }