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()]);
}
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();
}
}
}
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;
}
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;
}
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);
}
}
}
Aggregations