mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-08 15:09:39 +07:00
[workspace model] Clear source folders of the removing content entity
Prior this fix remove of content entity doesn't remove related source folders. This was cause for not disposing VirtualFilePointers in LegacyBridgeRootsWatcher.syncNewRootsToContainer GitOrigin-RevId: 9216d229d9abb19e9ac1bca0fe8dce95a9423ef4
This commit is contained in:
committed by
intellij-monorepo-bot
parent
d6b0581f26
commit
b9cef22caa
@@ -590,6 +590,39 @@ class LegacyBridgeModulesTest {
|
||||
assertEmpty(entityStore.current.entities(ContentRootEntity::class.java).toList())
|
||||
assertEmpty(entityStore.current.entities(CustomSourceRootPropertiesEntity::class.java).toList())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test remove content entity removes related source folders`() = WriteCommandAction.runWriteCommandAction(project) {
|
||||
val moduleName = "build"
|
||||
val antLibraryFolder = "ant-lib"
|
||||
|
||||
val moduleFile = File(project.basePath, "$moduleName.iml")
|
||||
val module = ModuleManager.getInstance(project).modifiableModel.let { moduleModel ->
|
||||
val module = moduleModel.newModule(moduleFile.path, EmptyModuleType.getInstance().id, null) as LegacyBridgeModule
|
||||
moduleModel.commit()
|
||||
module
|
||||
}
|
||||
|
||||
ModuleRootModificationUtil.updateModel(module) { model ->
|
||||
val tempDir = temporaryDirectoryRule.newPath().toFile()
|
||||
val url = VfsUtilCore.pathToUrl(FileUtil.toSystemIndependentName(tempDir.path))
|
||||
val contentEntry = model.addContentEntry(url)
|
||||
contentEntry.addSourceFolder("$url/$antLibraryFolder", TestCustomSourceRootType.INSTANCE)
|
||||
}
|
||||
|
||||
val entityStore = WorkspaceModel.getInstance(project).entityStore
|
||||
assertEquals(1, entityStore.current.entities(ContentRootEntity::class.java).count())
|
||||
assertEquals(1, entityStore.current.entities(SourceRootEntity::class.java).count())
|
||||
|
||||
ModuleRootModificationUtil.updateModel(module) { model ->
|
||||
val contentEntries = model.contentEntries
|
||||
assertEquals(1, contentEntries.size)
|
||||
model.removeContentEntry(contentEntries[0])
|
||||
}
|
||||
|
||||
assertEmpty(entityStore.current.entities(ContentRootEntity::class.java).toList())
|
||||
assertEmpty(entityStore.current.entities(SourceRootEntity::class.java).toList())
|
||||
}
|
||||
}
|
||||
|
||||
internal fun createEmptyTestProject(temporaryDirectory: TemporaryDirectory,
|
||||
|
||||
@@ -113,6 +113,7 @@ class LegacyBridgeModifiableRootModel(
|
||||
val entity = currentModel.contentEntities.firstOrNull { it.url == contentEntryUrl }
|
||||
?: error("ContentEntry $entry does not belong to modifiableRootModel of module ${legacyBridgeModule.name}")
|
||||
|
||||
entry.clearSourceFolders()
|
||||
diff.removeEntity(entity)
|
||||
|
||||
if (assertChangesApplied && contentEntries.any { it.url == contentEntryUrl.url }) {
|
||||
|
||||
Reference in New Issue
Block a user