mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
platform: fix automatic unloading of newly added modules if some modules point to non-existing iml files (IDEA-208237)
UnloadedModuleDescriptionImpl.createFromPaths doesn't return entries for non-existing iml files, so we shouldn't try to unload such modules.
This commit is contained in:
@@ -88,6 +88,23 @@ class AutomaticModuleUnloaderTest : ModuleTestCase() {
|
||||
doTest("b", listOf("c"), {}, "b", "c")
|
||||
}
|
||||
|
||||
fun `test deleted iml file`() = runBlocking {
|
||||
createModule("a")
|
||||
createModule("b")
|
||||
val deletedIml = createModule("deleted")
|
||||
val moduleManager = ModuleManager.getInstance(project)
|
||||
moduleManager.setUnloadedModules(listOf("a"))
|
||||
createModule("c")
|
||||
|
||||
val moduleFiles = createNewModuleFiles(listOf("d")) {}
|
||||
reloadProjectWithNewModules(moduleFiles) {
|
||||
File(deletedIml.moduleFilePath).delete()
|
||||
}
|
||||
|
||||
ModuleTestCase.assertSameElements(moduleManager.unloadedModuleDescriptions.map { it.name }, "a", "d")
|
||||
}
|
||||
|
||||
|
||||
private suspend fun doTest(initiallyUnloaded: String,
|
||||
newModulesName: List<String>,
|
||||
setup: (Map<String, Module>) -> Unit,
|
||||
@@ -125,13 +142,14 @@ class AutomaticModuleUnloaderTest : ModuleTestCase() {
|
||||
return moduleFiles
|
||||
}
|
||||
|
||||
private suspend fun reloadProjectWithNewModules(moduleFiles: List<File>) {
|
||||
private suspend fun reloadProjectWithNewModules(moduleFiles: List<File>, beforeReload: () -> Unit = {}) {
|
||||
val moduleManager = ModuleManagerImpl.getInstanceImpl(myProject)
|
||||
val modulePaths = LinkedHashSet<ModulePath>()
|
||||
moduleManager.modules.forEach { it.stateStore.save() }
|
||||
moduleManager.modules.mapTo(modulePaths) { ModulePath(it.moduleFilePath, null) }
|
||||
moduleManager.unloadedModuleDescriptions.mapTo(modulePaths) { (it as UnloadedModuleDescriptionImpl).modulePath }
|
||||
moduleFiles.mapTo(modulePaths) { ModulePath(FileUtil.toSystemIndependentName(it.absolutePath), null) }
|
||||
beforeReload()
|
||||
moduleManager.loadStateFromModulePaths(modulePaths)
|
||||
}
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ class AutomaticModuleUnloader(private val project: Project) : PersistentStateCom
|
||||
|
||||
val newLoadedNames = oldLoadedWithDependencies.mapTo(LinkedHashSet()) { it.name }
|
||||
val toLoad = modulesToLoad.filter { it.moduleName in newLoadedNames && it.moduleName !in oldLoaded}
|
||||
val toUnload = modulesToLoad.filter { it.moduleName !in newLoadedNames }
|
||||
val toUnload = modulesToLoad.filter { it.moduleName !in newLoadedNames && it.moduleName in moduleDescriptions}
|
||||
loadedModulesListStorage.modules.clear()
|
||||
modulesToLoad.filter { it.moduleName in newLoadedNames }.mapTo(loadedModulesListStorage.modules) { it.moduleName }
|
||||
val change = UnloadedModulesListChange(toLoad, toUnload, toUnload.map { moduleDescriptions[it.moduleName]!! })
|
||||
|
||||
Reference in New Issue
Block a user