From 025df96061d686fa599ada9510a1923835e40011 Mon Sep 17 00:00:00 2001 From: Vladimir Krivosheev Date: Wed, 26 Apr 2017 18:00:54 +0200 Subject: [PATCH] extract isUseLoadedStateAsExisting to simplify doInitComponent method --- .../src/ComponentStoreImpl.kt | 32 +++++++++---------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/platform/configuration-store-impl/src/ComponentStoreImpl.kt b/platform/configuration-store-impl/src/ComponentStoreImpl.kt index e67a08aae8f9..c826ea395fa7 100644 --- a/platform/configuration-store-impl/src/ComponentStoreImpl.kt +++ b/platform/configuration-store-impl/src/ComponentStoreImpl.kt @@ -306,29 +306,14 @@ abstract class ComponentStoreImpl : IComponentStore { val defaultState = if (stateSpec.defaultStateAsResource) getDefaultState(component, name, stateClass) else null if (loadPolicy == StateLoadPolicy.LOAD) { - val storageSpecs = getStorageSpecs(component, stateSpec, StateStorageOperation.READ) val storageChooser = component as? StateStorageChooserEx - for (storageSpec in storageSpecs) { + for (storageSpec in getStorageSpecs(component, stateSpec, StateStorageOperation.READ)) { if (storageChooser?.getResolution(storageSpec, StateStorageOperation.READ) == Resolution.SKIP) { continue } val storage = storageManager.getStateStorage(storageSpec) - // todo "ProjectModuleManager" investigate why after loadState we get empty state on getState, test CMakeWorkspaceContentRootsTest - // todo fix FacetManager - // use.loaded.state.as.existing used in upsource - val stateGetter = if (isUseLoadedStateAsExisting(storage) && - name != "AntConfiguration" && - name != "ProjectModuleManager" && - name != "FacetManager" && - name != "NewModuleRootManager" /* will be changed only on actual user change, so, to speed up module loading, skip it */ && - name != "DeprecatedModuleOptionManager" /* doesn't make sense to check it */ && - SystemPropertyUtil.getBoolean("use.loaded.state.as.existing", true)) { - (storage as? StorageBaseEx<*>)?.createGetSession(component, name, stateClass) - } - else { - null - } + val stateGetter = if (isUseLoadedStateAsExisting(storage, name)) (storage as? StorageBaseEx<*>)?.createGetSession(component, name, stateClass) else null var state = if (stateGetter == null) storage.getState(component, name, stateClass, defaultState, reloadData) else stateGetter.getState(defaultState) if (state == null) { if (changedStorages != null && changedStorages.contains(storage)) { @@ -361,6 +346,19 @@ abstract class ComponentStoreImpl : IComponentStore { return true } + // todo "ProjectModuleManager" investigate why after loadState we get empty state on getState, test CMakeWorkspaceContentRootsTest + // todo fix FacetManager + // use.loaded.state.as.existing used in upsource + private fun isUseLoadedStateAsExisting(storage: StateStorage, name: String): Boolean { + return isUseLoadedStateAsExisting(storage) && + name != "AntConfiguration" && + name != "ProjectModuleManager" && + name != "FacetManager" && + name != "NewModuleRootManager" /* will be changed only on actual user change, so, to speed up module loading, skip it */ && + name != "DeprecatedModuleOptionManager" /* doesn't make sense to check it */ && + SystemPropertyUtil.getBoolean("use.loaded.state.as.existing", true) + } + protected open fun isUseLoadedStateAsExisting(storage: StateStorage): Boolean = (storage as? XmlElementStorage)?.roamingType != RoamingType.DISABLED protected open fun getPathMacroManagerForDefaults(): PathMacroManager? = null