Search in sources :

Example 1 with ExpandMacroToPathMap

use of com.intellij.openapi.components.ExpandMacroToPathMap in project intellij-community by JetBrains.

the class ConversionContextImpl method getClassRoots.

@NotNull
public List<File> getClassRoots(Element libraryElement, @Nullable ModuleSettingsImpl moduleSettings) {
    List<File> files = new ArrayList<>();
    //todo[nik] support jar directories
    final Element classesChild = libraryElement.getChild("CLASSES");
    if (classesChild != null) {
        final ExpandMacroToPathMap pathMap = createExpandMacroMap(moduleSettings);
        for (Element root : classesChild.getChildren("root")) {
            final String url = root.getAttributeValue("url");
            final String path = VfsUtilCore.urlToPath(url);
            files.add(new File(PathUtil.getLocalPath(pathMap.substitute(path, true))));
        }
    }
    return files;
}
Also used : ExpandMacroToPathMap(com.intellij.openapi.components.ExpandMacroToPathMap) Element(org.jdom.Element) File(java.io.File) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with ExpandMacroToPathMap

use of com.intellij.openapi.components.ExpandMacroToPathMap in project intellij-community by JetBrains.

the class ModuleRootsExternalizationTest method testExpandMacro1.

public void testExpandMacro1() {
    final ExpandMacroToPathMap map = new ExpandMacroToPathMap();
    map.addMacroExpand("MACRO", "C:/idea");
    final String expanded = map.substitute("jar://$MACRO$/lib/forms_rt.jar!/", false);
    assertEquals("jar://C:/idea/lib/forms_rt.jar!/", expanded);
}
Also used : ExpandMacroToPathMap(com.intellij.openapi.components.ExpandMacroToPathMap)

Example 3 with ExpandMacroToPathMap

use of com.intellij.openapi.components.ExpandMacroToPathMap in project intellij-community by JetBrains.

the class ModuleRootsExternalizationTest method testExpandMacro3.

public void testExpandMacro3() {
    final ExpandMacroToPathMap map = new ExpandMacroToPathMap();
    map.addMacroExpand("MACRO1", "C:/idea");
    map.addMacroExpand("MACRO2", "forms_rt.jar!/");
    final String expanded = map.substitute("jar://$MACRO1$/lib/$MACRO2$", false);
    assertEquals("jar://C:/idea/lib/forms_rt.jar!/", expanded);
}
Also used : ExpandMacroToPathMap(com.intellij.openapi.components.ExpandMacroToPathMap)

Example 4 with ExpandMacroToPathMap

use of com.intellij.openapi.components.ExpandMacroToPathMap in project intellij-community by JetBrains.

the class ModuleRootsExternalizationTest method testExpandMacroNoExpand3.

public void testExpandMacroNoExpand3() {
    final ExpandMacroToPathMap map = new ExpandMacroToPathMap();
    map.addMacroExpand("MACRO", "C:/idea");
    final String expanded = map.substitute("jar://$UNKNOWN$/lib/forms_rt.jar!/", false);
    assertEquals("jar://$UNKNOWN$/lib/forms_rt.jar!/", expanded);
}
Also used : ExpandMacroToPathMap(com.intellij.openapi.components.ExpandMacroToPathMap)

Example 5 with ExpandMacroToPathMap

use of com.intellij.openapi.components.ExpandMacroToPathMap in project intellij-community by JetBrains.

the class BasePathMacroManager method getExpandMacroMap.

@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());
    }
    return result;
}
Also used : ExpandMacroToPathMap(com.intellij.openapi.components.ExpandMacroToPathMap) ExpandMacroToPathMap(com.intellij.openapi.components.ExpandMacroToPathMap) ReplacePathToMacroMap(com.intellij.application.options.ReplacePathToMacroMap) Map(java.util.Map) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

ExpandMacroToPathMap (com.intellij.openapi.components.ExpandMacroToPathMap)16 Element (org.jdom.Element)4 NotNull (org.jetbrains.annotations.NotNull)4 File (java.io.File)3 ReplacePathToMacroMap (com.intellij.application.options.ReplacePathToMacroMap)1 Logger (com.intellij.openapi.diagnostic.Logger)1 SystemInfo (com.intellij.openapi.util.SystemInfo)1 StringUtil (com.intellij.openapi.util.text.StringUtil)1 HashSet (com.intellij.util.containers.HashSet)1 FilenameFilter (java.io.FilenameFilter)1 IOException (java.io.IOException)1 java.util (java.util)1 Map (java.util.Map)1 TimeoutException (java.util.concurrent.TimeoutException)1 Nullable (org.jetbrains.annotations.Nullable)1 org.jetbrains.idea.eclipse (org.jetbrains.idea.eclipse)1 JpsElementFactory (org.jetbrains.jps.model.JpsElementFactory)1 org.jetbrains.jps.model.java (org.jetbrains.jps.model.java)1 JpsLibrary (org.jetbrains.jps.model.library.JpsLibrary)1 JpsLibraryReference (org.jetbrains.jps.model.library.JpsLibraryReference)1