From d63710b315afb86d5548274df4b8f2022bbbbb4e Mon Sep 17 00:00:00 2001 From: Vladimir Krivosheev Date: Mon, 7 Jan 2019 12:28:37 +0100 Subject: [PATCH] save modules before saving project MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Also, remove not required anymore beforeSave — beforeSaveComponents is enough --- .../src/ComponentStoreImpl.kt | 4 ++-- .../src/ComponentStoreWithExtraComponents.kt | 3 ++- .../src/ProjectStoreImpl.kt | 13 ++++--------- 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/platform/configuration-store-impl/src/ComponentStoreImpl.kt b/platform/configuration-store-impl/src/ComponentStoreImpl.kt index 04d613fd5cfd..cc90f8712bd3 100644 --- a/platform/configuration-store-impl/src/ComponentStoreImpl.kt +++ b/platform/configuration-store-impl/src/ComponentStoreImpl.kt @@ -134,7 +134,7 @@ abstract class ComponentStoreImpl : IComponentStore { final override fun save(readonlyFiles: MutableList, isForce: Boolean) { val errors: MutableList = SmartList() - beforeSaveComponents(errors) + beforeSaveComponents(errors, readonlyFiles) val saveSessionProducerManager = if (components.isEmpty()) null else SaveSessionProducerManager() if (saveSessionProducerManager != null) { @@ -155,7 +155,7 @@ abstract class ComponentStoreImpl : IComponentStore { CompoundRuntimeException.throwIfNotEmpty(errors) } - protected open fun beforeSaveComponents(errors: MutableList) { + protected open fun beforeSaveComponents(errors: MutableList, readonlyFiles: MutableList) { } protected open fun afterSaveComponents(errors: MutableList, isForce: Boolean) { diff --git a/platform/configuration-store-impl/src/ComponentStoreWithExtraComponents.kt b/platform/configuration-store-impl/src/ComponentStoreWithExtraComponents.kt index 60aa21d61de3..ba25ae3e2265 100644 --- a/platform/configuration-store-impl/src/ComponentStoreWithExtraComponents.kt +++ b/platform/configuration-store-impl/src/ComponentStoreWithExtraComponents.kt @@ -3,6 +3,7 @@ package com.intellij.configurationStore import com.intellij.configurationStore.schemeManager.SchemeManagerFactoryBase import com.intellij.openapi.components.SettingsSavingComponent +import com.intellij.openapi.components.impl.stores.SaveSessionAndFile import com.intellij.openapi.progress.ProcessCanceledException import com.intellij.project.isDirectoryBased @@ -17,7 +18,7 @@ abstract class ComponentStoreWithExtraComponents : ComponentStoreImpl() { super.initComponent(component, isService) } - override fun beforeSaveComponents(errors: MutableList) { + override fun beforeSaveComponents(errors: MutableList, readonlyFiles: MutableList) { // component state uses scheme manager in an ipr project, so, we must save it before val isIprProject = project?.let { !it.isDirectoryBased } ?: false if (isIprProject) { diff --git a/platform/configuration-store-impl/src/ProjectStoreImpl.kt b/platform/configuration-store-impl/src/ProjectStoreImpl.kt index 98165720aea0..916bf01f42e0 100644 --- a/platform/configuration-store-impl/src/ProjectStoreImpl.kt +++ b/platform/configuration-store-impl/src/ProjectStoreImpl.kt @@ -322,7 +322,7 @@ private open class ProjectStoreImpl(project: Project, private val pathMacroManag } } - final override fun beforeSaveComponents(errors: MutableList) { + override fun beforeSaveComponents(errors: MutableList, readonlyFiles: MutableList) { try { saveProjectName() } @@ -330,12 +330,10 @@ private open class ProjectStoreImpl(project: Project, private val pathMacroManag LOG.error("Unable to store project name", e) } - super.beforeSaveComponents(errors) + super.beforeSaveComponents(errors, readonlyFiles) } override fun doSave(saveSession: SaveExecutor, readonlyFiles: MutableList, errors: MutableList) { - beforeSave(readonlyFiles) - super.doSave(saveSession, readonlyFiles, errors) val notifications = NotificationsManager.getNotificationsManager().getNotificationsOfType(UnableToSaveProjectNotification::class.java, project) @@ -369,9 +367,6 @@ private open class ProjectStoreImpl(project: Project, private val pathMacroManag throw IComponentStore.SaveCancelledException() } } - - protected open fun beforeSave(readonlyFiles: MutableList) { - } } private fun dropUnableToSaveProjectNotification(project: Project, readOnlyFiles: List) { @@ -387,8 +382,8 @@ private fun dropUnableToSaveProjectNotification(project: Project, readOnlyFiles: private fun getFilesList(readonlyFiles: List) = readonlyFiles.mapSmart { it.file } private class ProjectWithModulesStoreImpl(project: Project, pathMacroManager: PathMacroManager) : ProjectStoreImpl(project, pathMacroManager) { - override fun beforeSave(readonlyFiles: MutableList) { - super.beforeSave(readonlyFiles) + override fun beforeSaveComponents(errors: MutableList, readonlyFiles: MutableList) { + super.beforeSaveComponents(errors, readonlyFiles) for (module in (ModuleManager.getInstance(project)?.modules ?: Module.EMPTY_ARRAY)) { module.stateStore.save(readonlyFiles)