Search in sources :

Example 1 with ReplacePathToMacroMap

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;
}
Also used : ReplacePathToMacroMap(com.intellij.application.options.ReplacePathToMacroMap) Element(org.jdom.Element) Nullable(org.jetbrains.annotations.Nullable)

Example 2 with ReplacePathToMacroMap

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;
}
Also used : ReplacePathToMacroMap(com.intellij.application.options.ReplacePathToMacroMap)

Example 3 with ReplacePathToMacroMap

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$/..");
}
Also used : ReplacePathToMacroMap(com.intellij.application.options.ReplacePathToMacroMap) Test(org.junit.Test)

Example 4 with ReplacePathToMacroMap

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));
}
Also used : ReplacePathToMacroMap(com.intellij.application.options.ReplacePathToMacroMap) Test(org.junit.Test)

Example 5 with ReplacePathToMacroMap

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;
}
Also used : PathMacros(com.intellij.openapi.application.PathMacros) ReplacePathToMacroMap(com.intellij.application.options.ReplacePathToMacroMap)

Aggregations

ReplacePathToMacroMap (com.intellij.application.options.ReplacePathToMacroMap)13 Test (org.junit.Test)4 NotNull (org.jetbrains.annotations.NotNull)3 PathMacros (com.intellij.openapi.application.PathMacros)1 ExpandMacroToPathMap (com.intellij.openapi.components.ExpandMacroToPathMap)1 Map (java.util.Map)1 Element (org.jdom.Element)1 Nullable (org.jetbrains.annotations.Nullable)1