Skip to content

Commit 4fbc8c3

Browse files
knishtintellij-monorepo-bot
authored andcommitted
IJPL-161819 inline prompt code generation: show diff in the gutter after code generation
IJPL-162132: Clear progressbar only when a meaningful message arrives from LLM IJPL-161819 gutter animation IJPL-161819 hide bulb on edt IJPL-161819 revert temporary code IJPL-161819 properly dispose InlinePromptEditorFilter IJPL-161819 hide unsupported actions IJPL-162132: Do now show lightbulb after code generation IJPL-161819 add tooltip text for line marker gutter IJPL-161819 add revert action on gutter IJPL-161819 move AIInEditorDiffRendererOnGutter to better packages IJPL-161819 use proper diff color IJPL-161819 move AIInEditorDiffRendererOnGutter to inlinePromptDetector module also, add dependency on `intellij.platform.collaborationTools` IJPL-161819 fix retry inlay text IJPL-161819 add gutter markers to inline prompt IJPL-161819 do not show generation diff on undo by default cleanup rename object IJPL-161819 add `simplify` to prompt initiating words IJPL-161819 ignore warnings shown while inline prompt is shown IJPL-161819 ignore new errors in the current file when an inline prompt is shown IJPL-161819 show diff after generation Squashed commits: Do not show quickfixes when the user is in inline prompt add on generation diff fix esc on retry regenerate inlay prevent blinking (fast fix) add undo/redo FUS statistics move diff listener class hide diff on esc, add adv setting dead code hide diff before regeneration do not show modified lines in diff (show them as deleted/added for more clarity) better diff make diff better show diff on undo something something some ctrl+Z GitOrigin-RevId: 2141d2e0b83c2b089780e0df1be12d43e4fff834
1 parent 7ae3831 commit 4fbc8c3

File tree

3 files changed

+40
-15
lines changed

3 files changed

+40
-15
lines changed

