From b055cd4e5cb3fc8b1bc9ca53f86eb7a5f0b3cd6e Mon Sep 17 00:00:00 2001 From: Anna Rakhmukova Date: Mon, 23 Jun 2025 18:39:38 +0200 Subject: [PATCH] [vcs-log] Extract VcsLogPanel.collectLogUiKeys method GitOrigin-RevId: b21dbd1ccacf8a4010c2247feb538d8a5e3c7ca3 --- .../com/intellij/vcs/log/ui/VcsLogPanel.kt | 48 ++++++++++++------- 1 file changed, 30 insertions(+), 18 deletions(-) diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/VcsLogPanel.kt b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/VcsLogPanel.kt index de61e7178de8..921552d4e47f 100644 --- a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/VcsLogPanel.kt +++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/VcsLogPanel.kt @@ -10,6 +10,7 @@ import com.intellij.ui.components.JBPanel import com.intellij.vcs.log.VcsLogDataKeys import com.intellij.vcs.log.impl.VcsLogManager import com.intellij.vcs.log.util.VcsLogUtil +import org.jetbrains.annotations.ApiStatus import java.awt.BorderLayout import javax.swing.JComponent @@ -45,25 +46,36 @@ class VcsLogPanel(private val manager: VcsLogManager, override val vcsLogUi: Vcs } override fun uiDataSnapshot(sink: DataSink) { - val hashes = vcsLogUi.getTable().selection.commits sink[VcsLogInternalDataKeys.LOG_MANAGER] = manager - sink[VcsLogDataKeys.VCS_LOG] = vcsLogUi.getVcsLog() - sink[VcsLogDataKeys.VCS_LOG_UI] = vcsLogUi - sink[VcsLogDataKeys.VCS_LOG_DATA_PROVIDER] = manager.dataManager - sink[VcsLogInternalDataKeys.LOG_DATA] = manager.dataManager - sink[VcsLogDataKeys.VCS_LOG_COMMIT_SELECTION] = vcsLogUi.getTable().selection - if (hashes.isNotEmpty()) { - sink[VcsDataKeys.VCS_REVISION_NUMBER] = VcsLogUtil.convertToRevisionNumber(hashes.first().hash) - } - if (hashes.isNotEmpty() && hashes.size <= VcsLogUtil.MAX_SELECTED_COMMITS) { - sink[PlatformDataKeys.SELECTED_ITEMS] = hashes.toTypedArray() - sink[VcsDataKeys.VCS_REVISION_NUMBERS] = hashes - .map { VcsLogUtil.convertToRevisionNumber(it.hash) } - .toTypedArray() - } - val metadata = vcsLogUi.getTable().selection.cachedMetadata - if (metadata.isNotEmpty() && metadata.size <= VcsLogUtil.MAX_SELECTED_COMMITS) { - sink[VcsDataKeys.VCS_COMMIT_SUBJECTS] = metadata.map { it.getSubject() }.toTypedArray() + collectLogUiKeys(sink, vcsLogUi) + } + + @ApiStatus.Internal + companion object { + fun collectLogUiKeys( + sink: DataSink, + vcsLogUi: VcsLogUiEx, + ) { + sink[VcsLogDataKeys.VCS_LOG_DATA_PROVIDER] = vcsLogUi.logData + sink[VcsLogInternalDataKeys.LOG_DATA] = vcsLogUi.logData + val selection = vcsLogUi.table.selection + val hashes = selection.commits + sink[VcsLogDataKeys.VCS_LOG] = vcsLogUi.vcsLog + sink[VcsLogDataKeys.VCS_LOG_UI] = vcsLogUi + sink[VcsLogDataKeys.VCS_LOG_COMMIT_SELECTION] = selection + if (hashes.isNotEmpty()) { + sink[VcsDataKeys.VCS_REVISION_NUMBER] = VcsLogUtil.convertToRevisionNumber(hashes.first().hash) + } + if (hashes.isNotEmpty() && hashes.size <= VcsLogUtil.MAX_SELECTED_COMMITS) { + sink[PlatformDataKeys.SELECTED_ITEMS] = hashes.toTypedArray() + sink[VcsDataKeys.VCS_REVISION_NUMBERS] = hashes + .map { VcsLogUtil.convertToRevisionNumber(it.hash) } + .toTypedArray() + } + val metadata = selection.cachedMetadata + if (metadata.isNotEmpty() && metadata.size <= VcsLogUtil.MAX_SELECTED_COMMITS) { + sink[VcsDataKeys.VCS_COMMIT_SUBJECTS] = metadata.map { it.getSubject() }.toTypedArray() + } } } } \ No newline at end of file