mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[jps model] refactoring: extract and reuse JpsComponentLoader.loadComponent method
GitOrigin-RevId: 907421fa095075d727feb207538340cf41e4dcd6
This commit is contained in:
committed by
intellij-monorepo-bot
parent
2e8cb4a8e1
commit
55fb09873d
+5
-1
@@ -41,6 +41,10 @@ public class JpsComponentLoader {
|
||||
return loadRootElement(file, myMacroExpander);
|
||||
}
|
||||
|
||||
public @Nullable Element loadComponent(@NotNull Path file, @NotNull String componentName) {
|
||||
return JDomSerializationUtil.findComponent(loadRootElement(file), componentName);
|
||||
}
|
||||
|
||||
public <E extends JpsElement> void loadComponents(@NotNull Path dir,
|
||||
@NotNull Path defaultConfigFile,
|
||||
JpsElementExtensionSerializerBase<E> serializer,
|
||||
@@ -60,7 +64,7 @@ public class JpsComponentLoader {
|
||||
|
||||
private @Nullable <E extends JpsElement> Element loadComponentData(@NotNull JpsElementExtensionSerializerBase<E> serializer, @NotNull Path configFile) {
|
||||
String componentName = serializer.getComponentName();
|
||||
Element component = JDomSerializationUtil.findComponent(loadRootElement(configFile), componentName);
|
||||
Element component = loadComponent(configFile, componentName);
|
||||
if (!(serializer instanceof JpsProjectExtensionWithExternalDataSerializer) || myExternalConfigurationDirectory == null) {
|
||||
return component;
|
||||
}
|
||||
|
||||
+2
-3
@@ -61,8 +61,7 @@ public final class JpsProjectConfigurationLoading {
|
||||
for (Path configurationFile : listXmlFiles(dir.resolve("runConfigurations"))) {
|
||||
JpsRunConfigurationSerializer.loadRunConfigurations(project, componentLoader.loadRootElement(configurationFile));
|
||||
}
|
||||
JpsRunConfigurationSerializer.loadRunConfigurations(project, JDomSerializationUtil.findComponent(
|
||||
componentLoader.loadRootElement(workspaceFile), "RunManager"));
|
||||
JpsRunConfigurationSerializer.loadRunConfigurations(project, componentLoader.loadComponent(workspaceFile, "RunManager"));
|
||||
runConfTimingLog.run();
|
||||
}
|
||||
}
|
||||
@@ -155,7 +154,7 @@ public final class JpsProjectConfigurationLoading {
|
||||
public static @NotNull Set<String> readNamesOfUnloadedModules(@NotNull Path workspaceFile, @NotNull JpsComponentLoader componentLoader) {
|
||||
Set<String> unloadedModules = new HashSet<>();
|
||||
if (workspaceFile.toFile().exists()) {
|
||||
Element unloadedModulesList = JDomSerializationUtil.findComponent(componentLoader.loadRootElement(workspaceFile), "UnloadedModulesList");
|
||||
Element unloadedModulesList = componentLoader.loadComponent(workspaceFile, "UnloadedModulesList");
|
||||
for (Element element : JDOMUtil.getChildren(unloadedModulesList, "module")) {
|
||||
unloadedModules.add(element.getAttributeValue("name"));
|
||||
}
|
||||
|
||||
+1
-1
@@ -158,7 +158,7 @@ public final class JpsProjectLoader {
|
||||
externalConfigDir = null;
|
||||
}
|
||||
|
||||
Element moduleData = JDomSerializationUtil.findComponent(myComponentLoader.loadRootElement(dir.resolve("modules.xml")), MODULE_MANAGER_COMPONENT);
|
||||
Element moduleData = myComponentLoader.loadComponent(dir.resolve("modules.xml"), MODULE_MANAGER_COMPONENT);
|
||||
Element externalModuleData;
|
||||
if (externalConfigDir == null) {
|
||||
externalModuleData = null;
|
||||
|
||||
+1
-2
@@ -17,8 +17,7 @@ internal class GlobalDirectJpsFileContentReader(private val macroExpander: JpsMa
|
||||
private val componentLoader = JpsComponentLoader(macroExpander, null)
|
||||
|
||||
override fun loadComponent(fileUrl: String, componentName: String, customModuleFilePath: String?): Element? {
|
||||
val rootElement = componentLoader.loadRootElement(Path(JpsPathUtil.urlToPath(fileUrl))) ?: return null
|
||||
return JDomSerializationUtil.findComponent(rootElement, componentName)
|
||||
return componentLoader.loadComponent(Path(JpsPathUtil.urlToPath(fileUrl)), componentName)
|
||||
}
|
||||
|
||||
override fun getExpandMacroMap(fileUrl: String): ExpandMacroToPathMap {
|
||||
|
||||
Reference in New Issue
Block a user