From a21e674a8a3f312fc70ccf1e0601c8e618296bda Mon Sep 17 00:00:00 2001 From: "Ilia.Shulgin" Date: Thu, 9 Oct 2025 15:54:46 +0200 Subject: [PATCH] [vcs] IJPL-173924 Cleanup refresh methods in ChangesViewEx GitOrigin-RevId: 07f6b7d1f0bd2e6cf47b857287fc614d37d50dd5 --- platform/vcs-impl/api-dump.txt | 5 ++--- .../com/intellij/openapi/vcs/changes/ChangesViewEx.kt | 9 +-------- .../intellij/openapi/vcs/changes/ChangesViewManager.java | 2 +- .../intellij/openapi/vcs/changes/DummyChangesView.java | 2 +- .../diff/ShowDiffFromLocalChangesActionProvider.java | 2 +- .../com/intellij/vcs/commit/ChangeListViewCommitPanel.kt | 4 ++-- .../com/intellij/vcs/commit/ChangesViewCommitPanel.kt | 5 ++++- 7 files changed, 12 insertions(+), 17 deletions(-) diff --git a/platform/vcs-impl/api-dump.txt b/platform/vcs-impl/api-dump.txt index 2fe3abac6f04..069bb2303c25 100644 --- a/platform/vcs-impl/api-dump.txt +++ b/platform/vcs-impl/api-dump.txt @@ -775,9 +775,8 @@ com.intellij.openapi.vcs.changes.ChangesViewEx - com.intellij.openapi.vcs.changes.ChangesViewI - a:getCommitWorkflowHandler():com.intellij.vcs.commit.ChangesViewCommitWorkflowHandler - a:isAllowExcludeFromCommit():Z -- a:refresh(java.lang.Runnable):V -- refresh(kotlin.coroutines.Continuation):java.lang.Object - a:resetViewImmediatelyAndRefreshLater():V +- a:scheduleRefresh(java.lang.Runnable):V com.intellij.openapi.vcs.changes.ChangesViewI - a:scheduleRefresh():V - a:selectChanges(java.util.List):V @@ -798,9 +797,9 @@ c:com.intellij.openapi.vcs.changes.ChangesViewManager - s:getLocalChangesToolWindowName(com.intellij.openapi.project.Project):java.lang.String - isAllowExcludeFromCommit():Z - isDiffPreviewAvailable():Z -- refresh(java.lang.Runnable):V - resetViewImmediatelyAndRefreshLater():V - scheduleRefresh():V +- scheduleRefresh(java.lang.Runnable):V - selectChanges(java.util.List):V - selectFile(com.intellij.openapi.vfs.VirtualFile):V - setBusy(Z):V diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ChangesViewEx.kt b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ChangesViewEx.kt index 3d721723f979..6410919ffe2d 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ChangesViewEx.kt +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ChangesViewEx.kt @@ -4,7 +4,6 @@ package com.intellij.openapi.vcs.changes import com.intellij.util.concurrency.annotations.RequiresBackgroundThread import com.intellij.util.concurrency.annotations.RequiresEdt import com.intellij.vcs.commit.ChangesViewCommitWorkflowHandler -import kotlinx.coroutines.CompletableDeferred import org.jetbrains.annotations.CalledInAny interface ChangesViewEx : ChangesViewI { @@ -15,13 +14,7 @@ interface ChangesViewEx : ChangesViewI { fun resetViewImmediatelyAndRefreshLater() @CalledInAny - fun refresh(@RequiresBackgroundThread callback: Runnable?) - - suspend fun refresh() { - val deferred = CompletableDeferred() - refresh { deferred.complete(Unit) } - deferred.await() - } + fun scheduleRefresh(@RequiresBackgroundThread callback: Runnable) val isAllowExcludeFromCommit: Boolean diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ChangesViewManager.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ChangesViewManager.java index db3fae40ff70..0dbc571a5acc 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ChangesViewManager.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ChangesViewManager.java @@ -181,7 +181,7 @@ public class ChangesViewManager implements ChangesViewEx, Disposable { } @Override - public void refresh(@Nullable Runnable callback) { + public void scheduleRefresh(@NotNull Runnable callback) { if (myToolWindowPanel != null) { myToolWindowPanel.scheduleRefreshNow(callback); } diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/DummyChangesView.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/DummyChangesView.java index c4a2f1ab7df7..f1bc1734e2a7 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/DummyChangesView.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/DummyChangesView.java @@ -57,7 +57,7 @@ class DummyChangesView implements ChangesViewEx { } @Override - public void refresh(@Nullable Runnable callback) { + public void scheduleRefresh(@NotNull Runnable callback) { } @Override diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/actions/diff/ShowDiffFromLocalChangesActionProvider.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/actions/diff/ShowDiffFromLocalChangesActionProvider.java index 804671c92125..05bb1209f810 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/actions/diff/ShowDiffFromLocalChangesActionProvider.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/actions/diff/ShowDiffFromLocalChangesActionProvider.java @@ -98,7 +98,7 @@ public class ShowDiffFromLocalChangesActionProvider implements AnActionExtension // this trick is essential since we are under some conditions to refresh changes; // but we can only rely on callback after refresh ChangeListManager.getInstance(project).invokeAfterUpdate(true, () -> { - ChangesViewManager.getInstanceEx(project).refresh(() -> { + ChangesViewManager.getInstanceEx(project).scheduleRefresh(() -> { try { List actualChanges = loadFakeRevisions(project, changes); resultRef.complete(collectRequestProducers(project, actualChanges, unversioned, view)); diff --git a/platform/vcs-impl/src/com/intellij/vcs/commit/ChangeListViewCommitPanel.kt b/platform/vcs-impl/src/com/intellij/vcs/commit/ChangeListViewCommitPanel.kt index e63cd974ac8c..f41cc07cb1d7 100644 --- a/platform/vcs-impl/src/com/intellij/vcs/commit/ChangeListViewCommitPanel.kt +++ b/platform/vcs-impl/src/com/intellij/vcs/commit/ChangeListViewCommitPanel.kt @@ -63,7 +63,7 @@ abstract class ChangeListViewCommitPanel @ApiStatus.Internal constructor( } final override var editedCommit: EditedCommitPresentation? by observable(null) { _, _, newValue -> - ChangesViewManager.getInstanceEx(project).refresh { + ChangesViewManager.getInstanceEx(project).scheduleRefresh { application.invokeLater { newValue?.let { expand(it) } } } } @@ -110,7 +110,7 @@ abstract class ChangeListViewCommitPanel @ApiStatus.Internal constructor( private fun closeEditorPreviewIfEmpty() { val changesViewManager = ChangesViewManager.getInstance(project) as? ChangesViewManager ?: return - ChangesViewManager.getInstanceEx(project).refresh { + ChangesViewManager.getInstanceEx(project).scheduleRefresh { application.invokeLater { changesViewManager.closeEditorPreview(true) } diff --git a/platform/vcs-impl/src/com/intellij/vcs/commit/ChangesViewCommitPanel.kt b/platform/vcs-impl/src/com/intellij/vcs/commit/ChangesViewCommitPanel.kt index b54caa82711e..8b6e4e48360a 100644 --- a/platform/vcs-impl/src/com/intellij/vcs/commit/ChangesViewCommitPanel.kt +++ b/platform/vcs-impl/src/com/intellij/vcs/commit/ChangesViewCommitPanel.kt @@ -12,6 +12,7 @@ import com.intellij.openapi.vcs.changes.ui.ChangesViewContentManager.Companion.g import com.intellij.openapi.vcs.changes.ui.ChangesViewContentManagerListener import com.intellij.openapi.vcs.changes.ui.isCommitToolWindowShown import com.intellij.openapi.wm.ToolWindow +import kotlinx.coroutines.CompletableDeferred import org.jetbrains.annotations.ApiStatus class ChangesViewCommitPanel @ApiStatus.Internal constructor( @@ -68,7 +69,9 @@ class ChangesViewCommitPanel @ApiStatus.Internal constructor( private fun getVcsToolWindow(): ToolWindow? = getToolWindowFor(project, LOCAL_CHANGES) override suspend fun refreshChangesViewBeforeCommit() { - ChangesViewManager.getInstanceEx(project).refresh() + val deferred = CompletableDeferred() + ChangesViewManager.getInstanceEx(project).scheduleRefresh { deferred.complete(Unit) } + deferred.await() } }