[jps model] fix loading attributes of iml root tag in the new implementation (IJPL-409)

The workspace model uses configurationStore API to load data, and there attributes of the root tag are represented as options in an artificial DeprecatedModuleOptionManager component.

GitOrigin-RevId: 2a0a197e8f41c491d5b9ffd9f707a9e2315f1301
This commit is contained in:
Nikolay Chashnikov
2024-06-27 18:25:54 +02:00
committed by intellij-monorepo-bot
parent 2d8fcf9a99
commit 2e8cb4a8e1

View File

@@ -28,7 +28,16 @@ internal class ProjectDirectJpsFileContentReader(
if (fileUrl.endsWith(".iml")) {
//todo support external storage
val loader = getModuleLoader(fileUrl)
return JDomSerializationUtil.findComponent(loader.loadRootElement(Path(JpsPathUtil.urlToPath(fileUrl))), componentName)
val rootElement = loader.loadRootElement(Path(JpsPathUtil.urlToPath(fileUrl)))
if (componentName == "DeprecatedModuleOptionManager") {
//this duplicates logic from ModuleStateStorageManager.beforeElementLoaded which is used to convert attributes to data in an artificial component
val componentTag = JDomSerializationUtil.createComponentElement(componentName)
rootElement?.attributes?.forEach { attribute ->
componentTag.addContent(Element("option").setAttribute("key", attribute.name).setAttribute("value", attribute.value))
}
return componentTag
}
return JDomSerializationUtil.findComponent(rootElement, componentName)
}
return loadProjectLevelComponent(fileUrl, componentName)
}