platform/collaboration-tools/src/com/intellij/collaboration/ui/codereview/editor/CodeReviewEditorGutterChangesRenderer.kt

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import com.intellij.openapi.Disposable
1313
import com.intellij.openapi.actionSystem.*
1414
import com.intellij.openapi.application.ReadAction
1515
import com.intellij.openapi.diff.DefaultFlagsProvider
16+
import com.intellij.openapi.diff.LineStatusMarkerColorScheme
1617
import com.intellij.openapi.diff.LineStatusMarkerDrawUtil
1718
import com.intellij.openapi.editor.Editor
1819
import com.intellij.openapi.editor.EditorFactory
@@ -42,14 +43,16 @@ import java.awt.datatransfer.StringSelection
4243
/**
4344
* Draws and handles review changes markers in gutter
4445
*/
45-
class CodeReviewEditorGutterChangesRenderer(private val model: CodeReviewEditorGutterActionableChangesModel,
46-
private val editor: Editor,
47-
disposable: Disposable)
48-
: LineStatusMarkerRendererWithPopup(editor.project, editor.document, model, disposable, { it === editor }) {
46+
open class CodeReviewEditorGutterChangesRenderer(
47+
private val model: CodeReviewEditorGutterActionableChangesModel,
48+
private val editor: Editor,
49+
disposable: Disposable,
50+
val lineStatusMarkerColorScheme: LineStatusMarkerColorScheme = ReviewInEditorUtil.REVIEW_STATUS_MARKER_COLOR_SCHEME,
51+
) : LineStatusMarkerRendererWithPopup(editor.project, editor.document, model, disposable, { it === editor }) {
4952

5053
override fun paintGutterMarkers(editor: Editor, ranges: List<Range>, g: Graphics) {
5154
LineStatusMarkerDrawUtil.paintDefault(editor, g, ranges, DefaultFlagsProvider.DEFAULT,
52-
ReviewInEditorUtil.REVIEW_STATUS_MARKER_COLOR_SCHEME, 0)
55+
lineStatusMarkerColorScheme, 0)
5356
}
5457

5558
override fun createErrorStripeTextAttributes(diffType: Byte): TextAttributes = ReviewChangesTextAttributes()
@@ -58,6 +61,7 @@ class CodeReviewEditorGutterChangesRenderer(private val model: CodeReviewEditorG
5861
override fun getErrorStripeColor(): Color = ReviewInEditorUtil.REVIEW_CHANGES_STATUS_COLOR
5962
}
6063

64+
6165
override fun createPopupPanel(editor: Editor,
6266
range: Range,
6367
mousePosition: Point?,
@@ -73,18 +77,27 @@ class CodeReviewEditorGutterChangesRenderer(private val model: CodeReviewEditorG
7377
null
7478
}
7579

76-
val actions = mutableListOf<AnAction>(
77-
ShowPrevChangeMarkerAction(range),
78-
ShowNextChangeMarkerAction(range),
79-
CopyLineStatusRangeAction(range),
80-
ShowDiffAction(range),
81-
ToggleByWordDiffAction()
80+
81+
val actions = listOfNotNull(
82+
createRevertAction(range),
83+
createPrevChangeAction(range),
84+
createNextChangeAction(range),
85+
createCopyLineAction(range),
86+
createShowDiffAction(range),
87+
createToggleByWordDiffAction()
8288
)
8389

8490
val toolbar = LineStatusMarkerPopupPanel.buildToolbar(editor, actions, disposable)
8591
return LineStatusMarkerPopupPanel.create(editor, toolbar, editorComponent, null)
8692
}
8793

94+
protected open fun createRevertAction(range: Range): AnAction? = null
95+
protected open fun createPrevChangeAction(range: Range): AnAction? = ShowPrevChangeMarkerAction(range)
96+
protected open fun createNextChangeAction(range: Range): AnAction? = ShowNextChangeMarkerAction(range)
97+
protected open fun createCopyLineAction(range: Range): AnAction? = CopyLineStatusRangeAction(range)
98+
protected open fun createShowDiffAction(range: Range): AnAction? = ShowDiffAction(range)
99+
protected open fun createToggleByWordDiffAction(): AnAction? = ToggleByWordDiffAction()
100+
88101
private fun createPopupEditor(project: Project?, mainEditor: Editor, vcsContent: String, disposable: Disposable): Editor {
89102
val factory = EditorFactory.getInstance()
90103
val editor = factory.createViewer(factory.createDocument(vcsContent), project, EditorKind.DIFF) as EditorEx
@@ -245,7 +258,7 @@ class CodeReviewEditorGutterChangesRenderer(private val model: CodeReviewEditorG
245258
val disposable = Disposer.newDisposable("Editor code review changes renderer disposable")
246259
editor.putUserData(CodeReviewEditorGutterActionableChangesModel.KEY, model)
247260
try {
248-
val renderer = CodeReviewEditorGutterChangesRenderer(model, editor, disposable)
261+
val renderer = CodeReviewEditorGutterChangesRenderer(model, editor, disposable, ReviewInEditorUtil.REVIEW_STATUS_MARKER_COLOR_SCHEME)
249262
model.reviewRanges.collect {
250263
renderer.scheduleUpdate()
251264
}

platform/diff-impl/src/com/intellij/openapi/vcs/ex/LineStatusMarkerRenderer.kt

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
1+
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
22
package com.intellij.openapi.vcs.ex
33

44
import com.intellij.diff.util.DiffDrawUtil
@@ -39,11 +39,16 @@ abstract class LineStatusMarkerRenderer internal constructor(
3939
private val updateQueue = MergingUpdateQueue("LineStatusMarkerRenderer", 100, true, MergingUpdateQueue.ANY_COMPONENT, disposable)
4040
private var disposed = false
4141

42+
private val gutterLayer = getGutterLayer()
4243
private var gutterHighlighter: RangeHighlighter = createGutterHighlighter()
4344
private val errorStripeHighlighters: MutableList<RangeHighlighter> = ArrayList()
4445

4546
protected abstract fun getRanges(): List<Range>?
4647

48+
protected open fun getGutterLayer(): Int {
49+
return DiffDrawUtil.LST_LINE_MARKER_LAYER
50+
}
51+
4752
init {
4853
Disposer.register(disposable, Disposable {
4954
disposed = true
@@ -89,7 +94,7 @@ abstract class LineStatusMarkerRenderer internal constructor(
8994
private fun createGutterHighlighter(): RangeHighlighter {
9095
val markupModel = DocumentMarkupModel.forDocument(document, project, true) as MarkupModelEx
9196
return markupModel.addRangeHighlighterAndChangeAttributes(null, 0, document.textLength,
92-
DiffDrawUtil.LST_LINE_MARKER_LAYER,
97+
gutterLayer,
9398
HighlighterTargetArea.LINES_IN_RANGE,
9499
false) { it: RangeHighlighterEx ->
95100
it.setGreedyToLeft(true)
@@ -184,7 +189,7 @@ abstract class LineStatusMarkerRenderer internal constructor(
184189

185190
private fun createErrorStripeHighlighter(markupModel: MarkupModelEx, textRange: TextRange, diffType: Byte): RangeHighlighter {
186191
return markupModel.addRangeHighlighterAndChangeAttributes(null, textRange.startOffset, textRange.endOffset,
187-
DiffDrawUtil.LST_LINE_MARKER_LAYER,
192+
gutterLayer,
188193
HighlighterTargetArea.LINES_IN_RANGE,
189194
false) { it: RangeHighlighterEx ->
190195
it.setThinErrorStripeMark(true)

platform/diff-impl/src/com/intellij/openapi/vcs/ex/LineStatusMarkerRendererWithPopup.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import com.intellij.openapi.editor.markup.LineMarkerRenderer
1515
import com.intellij.openapi.editor.markup.MarkupEditorFilter
1616
import com.intellij.openapi.project.Project
1717
import com.intellij.openapi.util.Disposer
18+
import com.intellij.openapi.util.NlsContexts
1819
import com.intellij.openapi.vcs.ex.LineStatusMarkerPopupPanel.showPopupAt
1920
import java.awt.Graphics
2021
import java.awt.Point
@@ -61,6 +62,8 @@ abstract class LineStatusMarkerRendererWithPopup(
6162
showPopupAt(editor, popup, mousePosition, popupDisposable)
6263
}
6364

65+
protected open fun getTooltipText(): @NlsContexts.Tooltip String? = null
66+
6467
protected abstract fun createPopupPanel(editor: Editor, range: Range, mousePosition: Point?, disposable: Disposable)
6568
: LineStatusMarkerPopupPanel
6669

@@ -102,6 +105,10 @@ abstract class LineStatusMarkerRendererWithPopup(
102105
showHint(editor, range, e)
103106
}
104107
}
108+
109+
override fun getTooltipText(): @NlsContexts.Tooltip String? {
110+
return (this@LineStatusMarkerRendererWithPopup).getTooltipText()
111+
}
105112
}
106113

107114
companion object {

0 commit comments

Comments
 (0)