mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[workspace-model] Extract logic of removing the unloaded module to the method
GitOrigin-RevId: 139a948e8a66b7b0a38045742d0365ca3ee54b3d
This commit is contained in:
committed by
intellij-monorepo-bot
parent
fb015d184a
commit
b6385b014e
+12
-16
@@ -75,14 +75,7 @@ internal class LegacyBridgeModifiableModuleModel(
|
||||
if (findModuleByName(moduleName) != null) {
|
||||
throw ModuleWithNameAlreadyExists("Module already exists: $moduleName", moduleName)
|
||||
}
|
||||
|
||||
// If module name equals to already unloaded module, the previous should be removed from store
|
||||
val unloadedModuleDescription = moduleManager.getUnloadedModuleDescription(moduleName)
|
||||
if (unloadedModuleDescription != null) {
|
||||
val moduleEntity = entityStoreOnDiff.current.resolve(ModuleId(unloadedModuleDescription.name))
|
||||
?: error("Could not find module to remove by id: ${unloadedModuleDescription.name}")
|
||||
diff.removeEntity(moduleEntity)
|
||||
}
|
||||
removeUnloadedModule(moduleName)
|
||||
|
||||
val entitySource = JpsProjectEntitiesLoader.createEntitySourceForModule(project, virtualFileManager.fromPath(PathUtil.getParentPath(canonicalPath)), null)
|
||||
|
||||
@@ -115,6 +108,16 @@ internal class LegacyBridgeModifiableModuleModel(
|
||||
return null
|
||||
}
|
||||
|
||||
private fun removeUnloadedModule(moduleName: String) {
|
||||
// If module name equals to already unloaded module, the previous should be removed from store
|
||||
val unloadedModuleDescription = moduleManager.getUnloadedModuleDescription(moduleName)
|
||||
if (unloadedModuleDescription != null) {
|
||||
val moduleEntity = entityStoreOnDiff.current.resolve(ModuleId(unloadedModuleDescription.name))
|
||||
?: error("Could not find module to remove by id: ${unloadedModuleDescription.name}")
|
||||
diff.removeEntity(moduleEntity)
|
||||
}
|
||||
}
|
||||
|
||||
// TODO Actually load module content
|
||||
override fun loadModule(filePath: String): Module =
|
||||
newModule(filePath, "")
|
||||
@@ -210,14 +213,7 @@ internal class LegacyBridgeModifiableModuleModel(
|
||||
if (module.name != newName) { // if renaming to itself, forget it altogether
|
||||
myNewNameToModule[newName] = module
|
||||
}
|
||||
|
||||
// If module name equals to already unloaded module, the previous should be removed from store
|
||||
val unloadedModuleDescription = moduleManager.getUnloadedModuleDescription(newName)
|
||||
if (unloadedModuleDescription != null) {
|
||||
val moduleEntity = entityStoreOnDiff.current.resolve(ModuleId(unloadedModuleDescription.name))
|
||||
?: error("Could not find module to remove by id: ${unloadedModuleDescription.name}")
|
||||
diff.removeEntity(moduleEntity)
|
||||
}
|
||||
removeUnloadedModule(newName)
|
||||
|
||||
if (oldModule != null) {
|
||||
throw ModuleWithNameAlreadyExists(ProjectModelBundle.message("module.already.exists.error", newName), newName)
|
||||
|
||||
Reference in New Issue
Block a user