mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
jps model: don't load and parse each iml file twice
This commit is contained in:
+29
-24
@@ -17,6 +17,7 @@ package org.jetbrains.jps.model.serialization;
|
||||
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.util.JDOMUtil;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.io.FileUtilRt;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
@@ -226,8 +227,8 @@ public class JpsProjectLoader extends JpsLoaderBase {
|
||||
if (componentRoot == null) return;
|
||||
final Element modules = componentRoot.getChild("modules");
|
||||
List<Future<JpsModule>> futures = new ArrayList<Future<JpsModule>>();
|
||||
final List<String> paths = new ArrayList<String>();
|
||||
final List<String> classpathDirs = new ArrayList<String>();
|
||||
|
||||
List<Future<Pair<File, Element>>> futureModuleFiles = new ArrayList<Future<Pair<File, Element>>>();
|
||||
for (Element moduleElement : JDOMUtil.getChildren(modules, "module")) {
|
||||
final String path = moduleElement.getAttributeValue("filepath");
|
||||
final File file = new File(path);
|
||||
@@ -236,23 +237,34 @@ public class JpsProjectLoader extends JpsLoaderBase {
|
||||
continue;
|
||||
}
|
||||
|
||||
final JpsMacroExpander expander = createModuleMacroExpander(myPathVariables, file);
|
||||
final Element moduleRoot = loadRootElement(file, expander);
|
||||
final String classpathDir = moduleRoot.getAttributeValue(CLASSPATH_DIR_ATTRIBUTE);
|
||||
if (classpathDir != null) {
|
||||
classpathDirs.add(classpathDir);
|
||||
}
|
||||
paths.add(path);
|
||||
}
|
||||
for (final String path : paths) {
|
||||
futures.add(ourThreadPool.submit(new Callable<JpsModule>() {
|
||||
futureModuleFiles.add(ourThreadPool.submit(new Callable<Pair<File, Element>>() {
|
||||
@Override
|
||||
public JpsModule call() throws Exception {
|
||||
return loadModule(path, classpathDirs, projectSdkType);
|
||||
public Pair<File, Element> call() throws Exception {
|
||||
final JpsMacroExpander expander = createModuleMacroExpander(myPathVariables, file);
|
||||
final Element moduleRoot = loadRootElement(file, expander);
|
||||
return Pair.create(file, moduleRoot);
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
try {
|
||||
final List<String> classpathDirs = new ArrayList<String>();
|
||||
for (Future<Pair<File, Element>> moduleFile : futureModuleFiles) {
|
||||
final String classpathDir = moduleFile.get().getSecond().getAttributeValue(CLASSPATH_DIR_ATTRIBUTE);
|
||||
if (classpathDir != null) {
|
||||
classpathDirs.add(classpathDir);
|
||||
}
|
||||
}
|
||||
|
||||
for (final Future<Pair<File, Element>> futureModuleFile : futureModuleFiles) {
|
||||
final Pair<File, Element> moduleFile = futureModuleFile.get();
|
||||
futures.add(ourThreadPool.submit(new Callable<JpsModule>() {
|
||||
@Override
|
||||
public JpsModule call() throws Exception {
|
||||
return loadModule(moduleFile.getFirst(), moduleFile.getSecond(), classpathDirs, projectSdkType);
|
||||
}
|
||||
}));
|
||||
}
|
||||
for (Future<JpsModule> future : futures) {
|
||||
JpsModule module = future.get();
|
||||
if (module != null) {
|
||||
@@ -267,21 +279,13 @@ public class JpsProjectLoader extends JpsLoaderBase {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private JpsModule loadModule(@NotNull String path, List<String> paths, @Nullable JpsSdkType<?> projectSdkType) {
|
||||
final File file = new File(path);
|
||||
private JpsModule loadModule(@NotNull File file, @NotNull Element moduleRoot, List<String> paths, @Nullable JpsSdkType<?> projectSdkType) {
|
||||
String name = FileUtil.getNameWithoutExtension(file);
|
||||
if (!file.exists()) {
|
||||
LOG.info("Module '" + name + "' is skipped: " + file.getAbsolutePath() + " doesn't exist");
|
||||
return null;
|
||||
}
|
||||
|
||||
final JpsMacroExpander expander = createModuleMacroExpander(myPathVariables, file);
|
||||
final Element moduleRoot = loadRootElement(file, expander);
|
||||
final String typeId = moduleRoot.getAttributeValue("type");
|
||||
final JpsModulePropertiesSerializer<?> serializer = getModulePropertiesSerializer(typeId);
|
||||
final JpsModule module = createModule(name, moduleRoot, serializer);
|
||||
module.getContainer().setChild(JpsModuleSerializationDataExtensionImpl.ROLE,
|
||||
new JpsModuleSerializationDataExtensionImpl(file.getParentFile()));
|
||||
new JpsModuleSerializationDataExtensionImpl(file.getParentFile()));
|
||||
|
||||
for (JpsModelSerializerExtension extension : JpsModelSerializerExtension.getExtensions()) {
|
||||
extension.loadModuleOptions(module, moduleRoot);
|
||||
@@ -298,6 +302,7 @@ public class JpsProjectLoader extends JpsLoaderBase {
|
||||
JpsModuleClasspathSerializer classpathSerializer = extension.getClasspathSerializer();
|
||||
if (classpathSerializer != null && classpathSerializer.getClasspathId().equals(classpath)) {
|
||||
String classpathDir = moduleRoot.getAttributeValue(CLASSPATH_DIR_ATTRIBUTE);
|
||||
final JpsMacroExpander expander = createModuleMacroExpander(myPathVariables, file);
|
||||
classpathSerializer.loadClasspath(module, classpathDir, baseModulePath, expander, paths, projectSdkType);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user