use of com.intellij.application.options.ReplacePathToMacroMap in project intellij-community by JetBrains.
the class ExternalResourceManagerExImpl method getState.
@Nullable
@Override
public Element getState() {
Element element = new Element("state");
Set<String> urls = new TreeSet<>();
for (Map<String, String> map : myResources.values()) {
urls.addAll(map.keySet());
}
for (String url : urls) {
if (url == null) {
continue;
}
String location = getResourceLocation(url);
if (location == null) {
continue;
}
Element e = new Element(RESOURCE_ELEMENT);
e.setAttribute(URL_ATTR, url);
e.setAttribute(LOCATION_ATTR, location.replace(File.separatorChar, '/'));
element.addContent(e);
}
myIgnoredResources.removeAll(myStandardIgnoredResources);
for (String ignoredResource : myIgnoredResources) {
Element e = new Element(IGNORED_RESOURCE_ELEMENT);
e.setAttribute(URL_ATTR, ignoredResource);
element.addContent(e);
}
if (myDefaultHtmlDoctype != null && !HTML5_DOCTYPE_ELEMENT.equals(myDefaultHtmlDoctype)) {
Element e = new Element(HTML_DEFAULT_DOCTYPE_ELEMENT);
e.setText(myDefaultHtmlDoctype);
element.addContent(e);
}
if (myXMLSchemaVersion != XMLSchemaVersion.XMLSchema_1_0) {
Element e = new Element(XML_SCHEMA_VERSION);
e.setText(myXMLSchemaVersion.toString());
element.addContent(e);
}
if (myCatalogPropertiesFile != null) {
Element properties = new Element(CATALOG_PROPERTIES_ELEMENT);
properties.setText(myCatalogPropertiesFile);
element.addContent(properties);
}
ReplacePathToMacroMap macroReplacements = new ReplacePathToMacroMap();
PathMacrosImpl.getInstanceEx().addMacroReplacements(macroReplacements);
macroReplacements.substitute(element, SystemInfo.isFileSystemCaseSensitive);
return element;
}
use of com.intellij.application.options.ReplacePathToMacroMap in project intellij-community by JetBrains.
the class ConversionContextImpl method createCollapseMacroMap.
private static ReplacePathToMacroMap createCollapseMacroMap(final String macroName, final File dir) {
ReplacePathToMacroMap map = new ReplacePathToMacroMap();
map.addMacroReplacement(FileUtil.toSystemIndependentName(dir.getAbsolutePath()), macroName);
PathMacrosImpl.getInstanceEx().addMacroReplacements(map);
return map;
}
use of com.intellij.application.options.ReplacePathToMacroMap in project intellij-community by JetBrains.
the class PathMacroManagerTest method testPathsOutsideProject.
@Test
public void testPathsOutsideProject() {
setUpMocks("/tmp/foo");
final ReplacePathToMacroMap replacePathMap = new ProjectPathMacroManager(myPathMacros, myProject).getReplacePathMap();
assertReplacements(replacePathMap, "file:/tmp/foo -> file:$PROJECT_DIR$\n" + "file://tmp/foo -> file:/$PROJECT_DIR$\n" + "file:///tmp/foo -> file://$PROJECT_DIR$\n" + "jar:/tmp/foo -> jar:$PROJECT_DIR$\n" + "jar://tmp/foo -> jar:/$PROJECT_DIR$\n" + "jar:///tmp/foo -> jar://$PROJECT_DIR$\n" + "/tmp/foo -> $PROJECT_DIR$\n" + APP_HOME + " -> $APPLICATION_HOME_DIR$\n" + "file:" + APP_HOME + " -> file:$APPLICATION_HOME_DIR$\n" + "file:/" + APP_HOME + " -> file:/$APPLICATION_HOME_DIR$\n" + "file://" + APP_HOME + " -> file://$APPLICATION_HOME_DIR$\n" + "jar:" + APP_HOME + " -> jar:$APPLICATION_HOME_DIR$\n" + "jar:/" + APP_HOME + " -> jar:/$APPLICATION_HOME_DIR$\n" + "jar://" + APP_HOME + " -> jar://$APPLICATION_HOME_DIR$\n" + USER_HOME + " -> $USER_HOME$\n" + "file:" + USER_HOME + " -> file:$USER_HOME$\n" + "file:/" + USER_HOME + " -> file:/$USER_HOME$\n" + "file://" + USER_HOME + " -> file://$USER_HOME$\n" + "jar:" + USER_HOME + " -> jar:$USER_HOME$\n" + "jar:/" + USER_HOME + " -> jar:/$USER_HOME$\n" + "jar://" + USER_HOME + " -> jar://$USER_HOME$\n" + "file:/tmp -> file:$PROJECT_DIR$/..\n" + "file://tmp -> file:/$PROJECT_DIR$/..\n" + "file:///tmp -> file://$PROJECT_DIR$/..\n" + "jar:/tmp -> jar:$PROJECT_DIR$/..\n" + "jar://tmp -> jar:/$PROJECT_DIR$/..\n" + "jar:///tmp -> jar://$PROJECT_DIR$/..\n" + "/tmp -> $PROJECT_DIR$/..");
}
use of com.intellij.application.options.ReplacePathToMacroMap in project intellij-community by JetBrains.
the class PathMacroManagerTest method testProjectUnderUserHome_ReplaceRecursively.
@SuppressWarnings("SpellCheckingInspection")
@Test
public void testProjectUnderUserHome_ReplaceRecursively() {
setUpMocks("/home/user/foo");
ReplacePathToMacroMap map = new ProjectPathMacroManager(myPathMacros, myProject).getReplacePathMap();
String src = "-Dfoo=/home/user/foo/bar/home -Dbar=\"/home/user\"";
String dst = "-Dfoo=$PROJECT_DIR$/bar/home -Dbar=\"$PROJECT_DIR$/..\"";
assertEquals(dst, map.substituteRecursively(src, true));
}
use of com.intellij.application.options.ReplacePathToMacroMap 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;
}
Aggregations