From 44415a5474334d98d5025819f981df70094b2d2f Mon Sep 17 00:00:00 2001 From: Vladimir Krivosheev Date: Mon, 30 May 2016 12:01:37 +0200 Subject: [PATCH] =?UTF-8?q?expandMacroMap=20=E2=80=94=20system=20macro=20s?= =?UTF-8?q?hould=20have=20a=20higher=20priority?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/impl/pathMacroManagerTest.kt | 32 +++++++++++++++++++ .../components/impl/BasePathMacroManager.java | 4 +-- 2 files changed, 34 insertions(+), 2 deletions(-) create mode 100644 platform/platform-tests/testSrc/com/intellij/openapi/components/impl/pathMacroManagerTest.kt diff --git a/platform/platform-tests/testSrc/com/intellij/openapi/components/impl/pathMacroManagerTest.kt b/platform/platform-tests/testSrc/com/intellij/openapi/components/impl/pathMacroManagerTest.kt new file mode 100644 index 000000000000..efaddffb554e --- /dev/null +++ b/platform/platform-tests/testSrc/com/intellij/openapi/components/impl/pathMacroManagerTest.kt @@ -0,0 +1,32 @@ +/* + * Copyright 2000-2016 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import com.intellij.application.options.PathMacrosImpl +import com.intellij.openapi.components.impl.BasePathMacroManager +import org.assertj.core.api.Assertions.assertThat +import org.jetbrains.jps.model.serialization.PathMacroUtil +import org.junit.Test + +class LightPathMacroManagerTest { + @Test + fun systemOverridesUser() { + val macros = PathMacrosImpl() + macros.setMacro("foo", "/home/user") + + val manager = BasePathMacroManager(macros) + assertThat(manager.collapsePath(com.intellij.util.SystemProperties.getUserHome())).isEqualTo("$${PathMacroUtil.USER_HOME_NAME}$") + } +} \ No newline at end of file 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 e201900c41c2..36d1a2ccfeff 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 @@ -103,20 +103,20 @@ public class BasePathMacroManager extends PathMacroManager { @NotNull public ExpandMacroToPathMap getExpandMacroMap() { ExpandMacroToPathMap result = new ExpandMacroToPathMap(); + getPathMacros().addMacroExpands(result); for (Map.Entry entry : PathMacroUtil.getGlobalSystemMacros().entrySet()) { result.addMacroExpand(entry.getKey(), entry.getValue()); } - getPathMacros().addMacroExpands(result); return result; } @NotNull protected ReplacePathToMacroMap getReplacePathMap() { ReplacePathToMacroMap result = new ReplacePathToMacroMap(); + getPathMacros().addMacroReplacements(result); for (Map.Entry entry : PathMacroUtil.getGlobalSystemMacros().entrySet()) { result.addMacroReplacement(entry.getValue(), entry.getKey()); } - getPathMacros().addMacroReplacements(result); return result; }