use of com.intellij.openapi.application.PathMacros in project intellij-community by JetBrains.
the class MavenEnvironmentRegistrar method registerPathVariable.
private static void registerPathVariable() {
String repository = MavenUtil.resolveLocalRepository(null, null, null).getAbsolutePath();
PathMacros macros = PathMacros.getInstance();
for (String each : macros.getAllMacroNames()) {
String path = macros.getValue(each);
if (path != null && FileUtil.pathsEqual(repository, path)) {
return;
}
}
macros.setMacro(MAVEN_REPOSITORY, repository);
}
use of com.intellij.openapi.application.PathMacros in project intellij-community by JetBrains.
the class ProjectMacrosUtil method checkMacros.
public static boolean checkMacros(@NotNull final Project project, @NotNull final Set<String> usedMacros) {
PathMacros pathMacros = PathMacros.getInstance();
usedMacros.removeAll(pathMacros.getSystemMacroNames());
usedMacros.removeAll(pathMacros.getUserMacroNames());
// try to lookup values in System properties
String pathMacroSystemPrefix = "path.macro.";
for (Iterator<String> it = usedMacros.iterator(); it.hasNext(); ) {
String macro = it.next();
String value = System.getProperty(pathMacroSystemPrefix + macro, null);
if (value != null) {
pathMacros.setMacro(macro, value);
it.remove();
}
}
if (usedMacros.isEmpty()) {
// all macros in configuration files are defined
return true;
}
// there are undefined macros, need to define them before loading components
final boolean[] result = new boolean[1];
WaitForProgressToShow.runOrInvokeAndWaitAboveProgress(() -> result[0] = showMacrosConfigurationDialog(project, usedMacros), ModalityState.NON_MODAL);
return result[0];
}
use of com.intellij.openapi.application.PathMacros in project intellij-plugins by JetBrains.
the class FlashBuilderModuleImporter method getAbsolutePathWithLinksHandled.
/**
* First call of this method should be later than mySdkFinder.findSdk()
*/
private String getAbsolutePathWithLinksHandled(final FlashBuilderProject project, final String path) {
if (!myPathVariablesInitialized) {
initPathVariables();
myPathVariablesInitialized = true;
}
final int slashIndex = path.indexOf('/');
final String potentialLink = slashIndex >= 0 ? path.substring(0, slashIndex) : path;
if (potentialLink.startsWith("${") && potentialLink.endsWith("}")) {
final String pathVarName = potentialLink.substring(2, potentialLink.length() - 1);
final PathMacros pathMacros = PathMacros.getInstance();
final String pathValue = pathMacros.getValue(pathVarName);
if (pathValue != null) {
return pathValue + (slashIndex >= 0 ? path.substring(slashIndex) : "");
} else {
return "$" + pathVarName + "$" + (slashIndex >= 0 ? path.substring(slashIndex) : "");
}
} else {
final Map<String, String> linkedResources = project.getLinkedResources();
if (!linkedResources.isEmpty()) {
final String linkValue = linkedResources.get(potentialLink);
if (linkValue != null) {
final PathMacros pathMacros = PathMacros.getInstance();
if (pathMacros.getValue(potentialLink) == null) {
pathMacros.setMacro(potentialLink, linkValue);
}
return linkValue + (slashIndex >= 0 ? path.substring(slashIndex) : "");
}
}
}
final boolean absolute = FileUtil.isAbsolute(path) && (SystemInfo.isWindows || new File(path).exists());
return absolute ? path : project.getProjectRootPath() + (slashIndex == 0 ? "" : "/") + path;
}
use of com.intellij.openapi.application.PathMacros in project intellij-community by JetBrains.
the class GenerationOptionsImpl method createReplacementMap.
private static ReplacePathToMacroMap createReplacementMap() {
final PathMacros pathMacros = PathMacros.getInstance();
final Set<String> macroNames = pathMacros.getUserMacroNames();
final ReplacePathToMacroMap map = new ReplacePathToMacroMap();
for (final String macroName : macroNames) {
map.put(GenerationUtils.normalizePath(pathMacros.getValue(macroName)), BuildProperties.propertyRef(BuildProperties.getPathMacroProperty(macroName)));
}
map.put(GenerationUtils.normalizePath(PathManager.getHomePath()), BuildProperties.propertyRef(BuildProperties.PROPERTY_IDEA_HOME));
return map;
}
use of com.intellij.openapi.application.PathMacros in project intellij-elixir by KronicDeth.
the class ParametersList method getMacroMap.
private Map<String, String> getMacroMap() {
if (myMacroMap == null) {
// the insertion order is important for later iterations, so LinkedHashMap is used
myMacroMap = new LinkedHashMap<String, String>();
// ApplicationManager.getApplication() will return null if executed in ParameterListTest
final Application application = ApplicationManager.getApplication();
if (application != null) {
final PathMacros pathMacros = PathMacros.getInstance();
if (pathMacros != null) {
for (String name : pathMacros.getUserMacroNames()) {
final String value = pathMacros.getValue(name);
if (value != null) {
myMacroMap.put("${" + name + "}", value);
}
}
}
final Map<String, String> env = EnvironmentUtil.getEnvironmentMap();
for (String name : env.keySet()) {
final String key = "${" + name + "}";
if (!myMacroMap.containsKey(key)) {
myMacroMap.put(key, env.get(name));
}
}
}
}
return myMacroMap;
}
Aggregations