IJPL-191229 part 5 - reuse NonPersistentModuleStore

GitOrigin-RevId: 701626759cfa1c3f0f7ebe2ec0ef61deef7d8b8f
This commit is contained in:
Vladimir Krivosheev
2025-09-01 19:26:43 +00:00
committed by intellij-monorepo-bot
parent 5fc984e1bc
commit 1fa9994a94
5 changed files with 11 additions and 53 deletions
@@ -19,6 +19,6 @@ class DefaultModuleStoreFactory : ModuleStoreFactory {
return ModuleStoreImpl(module, pathMacroManager)
}
fun createNonPersistentStore(): IComponentStore = NonPersistentModuleStore
fun createNonPersistentStore(): IComponentStore = NonPersistentStore
}
}
@@ -3,7 +3,7 @@ package com.intellij.workspaceModel.ide.impl.legacyBridge.module
import com.intellij.configurationStore.DefaultModuleStoreFactory
import com.intellij.configurationStore.ModuleStoreFactory
import com.intellij.configurationStore.NonPersistentModuleStore
import com.intellij.configurationStore.NonPersistentStore
import com.intellij.configurationStore.RenameableStateStorageManager
import com.intellij.facet.FacetManagerFactory
import com.intellij.facet.impl.FacetEventsPublisher
@@ -57,7 +57,7 @@ open class ModuleBridgeImpl(
override fun getModuleFile(): VirtualFile? = imlFilePointer?.file
override fun canStoreSettings(): Boolean = imlFilePointer != null && componentStore !is NonPersistentModuleStore
override fun canStoreSettings(): Boolean = imlFilePointer != null && componentStore !is NonPersistentStore
override fun rename(newName: String, newModuleFileUrl: VirtualFileUrl?, notifyStorage: Boolean) {
imlFilePointer = newModuleFileUrl as VirtualFileUrlBridge
@@ -73,7 +73,7 @@ open class ModuleBridgeImpl(
val isDisposed = Disposer.isDisposed(this)
if (!isDisposed) {
val store = componentStore
if (store !is NonPersistentModuleStore) {
if (store !is NonPersistentStore) {
return store.storageManager.expandMacro(StoragePathMacros.MODULE_FILE)
}
}
@@ -19,6 +19,8 @@ import kotlin.coroutines.CoroutineContext
import kotlin.coroutines.EmptyCoroutineContext
import kotlin.test.assertContains
private val testPluginDescriptor: DefaultPluginDescriptor = DefaultPluginDescriptor("test")
class ServiceContainerTest {
@Test
fun `cyclic detection`() {
@@ -8,7 +8,7 @@ import org.jetbrains.annotations.ApiStatus
import java.nio.file.Path
@ApiStatus.Internal
object NonPersistentModuleStore : IComponentStore {
object NonPersistentStore : IComponentStore {
override val storageManager: StateStorageManager
get() = NonPersistentStateStorageManager
@@ -1,70 +1,26 @@
// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.serviceContainer
import com.intellij.configurationStore.StateStorageManager
import com.intellij.configurationStore.NonPersistentStore
import com.intellij.ide.plugins.IdeaPluginDescriptorImpl
import com.intellij.openapi.application.Application
import com.intellij.openapi.components.PersistentStateComponent
import com.intellij.openapi.components.ServiceDescriptor
import com.intellij.openapi.components.impl.stores.IComponentStore
import com.intellij.openapi.extensions.DefaultPluginDescriptor
import com.intellij.openapi.extensions.PluginId
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.DelicateCoroutinesApi
import kotlinx.coroutines.GlobalScope
import org.jetbrains.annotations.TestOnly
import kotlin.coroutines.EmptyCoroutineContext
val testPluginDescriptor: DefaultPluginDescriptor = DefaultPluginDescriptor("test")
@OptIn(DelicateCoroutinesApi::class)
@TestOnly
class TestComponentManager(
override var isGetComponentAdapterOfTypeCheckEnabled: Boolean = true,
@JvmField val parentScope: CoroutineScope = GlobalScope,
) :
ComponentManagerImpl(
parent = null,
parentScope = parentScope,
additionalContext = EmptyCoroutineContext,
) {
override val componentStore: IComponentStore = TestComponentStore()
) : ComponentManagerImpl(parent = null, parentScope = parentScope, additionalContext = EmptyCoroutineContext) {
override val componentStore: IComponentStore
get() = NonPersistentStore
override fun getContainerDescriptor(pluginDescriptor: IdeaPluginDescriptorImpl) = pluginDescriptor.appContainerDescriptor
override fun getApplication(): Application? = null
}
private class TestComponentStore : IComponentStore {
override val storageManager: StateStorageManager
get() = TODO("not implemented")
override fun initComponentBlocking(component: Any, serviceDescriptor: ServiceDescriptor?, pluginId: PluginId) {
}
override suspend fun initComponent(component: Any, serviceDescriptor: ServiceDescriptor?, pluginId: PluginId) {
}
override fun unloadComponent(component: Any) {
}
override fun initPersistencePlainComponent(component: Any, key: String, pluginId: PluginId) {
}
override fun reloadStates(componentNames: Set<String>) {
}
override fun reloadState(componentClass: Class<out PersistentStateComponent<*>>) {
}
override fun isReloadPossible(componentNames: Set<String>) = false
override suspend fun save(forceSavingAllSettings: Boolean) {
}
override fun saveComponent(component: PersistentStateComponent<*>) {
}
override fun removeComponent(name: String) {
}
}