Search in sources :

Example 11 with ExpandMacroToPathMap

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

the class ConversionContextImpl method findModuleFiles.

private File[] findModuleFiles(final Element root) {
    final Element modulesManager = JDomSerializationUtil.findComponent(root, ModuleManagerImpl.COMPONENT_NAME);
    if (modulesManager == null)
        return new File[0];
    final Element modules = modulesManager.getChild(ModuleManagerImpl.ELEMENT_MODULES);
    if (modules == null)
        return new File[0];
    final ExpandMacroToPathMap macros = createExpandMacroMap();
    List<File> files = new ArrayList<>();
    for (Element module : modules.getChildren(ModuleManagerImpl.ELEMENT_MODULE)) {
        String filePath = module.getAttributeValue(ModuleManagerImpl.ATTRIBUTE_FILEPATH);
        filePath = macros.substitute(filePath, true);
        files.add(new File(FileUtil.toSystemDependentName(filePath)));
    }
    return files.toArray(new File[files.size()]);
}
Also used : ExpandMacroToPathMap(com.intellij.openapi.components.ExpandMacroToPathMap) Element(org.jdom.Element) File(java.io.File)

Example 12 with ExpandMacroToPathMap

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

the class FileEditorManagerTestCase method openFiles.

protected void openFiles(@NotNull String femSerialisedText) throws IOException, JDOMException, InterruptedException, ExecutionException {
    Element rootElement = JdomKt.loadElement(femSerialisedText);
    ExpandMacroToPathMap map = new ExpandMacroToPathMap();
    map.addMacroExpand(PathMacroUtil.PROJECT_DIR_MACRO_NAME, getTestDataPath());
    map.substitute(rootElement, true, true);
    myManager.loadState(rootElement);
    Future<?> future = ApplicationManager.getApplication().executeOnPooledThread(() -> myManager.getMainSplitters().openFiles());
    while (true) {
        try {
            future.get(100, TimeUnit.MILLISECONDS);
            return;
        } catch (TimeoutException e) {
            UIUtil.dispatchAllInvocationEvents();
        }
    }
}
Also used : ExpandMacroToPathMap(com.intellij.openapi.components.ExpandMacroToPathMap) Element(org.jdom.Element) TimeoutException(java.util.concurrent.TimeoutException)

Example 13 with ExpandMacroToPathMap

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

the class ModulePathMacroManager method getExpandMacroMap.

@NotNull
@Override
public ExpandMacroToPathMap getExpandMacroMap() {
    ExpandMacroToPathMap result = super.getExpandMacroMap();
    addFileHierarchyReplacements(result, PathMacroUtil.MODULE_DIR_MACRO_NAME, PathMacroUtil.getModuleDir(myModule.getModuleFilePath()));
    return result;
}
Also used : ExpandMacroToPathMap(com.intellij.openapi.components.ExpandMacroToPathMap) NotNull(org.jetbrains.annotations.NotNull)

Example 14 with ExpandMacroToPathMap

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

the class ProjectPathMacroManager method getExpandMacroMap.

@NotNull
@Override
public ExpandMacroToPathMap getExpandMacroMap() {
    final ExpandMacroToPathMap result = super.getExpandMacroMap();
    addFileHierarchyReplacements(result, PathMacroUtil.PROJECT_DIR_MACRO_NAME, myProject.getBasePath());
    return result;
}
Also used : ExpandMacroToPathMap(com.intellij.openapi.components.ExpandMacroToPathMap) NotNull(org.jetbrains.annotations.NotNull)

Example 15 with ExpandMacroToPathMap

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

the class JpsEclipseClasspathReader method addJUnitDefaultLib.

@Override
protected void addJUnitDefaultLib(JpsModule rootModel, String junitName, ExpandMacroToPathMap macroMap) {
    final String ideaHome = macroMap.substitute("$APPLICATION_HOME_DIR$", SystemInfo.isFileSystemCaseSensitive);
    final FilenameFilter junitFilter = (dir, name) -> name.startsWith("junit");
    File[] junitJars = new File(ideaHome, "lib").listFiles(junitFilter);
    if (junitJars == null || junitJars.length == 0) {
        junitJars = new File(new File(ideaHome, "community"), "lib").listFiles(junitFilter);
    }
    if (junitJars != null && junitJars.length > 0) {
        final boolean isJUnit4 = junitName.contains("4");
        File junitJar = null;
        for (File jar : junitJars) {
            final boolean isCurrentJarV4 = jar.getName().contains("4");
            if (isCurrentJarV4 && isJUnit4 || !isCurrentJarV4 && !isJUnit4) {
                junitJar = jar;
                break;
            }
        }
        if (junitJar != null) {
            final JpsLibrary jpsLibrary = rootModel.addModuleLibrary(junitName, JpsJavaLibraryType.INSTANCE);
            jpsLibrary.addRoot(pathToUrl(junitJar.getPath()), JpsOrderRootType.COMPILED);
            final JpsDependenciesList dependenciesList = rootModel.getDependenciesList();
            dependenciesList.addLibraryDependency(jpsLibrary);
        }
    }
}
Also used : FilenameFilter(java.io.FilenameFilter) java.util(java.util) JpsOrderRootType(org.jetbrains.jps.model.library.JpsOrderRootType) StringUtil(com.intellij.openapi.util.text.StringUtil) ExpandMacroToPathMap(com.intellij.openapi.components.ExpandMacroToPathMap) org.jetbrains.jps.model.java(org.jetbrains.jps.model.java) HashSet(com.intellij.util.containers.HashSet) IOException(java.io.IOException) org.jetbrains.jps.model.module(org.jetbrains.jps.model.module) SystemInfo(com.intellij.openapi.util.SystemInfo) File(java.io.File) Nullable(org.jetbrains.annotations.Nullable) org.jetbrains.idea.eclipse(org.jetbrains.idea.eclipse) JpsLibraryReference(org.jetbrains.jps.model.library.JpsLibraryReference) JpsElementFactory(org.jetbrains.jps.model.JpsElementFactory) JpsLibraryTableSerializer(org.jetbrains.jps.model.serialization.library.JpsLibraryTableSerializer) Logger(com.intellij.openapi.diagnostic.Logger) Element(org.jdom.Element) JpsLibrary(org.jetbrains.jps.model.library.JpsLibrary) JpsMacroExpander(org.jetbrains.jps.model.serialization.JpsMacroExpander) FilenameFilter(java.io.FilenameFilter) File(java.io.File) JpsLibrary(org.jetbrains.jps.model.library.JpsLibrary)

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