diff --git a/platform/lang-impl/src/com/intellij/execution/impl/ProjectRunConfigurationManager.kt b/platform/lang-impl/src/com/intellij/execution/impl/ProjectRunConfigurationInitializer.kt similarity index 52% rename from platform/lang-impl/src/com/intellij/execution/impl/ProjectRunConfigurationManager.kt rename to platform/lang-impl/src/com/intellij/execution/impl/ProjectRunConfigurationInitializer.kt index 40776207a2fe..c77bb5c56ddb 100644 --- a/platform/lang-impl/src/com/intellij/execution/impl/ProjectRunConfigurationManager.kt +++ b/platform/lang-impl/src/com/intellij/execution/impl/ProjectRunConfigurationInitializer.kt @@ -17,13 +17,9 @@ package com.intellij.execution.impl import com.intellij.execution.IS_RUN_MANAGER_INITIALIZED import com.intellij.execution.RunManager -import com.intellij.execution.configurations.UnknownRunConfiguration -import com.intellij.openapi.components.* +import com.intellij.openapi.components.service import com.intellij.openapi.project.Project import com.intellij.openapi.project.impl.ProjectLifecycleListener -import com.intellij.openapi.util.Pair -import gnu.trove.THashSet -import org.jdom.Element internal class ProjectRunConfigurationInitializer(project: Project) { init { @@ -45,45 +41,6 @@ internal class ProjectRunConfigurationInitializer(project: Project) { IS_RUN_MANAGER_INITIALIZED.set(project, true) // we must not fire beginUpdate here, because message bus will fire queued parent message bus messages (and, so, SOE may occur because all other projectOpened will be processed before us) // simply, you should not listen changes until project opened - if (isUseProjectSchemeManager()) { - project.service() - } - else { - project.service() - } + project.service() } -} - -@State(name = "ProjectRunConfigurationManager", storages = arrayOf(Storage(value = "runConfigurations", stateSplitter = OldProjectRunConfigurationStateSplitter::class))) -private class ProjectRunConfigurationManager(manager: RunManager) : PersistentStateComponent { - private val manager = manager as RunManagerImpl - - override fun getState(): Element? { - val state = Element("state") - manager.writeConfigurations(state, manager.getSharedConfigurations()) - return state - } - - override fun loadState(state: Element) { - val existing = THashSet() - state.getChildren(RunManagerImpl.CONFIGURATION).mapTo(existing) { - manager.loadConfiguration(it, true).uniqueID - } - - manager.removeNotExistingSharedConfigurations(existing) - manager.requestSort() - - if (manager.selectedConfiguration == null) { - for (settings in manager.allSettings) { - if (settings.type !is UnknownRunConfiguration) { - manager.selectedConfiguration = settings - break - } - } - } - } -} - -internal class OldProjectRunConfigurationStateSplitter : StateSplitterEx() { - override fun splitState(state: Element): List> = StateSplitterEx.splitState(state, RunManagerImpl.NAME_ATTR) } \ No newline at end of file diff --git a/platform/lang-impl/src/com/intellij/execution/impl/RunManagerImpl.kt b/platform/lang-impl/src/com/intellij/execution/impl/RunManagerImpl.kt index 4073de02a644..223b7ac43566 100644 --- a/platform/lang-impl/src/com/intellij/execution/impl/RunManagerImpl.kt +++ b/platform/lang-impl/src/com/intellij/execution/impl/RunManagerImpl.kt @@ -129,7 +129,7 @@ open class RunManagerImpl(internal val project: Project) : RunManagerEx(), Persi private val workspaceSchemeManager = SchemeManagerFactory.getInstance(project).create("workspace", RunConfigurationSchemeManager(this, false), streamProvider = workspaceSchemeManagerProvider, autoSave = false) @Suppress("LeakingThis") - private var projectSchemeManager = if (isUseProjectSchemeManager()) SchemeManagerFactory.getInstance(project).create("runConfigurations", RunConfigurationSchemeManager(this, true), isUseOldFileNameSanitize = true) else null + private var projectSchemeManager = SchemeManagerFactory.getInstance(project).create("runConfigurations", RunConfigurationSchemeManager(this, true), isUseOldFileNameSanitize = true) private val isFirstLoadState = AtomicBoolean(true) @@ -282,7 +282,7 @@ open class RunManagerImpl(internal val project: Project) : RunManagerEx(), Persi refreshUsagesList(settings) } else { - (if (settings.isShared) workspaceSchemeManager else projectSchemeManager)?.removeScheme(settings as RunnerAndConfigurationSettingsImpl) + (if (settings.isShared) workspaceSchemeManager else projectSchemeManager).removeScheme(settings as RunnerAndConfigurationSettingsImpl) } // scheme level can be changed (workspace -> project), so, ensure that scheme is added to corresponding scheme manager (if exists, doesn't harm) @@ -357,7 +357,7 @@ open class RunManagerImpl(internal val project: Project) : RunManagerEx(), Persi } // comparator is null if want just to save current order (e.g. if want to keep order even after reload) - // yes, on hot reload, because our ProjectRunConfigurationManager doesn't use SchemeManager and change of some RC file leads to reload of all configurations + // yes, on hot reload, because our DeprecatedProjectRunConfigurationManager doesn't use SchemeManager and change of some RC file leads to reload of all configurations fun setOrder(comparator: Comparator?) { lock.write { val sorted = idToSettings.values.filterTo(ArrayList(idToSettings.size)) { it.type !is UnknownConfigurationType } @@ -610,7 +610,8 @@ open class RunManagerImpl(internal val project: Project) : RunManagerEx(), Persi override fun noStateLoaded() { isFirstLoadState.set(false) - projectSchemeManager?.loadSchemes() + projectSchemeManager.loadSchemes() + projectRunConfigurationFirstLoaded() } override fun loadState(parentNode: Element) { @@ -649,7 +650,7 @@ open class RunManagerImpl(internal val project: Project) : RunManagerEx(), Persi customOrder.ensureCapacity(order.size) order.mapIndexed { index, id -> customOrder.put(id, index) } - // ProjectRunConfigurationManager will not call requestSort if no shared configurations + // DeprecatedProjectRunConfigurationManager will not call requestSort if no shared configurations requestSort() recentlyUsedTemporaries.clear() @@ -670,7 +671,8 @@ open class RunManagerImpl(internal val project: Project) : RunManagerEx(), Persi } if (isFirstLoadState) { - projectSchemeManager?.loadSchemes() + projectSchemeManager.loadSchemes() + projectRunConfigurationFirstLoaded() } fireBeforeRunTasksUpdated() @@ -680,6 +682,13 @@ open class RunManagerImpl(internal val project: Project) : RunManagerEx(), Persi } } + private fun projectRunConfigurationFirstLoaded() { + requestSort() + if (selectedConfiguration == null) { + selectedConfiguration = allSettings.firstOrNull { it.type !is UnknownRunConfiguration } + } + } + fun readContext(parentNode: Element) { var selectedConfigurationId = parentNode.getAttributeValue(SELECTED_ATTR) @@ -828,19 +837,6 @@ open class RunManagerImpl(internal val project: Project) : RunManagerEx(), Persi } } - fun getSharedConfigurations(): List { - var result: MutableList? = null - for (configuration in allSettings) { - if (configuration.isShared) { - if (result == null) { - result = ArrayList() - } - result.add(configuration) - } - } - return result ?: emptyList() - } - override val tempConfigurationsList: List get() = allSettings.filterSmart { it.isTemporary } @@ -1099,28 +1095,6 @@ open class RunManagerImpl(internal val project: Project) : RunManagerEx(), Persi } } - fun removeNotExistingSharedConfigurations(existing: Set) { - var removed: MutableList? = null - lock.write { - val iterator = idToSettings.values.iterator() - for (settings in iterator) { - if (!settings.isTemplate && settings.isShared && !existing.contains(settings.uniqueID)) { - if (removed == null) { - immutableSortedSettingsList = null - removed = SmartList() - } - removed!!.add(settings) - iterator.remove() - } - } - } - - if (removed != null) { - val publisher = eventPublisher - removed?.forEach { publisher.runConfigurationRemoved(it) } - } - } - fun fireBeginUpdate() { eventPublisher.beginUpdate() } @@ -1198,6 +1172,4 @@ open class RunManagerImpl(internal val project: Project) : RunManagerEx(), Persi removed.forEach { eventPublisher.runConfigurationRemoved(it) } changedSettings.forEach { eventPublisher.runConfigurationChanged(it, null) } } -} - -internal fun isUseProjectSchemeManager() = Registry.`is`("runManager.use.schemeManager", false) \ No newline at end of file +} \ No newline at end of file diff --git a/platform/platform-resources/src/META-INF/PlatformExtensions.xml b/platform/platform-resources/src/META-INF/PlatformExtensions.xml index b1523ce0dd02..617bb0510692 100644 --- a/platform/platform-resources/src/META-INF/PlatformExtensions.xml +++ b/platform/platform-resources/src/META-INF/PlatformExtensions.xml @@ -353,7 +353,6 @@ serviceImplementation="com.intellij.ide.RemoteDesktopDetector"/> - diff --git a/platform/util/resources/misc/registry.properties b/platform/util/resources/misc/registry.properties index 08a05d18eb53..58f53f519c42 100644 --- a/platform/util/resources/misc/registry.properties +++ b/platform/util/resources/misc/registry.properties @@ -1203,8 +1203,6 @@ performance.watcher.sampling.interval.ms.description=If the product is unrespons JavaScript.Language.Service.truncate.traced.messages=true JavaScript.Language.Service.truncate.traced.messages.description=Truncate traced JavaScript language Service messages in log -runManager.use.schemeManager=true - vfs.use.nio-based.local.refresh.worker=false vfs.use.new.jar.handler=true