From 62e6a2484aaac45975943d0e542bf440f66d36fc Mon Sep 17 00:00:00 2001 From: "Gregory.Shrago" Date: Fri, 2 Aug 2024 19:04:13 +0400 Subject: [PATCH] avoid "implement by delegation" with default java methods Default methods are never called due to KT-18324. Follow-up to [RDCT] Fix the run configuration popup not updating on start/stop of run configurations GitOrigin-RevId: 895673d621259a0e94d558b21ab4c1892e111d87 --- .../intellij/execution/ui/RunToolbarPopup.kt | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/platform/execution-impl/src/com/intellij/execution/ui/RunToolbarPopup.kt b/platform/execution-impl/src/com/intellij/execution/ui/RunToolbarPopup.kt index 59839fca0eb9..8e2e1733faaf 100644 --- a/platform/execution-impl/src/com/intellij/execution/ui/RunToolbarPopup.kt +++ b/platform/execution-impl/src/com/intellij/execution/ui/RunToolbarPopup.kt @@ -212,14 +212,12 @@ private fun createRunConfigurationActionGroup(folderMaps: Collection project.messageBus.syncPublisher(VOID_EXECUTION_TOPIC).run() } -) { - companion object { - @Topic.ProjectLevel - val VOID_EXECUTION_TOPIC = Topic("any execution event", Runnable::class.java) - } -} +@Topic.ProjectLevel +val VOID_EXECUTION_TOPIC = Topic("any execution event", Runnable::class.java) + +@ApiStatus.Internal +private class RunPopupVoidExecutionListener(project: Project) : MyExecutionListener( + { _, _, _ -> project.messageBus.syncPublisher(VOID_EXECUTION_TOPIC).run() }) internal class RunConfigurationsActionGroupPopup(actionGroup: ActionGroup, dataContext: DataContext, @@ -254,7 +252,7 @@ internal class RunConfigurationsActionGroupPopup(actionGroup: ActionGroup, } listModel.syncModel() - project.messageBus.connect(this).subscribe(RunPopupVoidExecutionListener.VOID_EXECUTION_TOPIC, Runnable { + project.messageBus.connect(this).subscribe(VOID_EXECUTION_TOPIC, Runnable { ApplicationManager.getApplication().invokeLater { if (list.isShowing) { (myStep as ActionPopupStep).updateStepItems(list) @@ -741,16 +739,18 @@ class RunConfigurationStartHistory(private val project: Project) : PersistentSta private class ExecutionReasonableHistoryManager : ProjectActivity { override suspend fun execute(project: Project) { - project.messageBus.simpleConnect().subscribe(ExecutionManager.EXECUTION_TOPIC, createExecutionListener { executorId, env, reason -> + project.messageBus.simpleConnect().subscribe(ExecutionManager.EXECUTION_TOPIC, MyExecutionListener { executorId, env, state -> getPersistedConfiguration(env.runnerAndConfigurationSettings)?.let { conf -> - RunStatusHistory.getInstance(env.project).changeState(conf, executorId, reason) + RunStatusHistory.getInstance(env.project).changeState(conf, executorId, state) } ActivityTracker.getInstance().inc() // needed to update run toolbar }) } } -private fun createExecutionListener(onAnyChange: (executorId: String, env: ExecutionEnvironment, reason: RunState) -> Unit) = object : ExecutionListener { +private open class MyExecutionListener( + val onAnyChange: (executorId: String, env: ExecutionEnvironment, reason: RunState) -> Unit +) : ExecutionListener { override fun processStartScheduled(executorId: String, env: ExecutionEnvironment) { onAnyChange(executorId, env, RunState.SCHEDULED) }