diff --git a/platform/collaboration-tools/api-dump-experimental.txt b/platform/collaboration-tools/api-dump-experimental.txt index f1580e2bd827..afd76e3e851c 100644 --- a/platform/collaboration-tools/api-dump-experimental.txt +++ b/platform/collaboration-tools/api-dump-experimental.txt @@ -522,13 +522,6 @@ f:com.intellij.collaboration.api.json.JsonHttpApiHelperKt - sf:INSTANCE:com.intellij.collaboration.ui.codereview.changes.CodeReviewChangeListComponentFactory - f:createIn(kotlinx.coroutines.CoroutineScope,com.intellij.collaboration.ui.codereview.details.model.CodeReviewChangeListViewModel,com.intellij.collaboration.ui.codereview.CodeReviewProgressTreeModel,java.lang.String):com.intellij.openapi.vcs.changes.ui.AsyncChangesTree - f:getSELECTED_CHANGES():com.intellij.openapi.actionSystem.DataKey -*f:com.intellij.collaboration.ui.codereview.changes.CodeReviewChangesTreeFactory -- *sf:Companion:com.intellij.collaboration.ui.codereview.changes.CodeReviewChangesTreeFactory$Companion -- (com.intellij.openapi.project.Project,com.intellij.collaboration.ui.SingleValueModel):V -- f:create(java.lang.String,Z):com.intellij.openapi.vcs.changes.ui.AsyncChangesTree -- bs:create$default(com.intellij.collaboration.ui.codereview.changes.CodeReviewChangesTreeFactory,java.lang.String,Z,I,java.lang.Object):com.intellij.openapi.vcs.changes.ui.AsyncChangesTree -*f:com.intellij.collaboration.ui.codereview.changes.CodeReviewChangesTreeFactory$Companion -- f:createTreeToolbar(com.intellij.openapi.actionSystem.ActionManager,java.lang.String,javax.swing.JComponent):javax.swing.JComponent *f:com.intellij.collaboration.ui.codereview.comment.CodeReviewCommentTextFieldFactory - sf:INSTANCE:com.intellij.collaboration.ui.codereview.comment.CodeReviewCommentTextFieldFactory - f:createIn(kotlinx.coroutines.CoroutineScope,com.intellij.collaboration.ui.codereview.comment.CodeReviewSubmittableTextViewModel,com.intellij.collaboration.ui.codereview.comment.CommentInputActionsComponentFactory$Config,com.intellij.collaboration.ui.codereview.timeline.comment.CommentTextFieldFactory$IconConfig):javax.swing.JComponent diff --git a/platform/collaboration-tools/src/com/intellij/collaboration/ui/codereview/changes/CodeReviewChangesTreeFactory.kt b/platform/collaboration-tools/src/com/intellij/collaboration/ui/codereview/changes/CodeReviewChangesTreeFactory.kt deleted file mode 100644 index 8b5ddc9a116d..000000000000 --- a/platform/collaboration-tools/src/com/intellij/collaboration/ui/codereview/changes/CodeReviewChangesTreeFactory.kt +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright 2000-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. -package com.intellij.collaboration.ui.codereview.changes - -import com.intellij.collaboration.ui.SingleValueModel -import com.intellij.openapi.actionSystem.ActionGroup -import com.intellij.openapi.actionSystem.ActionManager -import com.intellij.openapi.actionSystem.DataSink -import com.intellij.openapi.actionSystem.DefaultActionGroup -import com.intellij.openapi.actionSystem.IdeActions -import com.intellij.openapi.project.Project -import com.intellij.openapi.vcs.changes.Change -import com.intellij.openapi.vcs.changes.ui.* -import com.intellij.ui.ClientProperty -import com.intellij.ui.ExpandableItemsHandler -import com.intellij.ui.SelectionSaver -import com.intellij.util.ui.tree.TreeUtil -import org.jetbrains.annotations.ApiStatus.Obsolete -import org.jetbrains.annotations.Nls -import javax.swing.JComponent -import javax.swing.tree.DefaultTreeModel - -@Obsolete -class CodeReviewChangesTreeFactory(private val project: Project, - private val changesModel: SingleValueModel>) { - - fun create(emptyTextText: @Nls String, preselectFirstChange: Boolean = true): AsyncChangesTree { - val tree = object : AsyncChangesTree(project, false, false) { - override val changesTreeModel: AsyncChangesTreeModel = SimpleAsyncChangesTreeModel.create { grouping -> - TreeModelBuilder.buildFromChanges(project, grouping, changesModel.value, null) - } - - override fun updateTreeModel(model: DefaultTreeModel, treeStateStrategy: TreeStateStrategy<*>) { - super.updateTreeModel(model, treeStateStrategy) - - if (preselectFirstChange && isSelectionEmpty && !isEmpty) { - TreeUtil.selectFirstNode(this) - } - } - - override fun uiDataSnapshot(sink: DataSink) { - super.uiDataSnapshot(sink) - VcsTreeModelData.uiDataSnapshot(sink, project, this) - } - - override fun getToggleClickCount(): Int { - return toggleClickCount - } - - }.apply { - emptyText.text = emptyTextText - toggleClickCount = 2 - }.also { - ClientProperty.put(it, ExpandableItemsHandler.IGNORE_ITEM_SELECTION, true) - SelectionSaver.installOn(it) - } - changesModel.addAndInvokeListener { tree.rebuildTree() } - return tree - } - - companion object { - fun createTreeToolbar(actionManager: ActionManager, groupName: String, treeContainer: JComponent): JComponent { - val changesToolbarActionGroup = actionManager.getAction(groupName) as ActionGroup - val changesToolbar = actionManager.createActionToolbar("ChangesBrowser", changesToolbarActionGroup, true) - val treeActionsGroup = DefaultActionGroup(actionManager.getAction(IdeActions.ACTION_EXPAND_ALL), - actionManager.getAction(IdeActions.ACTION_COLLAPSE_ALL)) - return TreeActionsToolbarPanel(changesToolbar, treeActionsGroup, treeContainer) - } - } -} \ No newline at end of file diff --git a/platform/collaboration-tools/src/com/intellij/collaboration/ui/codereview/editor/DocumentTrackerCodeReviewEditorGutterChangesModel.kt b/platform/collaboration-tools/src/com/intellij/collaboration/ui/codereview/editor/DocumentTrackerCodeReviewEditorGutterChangesModel.kt deleted file mode 100644 index 9143bea57b65..000000000000 --- a/platform/collaboration-tools/src/com/intellij/collaboration/ui/codereview/editor/DocumentTrackerCodeReviewEditorGutterChangesModel.kt +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. -package com.intellij.collaboration.ui.codereview.editor - -import com.intellij.collaboration.async.collectScoped -import com.intellij.collaboration.async.launchNow -import com.intellij.collaboration.util.ExcludingApproximateChangedRangesShifter -import com.intellij.diff.util.Range -import com.intellij.openapi.application.EDT -import com.intellij.openapi.application.EdtImmediate -import com.intellij.openapi.editor.Document -import com.intellij.openapi.vcs.ex.DocumentTracker -import com.intellij.openapi.vcs.ex.LineStatusTrackerBase -import com.intellij.openapi.vcs.ex.LstRange -import com.intellij.platform.util.coroutines.childScope -import kotlinx.coroutines.CoroutineScope -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.flow.* -import kotlinx.coroutines.isActive -import kotlinx.coroutines.withContext -import org.jetbrains.annotations.ApiStatus - -/** - * Changes model which uses [DocumentTracker] to track and shift changes between review head and current document state - */ -@ApiStatus.Internal -@ApiStatus.ScheduledForRemoval -@Deprecated("Please use com.intellij.collaboration.ui.codereview.editor.ReviewInEditorUtil.trackDocumentDiffSync") -class DocumentTrackerCodeReviewEditorGutterChangesModel( - parentCs: CoroutineScope, - private val document: Document, - reviewHeadContent: Flow, - reviewChangesRanges: Flow?> -) : CodeReviewEditorGutterChangesModel { - private val cs = parentCs.childScope(javaClass.name, Dispatchers.EDT) - - private val _reviewRanges = MutableStateFlow?>(null) - override val reviewRanges: StateFlow?> = _reviewRanges.asStateFlow() - - private val _postReviewRanges = MutableStateFlow?>(null) - - /** - * Ranges changed between review head and current document content - */ - val postReviewRanges: StateFlow?> = _postReviewRanges.asStateFlow() - - override fun isValid(): Boolean = cs.isActive && _reviewRanges.value != null - - init { - cs.launchNow { - combine(reviewHeadContent, reviewChangesRanges, ::Pair).collectScoped { (headContent, reviewRanges) -> - if (headContent != null && reviewRanges != null) { - trackChanges(headContent, reviewRanges) - } - } - } - } - - private suspend fun trackChanges(originalContent: CharSequence, reviewRanges: List) { - withContext(Dispatchers.EdtImmediate) { - val reviewHeadDocument = LineStatusTrackerBase.createVcsDocument(originalContent) - ReviewInEditorUtil.trackDocumentDiffSync(reviewHeadDocument, document) { trackerRanges -> - _postReviewRanges.value = trackerRanges - _reviewRanges.value = ExcludingApproximateChangedRangesShifter.shift(reviewRanges, trackerRanges).map(Range::asLst) - } - } - } -} \ No newline at end of file