From 1fa9994a94b4a657430c772d882bf98b1926aeb3 Mon Sep 17 00:00:00 2001 From: Vladimir Krivosheev Date: Mon, 1 Sep 2025 18:48:14 +0200 Subject: [PATCH] IJPL-191229 part 5 - reuse NonPersistentModuleStore GitOrigin-RevId: 701626759cfa1c3f0f7ebe2ec0ef61deef7d8b8f --- .../src/DefaultModuleStoreFactory.kt | 2 +- .../legacyBridge/module/ModuleBridgeImpl.kt | 6 +-- .../serviceContainer/ServiceContainerTest.kt | 2 + .../configurationStore/NonPersistentStore.kt} | 2 +- .../serviceContainer/TestComponentManager.kt | 52 ++----------------- 5 files changed, 11 insertions(+), 53 deletions(-) rename platform/{configuration-store-impl/src/NonPersistentModuleStore.kt => projectModel-impl/src/com/intellij/configurationStore/NonPersistentStore.kt} (97%) diff --git a/platform/configuration-store-impl/src/DefaultModuleStoreFactory.kt b/platform/configuration-store-impl/src/DefaultModuleStoreFactory.kt index 686c94ffbabf..0634e484395a 100644 --- a/platform/configuration-store-impl/src/DefaultModuleStoreFactory.kt +++ b/platform/configuration-store-impl/src/DefaultModuleStoreFactory.kt @@ -19,6 +19,6 @@ class DefaultModuleStoreFactory : ModuleStoreFactory { return ModuleStoreImpl(module, pathMacroManager) } - fun createNonPersistentStore(): IComponentStore = NonPersistentModuleStore + fun createNonPersistentStore(): IComponentStore = NonPersistentStore } } \ No newline at end of file diff --git a/platform/lang-impl/src/com/intellij/workspaceModel/ide/impl/legacyBridge/module/ModuleBridgeImpl.kt b/platform/lang-impl/src/com/intellij/workspaceModel/ide/impl/legacyBridge/module/ModuleBridgeImpl.kt index c904376efdd9..cb097fedba3d 100644 --- a/platform/lang-impl/src/com/intellij/workspaceModel/ide/impl/legacyBridge/module/ModuleBridgeImpl.kt +++ b/platform/lang-impl/src/com/intellij/workspaceModel/ide/impl/legacyBridge/module/ModuleBridgeImpl.kt @@ -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) } } diff --git a/platform/platform-tests/testSrc/com/intellij/serviceContainer/ServiceContainerTest.kt b/platform/platform-tests/testSrc/com/intellij/serviceContainer/ServiceContainerTest.kt index 56ea70fef7c3..d489bf7ca42f 100644 --- a/platform/platform-tests/testSrc/com/intellij/serviceContainer/ServiceContainerTest.kt +++ b/platform/platform-tests/testSrc/com/intellij/serviceContainer/ServiceContainerTest.kt @@ -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`() { diff --git a/platform/configuration-store-impl/src/NonPersistentModuleStore.kt b/platform/projectModel-impl/src/com/intellij/configurationStore/NonPersistentStore.kt similarity index 97% rename from platform/configuration-store-impl/src/NonPersistentModuleStore.kt rename to platform/projectModel-impl/src/com/intellij/configurationStore/NonPersistentStore.kt index c3c9f606259d..95ae9e38793c 100644 --- a/platform/configuration-store-impl/src/NonPersistentModuleStore.kt +++ b/platform/projectModel-impl/src/com/intellij/configurationStore/NonPersistentStore.kt @@ -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 diff --git a/platform/service-container/testSrc/com/intellij/serviceContainer/TestComponentManager.kt b/platform/service-container/testSrc/com/intellij/serviceContainer/TestComponentManager.kt index 3451553dda68..6eef67e6bd7f 100644 --- a/platform/service-container/testSrc/com/intellij/serviceContainer/TestComponentManager.kt +++ b/platform/service-container/testSrc/com/intellij/serviceContainer/TestComponentManager.kt @@ -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) { - } - - override fun reloadState(componentClass: Class>) { - } - - override fun isReloadPossible(componentNames: Set) = false - - override suspend fun save(forceSavingAllSettings: Boolean) { - } - - override fun saveComponent(component: PersistentStateComponent<*>) { - } - - override fun removeComponent(name: String) { - } } \ No newline at end of file