mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
prefer to use PathMacroUtil directly
This commit is contained in:
+2
-3
@@ -15,7 +15,6 @@
|
||||
*/
|
||||
package org.jetbrains.jps.model.serialization;
|
||||
|
||||
import com.intellij.application.options.PathMacrosImpl;
|
||||
import com.intellij.openapi.application.PathManager;
|
||||
import com.intellij.openapi.application.ex.PathManagerEx;
|
||||
import com.intellij.openapi.util.io.FileUtilRt;
|
||||
@@ -79,8 +78,8 @@ public abstract class JpsSerializationTestCase extends JpsModelTestCase {
|
||||
|
||||
protected Map<String, String> getPathVariables() {
|
||||
Map<String, String> variables = new HashMap<String, String>();
|
||||
variables.put(PathMacrosImpl.APPLICATION_HOME_MACRO_NAME, PathManager.getHomePath());
|
||||
variables.put(PathMacrosImpl.USER_HOME_MACRO_NAME, SystemProperties.getUserHome());
|
||||
variables.put(PathMacroUtil.APPLICATION_HOME_DIR, PathManager.getHomePath());
|
||||
variables.put(PathMacroUtil.USER_HOME_NAME, SystemProperties.getUserHome());
|
||||
return variables;
|
||||
}
|
||||
|
||||
|
||||
@@ -47,6 +47,7 @@ import org.jdom.Element;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jps.model.serialization.JDomSerializationUtil;
|
||||
import org.jetbrains.jps.model.serialization.PathMacroUtil;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@@ -168,7 +169,7 @@ public class ConversionContextImpl implements ConversionContext {
|
||||
final ExpandMacroToPathMap map = createExpandMacroMap();
|
||||
if (moduleSettings != null) {
|
||||
final String modulePath = FileUtil.toSystemIndependentName(moduleSettings.getModuleFile().getParentFile().getAbsolutePath());
|
||||
map.addMacroExpand(PathMacrosImpl.MODULE_DIR_MACRO_NAME, modulePath);
|
||||
map.addMacroExpand(PathMacroUtil.MODULE_DIR_MACRO_NAME, modulePath);
|
||||
}
|
||||
return map;
|
||||
}
|
||||
@@ -183,12 +184,12 @@ public class ConversionContextImpl implements ConversionContext {
|
||||
@Override
|
||||
@NotNull
|
||||
public String collapsePath(@NotNull String path) {
|
||||
ReplacePathToMacroMap map = createCollapseMacroMap(PathMacrosImpl.PROJECT_DIR_MACRO_NAME, myProjectBaseDir);
|
||||
ReplacePathToMacroMap map = createCollapseMacroMap(PathMacroUtil.PROJECT_DIR_MACRO_NAME, myProjectBaseDir);
|
||||
return map.substitute(path, SystemInfo.isFileSystemCaseSensitive);
|
||||
}
|
||||
|
||||
public static String collapsePath(@NotNull String path, @NotNull ModuleSettingsImpl moduleSettings) {
|
||||
final ReplacePathToMacroMap map = createCollapseMacroMap(PathMacrosImpl.MODULE_DIR_MACRO_NAME, moduleSettings.getModuleFile().getParentFile());
|
||||
final ReplacePathToMacroMap map = createCollapseMacroMap(PathMacroUtil.MODULE_DIR_MACRO_NAME, moduleSettings.getModuleFile().getParentFile());
|
||||
return map.substitute(path, SystemInfo.isFileSystemCaseSensitive);
|
||||
}
|
||||
|
||||
@@ -322,7 +323,7 @@ public class ConversionContextImpl implements ConversionContext {
|
||||
private ExpandMacroToPathMap createExpandMacroMap() {
|
||||
final ExpandMacroToPathMap macros = new ExpandMacroToPathMap();
|
||||
final String projectDir = FileUtil.toSystemIndependentName(myProjectBaseDir.getAbsolutePath());
|
||||
macros.addMacroExpand(PathMacrosImpl.PROJECT_DIR_MACRO_NAME, projectDir);
|
||||
macros.addMacroExpand(PathMacroUtil.PROJECT_DIR_MACRO_NAME, projectDir);
|
||||
PathMacrosImpl.getInstanceEx().addMacroExpands(macros);
|
||||
return macros;
|
||||
}
|
||||
|
||||
+2
-2
@@ -17,7 +17,6 @@ package com.intellij.ide.util.projectWizard;
|
||||
|
||||
import com.intellij.CommonBundle;
|
||||
import com.intellij.application.options.PathMacrosCollector;
|
||||
import com.intellij.application.options.PathMacrosImpl;
|
||||
import com.intellij.conversion.ConversionResult;
|
||||
import com.intellij.conversion.ConversionService;
|
||||
import com.intellij.ide.IdeBundle;
|
||||
@@ -37,6 +36,7 @@ import com.intellij.openapi.util.JDOMUtil;
|
||||
import org.jdom.Element;
|
||||
import org.jdom.JDOMException;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jps.model.serialization.PathMacroUtil;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@@ -99,7 +99,7 @@ public class ExistingModuleLoader extends ModuleBuilder {
|
||||
}
|
||||
final Element root = JDOMUtil.load(file);
|
||||
final Set<String> usedMacros = PathMacrosCollector.getMacroNames(root);
|
||||
usedMacros.remove("$" + PathMacrosImpl.MODULE_DIR_MACRO_NAME + "$");
|
||||
usedMacros.remove("$" + PathMacroUtil.MODULE_DIR_MACRO_NAME + "$");
|
||||
usedMacros.removeAll(PathMacros.getInstance().getAllMacroNames());
|
||||
|
||||
if (usedMacros.size() > 0) {
|
||||
|
||||
+4
-14
@@ -56,25 +56,15 @@ public class PathMacrosImpl extends PathMacros implements PersistentStateCompone
|
||||
@NonNls
|
||||
public static final String IGNORED_MACRO_ELEMENT = "ignoredMacro";
|
||||
|
||||
// predefined macros
|
||||
@NonNls
|
||||
public static final String APPLICATION_HOME_MACRO_NAME = PathMacroUtil.APPLICATION_HOME_DIR;
|
||||
@NonNls
|
||||
public static final String PROJECT_DIR_MACRO_NAME = PathMacroUtil.PROJECT_DIR_MACRO_NAME;
|
||||
@NonNls
|
||||
public static final String MODULE_DIR_MACRO_NAME = PathMacroUtil.MODULE_DIR_MACRO_NAME;
|
||||
@NonNls
|
||||
public static final String USER_HOME_MACRO_NAME = PathMacroUtil.USER_HOME_NAME;
|
||||
|
||||
private static final Set<String> SYSTEM_MACROS = new THashSet<>();
|
||||
@NonNls public static final String EXT_FILE_NAME = "path.macros";
|
||||
|
||||
static {
|
||||
SYSTEM_MACROS.add(APPLICATION_HOME_MACRO_NAME);
|
||||
SYSTEM_MACROS.add(PathMacroUtil.APPLICATION_HOME_DIR);
|
||||
SYSTEM_MACROS.add(PathMacroUtil.APPLICATION_PLUGINS_DIR);
|
||||
SYSTEM_MACROS.add(PROJECT_DIR_MACRO_NAME);
|
||||
SYSTEM_MACROS.add(MODULE_DIR_MACRO_NAME);
|
||||
SYSTEM_MACROS.add(USER_HOME_MACRO_NAME);
|
||||
SYSTEM_MACROS.add(PathMacroUtil.PROJECT_DIR_MACRO_NAME);
|
||||
SYSTEM_MACROS.add(PathMacroUtil.MODULE_DIR_MACRO_NAME);
|
||||
SYSTEM_MACROS.add(PathMacroUtil.USER_HOME_NAME);
|
||||
}
|
||||
|
||||
@SuppressWarnings("SpellCheckingInspection")
|
||||
|
||||
+5
-4
@@ -26,6 +26,7 @@ import gnu.trove.TObjectIntHashMap;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jps.model.serialization.PathMacroUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -172,10 +173,10 @@ public class ReplacePathToMacroMap extends PathMacroMap {
|
||||
private static int getIndex(@NotNull final Map.Entry<String, String> s) {
|
||||
final String replacement = s.getValue();
|
||||
if (replacement.contains("..")) return 1;
|
||||
if (replacement.contains("$" + PathMacrosImpl.USER_HOME_MACRO_NAME + "$")) return 1;
|
||||
if (replacement.contains("$" + PathMacrosImpl.APPLICATION_HOME_MACRO_NAME + "$")) return 1;
|
||||
if (replacement.contains("$" + PathMacrosImpl.MODULE_DIR_MACRO_NAME + "$")) return 3;
|
||||
if (replacement.contains("$" + PathMacrosImpl.PROJECT_DIR_MACRO_NAME + "$")) return 3;
|
||||
if (replacement.contains("$" + PathMacroUtil.USER_HOME_NAME + "$")) return 1;
|
||||
if (replacement.contains("$" + PathMacroUtil.APPLICATION_HOME_DIR + "$")) return 1;
|
||||
if (replacement.contains("$" + PathMacroUtil.MODULE_DIR_MACRO_NAME + "$")) return 3;
|
||||
if (replacement.contains("$" + PathMacroUtil.PROJECT_DIR_MACRO_NAME + "$")) return 3;
|
||||
return 2;
|
||||
}
|
||||
|
||||
|
||||
@@ -101,7 +101,8 @@ public class CoreModule extends MockComponentManager implements ModuleEx {
|
||||
return new CoreModuleScopeProvider();
|
||||
}
|
||||
|
||||
protected PathMacroManager createModulePathMacroManager(@NotNull Project project) {
|
||||
// used by Upsource
|
||||
protected PathMacroManager createModulePathMacroManager(@SuppressWarnings("unused") @NotNull Project project) {
|
||||
return new ModulePathMacroManager(PathMacros.getInstance(), this);
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -15,7 +15,6 @@
|
||||
*/
|
||||
package com.intellij.openapi.components.impl;
|
||||
|
||||
import com.intellij.application.options.PathMacrosImpl;
|
||||
import com.intellij.application.options.ReplacePathToMacroMap;
|
||||
import com.intellij.openapi.application.PathMacros;
|
||||
import com.intellij.openapi.components.ExpandMacroToPathMap;
|
||||
@@ -23,6 +22,7 @@ import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jps.model.serialization.PathMacroUtil;
|
||||
|
||||
public class ProjectPathMacroManager extends BasePathMacroManager {
|
||||
private final Project myProject;
|
||||
@@ -36,7 +36,7 @@ public class ProjectPathMacroManager extends BasePathMacroManager {
|
||||
@Override
|
||||
public ExpandMacroToPathMap getExpandMacroMap() {
|
||||
final ExpandMacroToPathMap result = super.getExpandMacroMap();
|
||||
addFileHierarchyReplacements(result, PathMacrosImpl.PROJECT_DIR_MACRO_NAME, getProjectDir(myProject));
|
||||
addFileHierarchyReplacements(result, PathMacroUtil.PROJECT_DIR_MACRO_NAME, getProjectDir(myProject));
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ public class ProjectPathMacroManager extends BasePathMacroManager {
|
||||
@Override
|
||||
public ReplacePathToMacroMap getReplacePathMap() {
|
||||
final ReplacePathToMacroMap result = super.getReplacePathMap();
|
||||
addFileHierarchyReplacements(result, PathMacrosImpl.PROJECT_DIR_MACRO_NAME, getProjectDir(myProject), null);
|
||||
addFileHierarchyReplacements(result, PathMacroUtil.PROJECT_DIR_MACRO_NAME, getProjectDir(myProject), null);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
*/
|
||||
package org.jetbrains.jps.ant;
|
||||
|
||||
import com.intellij.application.options.PathMacrosImpl;
|
||||
import com.intellij.lang.ant.config.impl.BuildFileProperty;
|
||||
import com.intellij.openapi.application.ex.PathManagerEx;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
@@ -30,6 +29,7 @@ import org.jetbrains.jps.ant.model.impl.artifacts.JpsAntArtifactExtensionImpl;
|
||||
import org.jetbrains.jps.model.artifact.JpsArtifact;
|
||||
import org.jetbrains.jps.model.artifact.JpsArtifactService;
|
||||
import org.jetbrains.jps.model.serialization.JpsSerializationTestCase;
|
||||
import org.jetbrains.jps.model.serialization.PathMacroUtil;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
@@ -94,7 +94,7 @@ public class JpsAntSerializationTest extends JpsSerializationTestCase {
|
||||
@Override
|
||||
protected Map<String, String> getPathVariables() {
|
||||
Map<String, String> pathVariables = super.getPathVariables();
|
||||
pathVariables.put(PathMacrosImpl.APPLICATION_HOME_MACRO_NAME, PlatformTestUtil.getCommunityPath());
|
||||
pathVariables.put(PathMacroUtil.APPLICATION_HOME_DIR, PlatformTestUtil.getCommunityPath());
|
||||
return pathVariables;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user