expandMacroMap — system macro should have a higher priority

This commit is contained in:
Vladimir Krivosheev
2016-05-30 12:02:42 +02:00
parent d3ef4ef302
commit 44415a5474
2 changed files with 34 additions and 2 deletions
@@ -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}$")
}
}
@@ -103,20 +103,20 @@ public class BasePathMacroManager extends PathMacroManager {
@NotNull
public ExpandMacroToPathMap getExpandMacroMap() {
ExpandMacroToPathMap result = new ExpandMacroToPathMap();
getPathMacros().addMacroExpands(result);
for (Map.Entry<String, String> 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<String, String> entry : PathMacroUtil.getGlobalSystemMacros().entrySet()) {
result.addMacroReplacement(entry.getValue(), entry.getKey());
}
getPathMacros().addMacroReplacements(result);
return result;
}