mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-09 08:09:39 +07:00
[gh/collab] Lift navigable editor functionality into collab-tools
GitOrigin-RevId: 1c69841bbcd51ff31f86f9fc6ea895db4df4e2ad
This commit is contained in:
committed by
intellij-monorepo-bot
parent
13cc9223e1
commit
bdbc7fb8f6
@@ -1,6 +1,7 @@
|
||||
// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package org.jetbrains.plugins.github.pullrequest.comment.action
|
||||
|
||||
import com.intellij.collaboration.ui.codereview.editor.CodeReviewNavigableEditorViewModel
|
||||
import com.intellij.diff.tools.util.DiffDataKeys
|
||||
import com.intellij.openapi.actionSystem.ActionUpdateThread
|
||||
import com.intellij.openapi.actionSystem.AnAction
|
||||
@@ -15,9 +16,10 @@ internal class GHPRDiffReviewNextCommentAction : AnAction() {
|
||||
|
||||
val editor = e.getData(DiffDataKeys.CURRENT_EDITOR)
|
||||
|
||||
val editorModel = editor?.getUserData(GHPRReviewDiffEditorModel.KEY)
|
||||
val editorModel = editor?.getUserData(CodeReviewNavigableEditorViewModel.KEY)
|
||||
?: editor?.getUserData(GHPRReviewDiffEditorModel.KEY)
|
||||
e.presentation.isVisible = editorModel != null
|
||||
if (editorModel == null) return
|
||||
if (editor == null || editorModel == null) return
|
||||
|
||||
val focused = findFocusedThreadId(project)
|
||||
e.presentation.isEnabled = if (focused != null) {
|
||||
@@ -33,8 +35,9 @@ internal class GHPRDiffReviewNextCommentAction : AnAction() {
|
||||
val project = e.project ?: return
|
||||
|
||||
val editor = e.getData(DiffDataKeys.CURRENT_EDITOR)
|
||||
val editorModel = editor?.getUserData(GHPRReviewDiffEditorModel.KEY)
|
||||
if (editorModel == null) return
|
||||
val editorModel = editor?.getUserData(CodeReviewNavigableEditorViewModel.KEY)
|
||||
?: editor?.getUserData(GHPRReviewDiffEditorModel.KEY)
|
||||
if (editor == null || editorModel == null) return
|
||||
|
||||
val focused = findFocusedThreadId(project)
|
||||
if (focused != null) {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package org.jetbrains.plugins.github.pullrequest.comment.action
|
||||
|
||||
import com.intellij.collaboration.ui.codereview.editor.CodeReviewNavigableEditorViewModel
|
||||
import com.intellij.diff.tools.util.DiffDataKeys
|
||||
import com.intellij.openapi.actionSystem.ActionUpdateThread
|
||||
import com.intellij.openapi.actionSystem.AnAction
|
||||
@@ -15,9 +16,10 @@ internal class GHPRDiffReviewPreviousCommentAction : AnAction() {
|
||||
|
||||
val editor = e.getData(DiffDataKeys.CURRENT_EDITOR)
|
||||
|
||||
val editorModel = editor?.getUserData(GHPRReviewDiffEditorModel.KEY)
|
||||
val editorModel = editor?.getUserData(CodeReviewNavigableEditorViewModel.KEY)
|
||||
?: editor?.getUserData(GHPRReviewDiffEditorModel.KEY)
|
||||
e.presentation.isVisible = editorModel != null
|
||||
if (editorModel == null) return
|
||||
if (editor == null || editorModel == null) return
|
||||
|
||||
val focused = findFocusedThreadId(project)
|
||||
e.presentation.isEnabled = if (focused != null) {
|
||||
@@ -33,8 +35,9 @@ internal class GHPRDiffReviewPreviousCommentAction : AnAction() {
|
||||
val project = e.project ?: return
|
||||
|
||||
val editor = e.getData(DiffDataKeys.CURRENT_EDITOR)
|
||||
val editorModel = editor?.getUserData(GHPRReviewDiffEditorModel.KEY)
|
||||
if (editorModel == null) return
|
||||
val editorModel = editor?.getUserData(CodeReviewNavigableEditorViewModel.KEY)
|
||||
?: editor?.getUserData(GHPRReviewDiffEditorModel.KEY)
|
||||
if (editor == null || editorModel == null) return
|
||||
|
||||
val focused = findFocusedThreadId(project)
|
||||
if (focused != null) {
|
||||
|
||||
@@ -7,6 +7,7 @@ import com.intellij.collaboration.ui.codereview.diff.viewer.showCodeReview
|
||||
import com.intellij.collaboration.ui.codereview.editor.CodeReviewCommentableEditorModel
|
||||
import com.intellij.collaboration.ui.codereview.editor.CodeReviewEditorGutterControlsModel
|
||||
import com.intellij.collaboration.ui.codereview.editor.CodeReviewEditorModel
|
||||
import com.intellij.collaboration.ui.codereview.editor.CodeReviewNavigableEditorViewModel
|
||||
import com.intellij.collaboration.util.Hideable
|
||||
import com.intellij.collaboration.util.RefComparisonChange
|
||||
import com.intellij.collaboration.util.syncOrToggleAll
|
||||
@@ -87,29 +88,10 @@ internal class GHPRReviewDiffExtension : DiffExtension() {
|
||||
}
|
||||
|
||||
internal interface GHPRReviewDiffEditorModel : CodeReviewEditorModel<GHPREditorMappedComponentModel>,
|
||||
CodeReviewCommentableEditorModel.WithMultilineComments {
|
||||
@RequiresEdt
|
||||
fun canGotoNextComment(focused: String): Boolean
|
||||
@RequiresEdt
|
||||
fun canGotoNextComment(line: Int): Boolean
|
||||
|
||||
@RequiresEdt
|
||||
fun canGotoPreviousComment(focused: String): Boolean
|
||||
@RequiresEdt
|
||||
fun canGotoPreviousComment(line: Int): Boolean
|
||||
|
||||
@RequiresEdt
|
||||
fun gotoNextComment(focused: String)
|
||||
@RequiresEdt
|
||||
fun gotoNextComment(line: Int)
|
||||
|
||||
@RequiresEdt
|
||||
fun gotoPreviousComment(focused: String)
|
||||
@RequiresEdt
|
||||
fun gotoPreviousComment(line: Int)
|
||||
|
||||
CodeReviewCommentableEditorModel.WithMultilineComments,
|
||||
CodeReviewNavigableEditorViewModel {
|
||||
companion object {
|
||||
val KEY = Key.create<GHPRReviewDiffEditorModel>("org.jetbrains.plugins.github.pullrequest.ui.diff.GHPRDiffEditorModel")
|
||||
val KEY: Key<GHPRReviewDiffEditorModel> = Key.create("GitHub.PullRequest.Diff.Editor.Model")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -194,18 +176,18 @@ private class DiffEditorModel(
|
||||
}
|
||||
|
||||
@RequiresEdt
|
||||
override fun canGotoNextComment(focused: String): Boolean = reviewVm.nextComment(focused) != null
|
||||
override fun canGotoNextComment(focusedThreadId: String): Boolean = reviewVm.nextComment(focusedThreadId) != null
|
||||
@RequiresEdt
|
||||
override fun canGotoNextComment(line: Int): Boolean = reviewVm.nextComment(lineToUnified(line)) != null
|
||||
|
||||
@RequiresEdt
|
||||
override fun canGotoPreviousComment(focused: String): Boolean = reviewVm.previousComment(focused) != null
|
||||
override fun canGotoPreviousComment(focusedThreadId: String): Boolean = reviewVm.previousComment(focusedThreadId) != null
|
||||
@RequiresEdt
|
||||
override fun canGotoPreviousComment(line: Int): Boolean = reviewVm.previousComment(lineToUnified(line)) != null
|
||||
|
||||
@RequiresEdt
|
||||
override fun gotoNextComment(focused: String) {
|
||||
val commentId = reviewVm.nextComment(focused) ?: return
|
||||
override fun gotoNextComment(focusedThreadId: String) {
|
||||
val commentId = reviewVm.nextComment(focusedThreadId) ?: return
|
||||
reviewVm.showDiffAtComment(commentId)
|
||||
}
|
||||
|
||||
@@ -216,8 +198,8 @@ private class DiffEditorModel(
|
||||
}
|
||||
|
||||
@RequiresEdt
|
||||
override fun gotoPreviousComment(focused: String) {
|
||||
val commentId = reviewVm.previousComment(focused) ?: return
|
||||
override fun gotoPreviousComment(focusedThreadId: String) {
|
||||
val commentId = reviewVm.previousComment(focusedThreadId) ?: return
|
||||
reviewVm.showDiffAtComment(commentId)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user