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
This commit is contained in:
Konstantin Nisht
2024-09-12 20:28:41 +02:00
committed by intellij-monorepo-bot
parent 7ae3831b12
commit 4fbc8c3e29
3 changed files with 40 additions and 15 deletions

View File

@@ -13,6 +13,7 @@ import com.intellij.openapi.Disposable
import com.intellij.openapi.actionSystem.*
import com.intellij.openapi.application.ReadAction
import com.intellij.openapi.diff.DefaultFlagsProvider
import com.intellij.openapi.diff.LineStatusMarkerColorScheme
import com.intellij.openapi.diff.LineStatusMarkerDrawUtil
import com.intellij.openapi.editor.Editor
import com.intellij.openapi.editor.EditorFactory
@@ -42,14 +43,16 @@ import java.awt.datatransfer.StringSelection
/**
* Draws and handles review changes markers in gutter
*/
class CodeReviewEditorGutterChangesRenderer(private val model: CodeReviewEditorGutterActionableChangesModel,
private val editor: Editor,
disposable: Disposable)
: LineStatusMarkerRendererWithPopup(editor.project, editor.document, model, disposable, { it === editor }) {
open class CodeReviewEditorGutterChangesRenderer(
private val model: CodeReviewEditorGutterActionableChangesModel,
private val editor: Editor,
disposable: Disposable,
val lineStatusMarkerColorScheme: LineStatusMarkerColorScheme = ReviewInEditorUtil.REVIEW_STATUS_MARKER_COLOR_SCHEME,
) : LineStatusMarkerRendererWithPopup(editor.project, editor.document, model, disposable, { it === editor }) {
override fun paintGutterMarkers(editor: Editor, ranges: List<Range>, g: Graphics) {
LineStatusMarkerDrawUtil.paintDefault(editor, g, ranges, DefaultFlagsProvider.DEFAULT,
ReviewInEditorUtil.REVIEW_STATUS_MARKER_COLOR_SCHEME, 0)
lineStatusMarkerColorScheme, 0)
}
override fun createErrorStripeTextAttributes(diffType: Byte): TextAttributes = ReviewChangesTextAttributes()
@@ -58,6 +61,7 @@ class CodeReviewEditorGutterChangesRenderer(private val model: CodeReviewEditorG
override fun getErrorStripeColor(): Color = ReviewInEditorUtil.REVIEW_CHANGES_STATUS_COLOR
}
override fun createPopupPanel(editor: Editor,
range: Range,
mousePosition: Point?,
@@ -73,18 +77,27 @@ class CodeReviewEditorGutterChangesRenderer(private val model: CodeReviewEditorG
null
}
val actions = mutableListOf<AnAction>(
ShowPrevChangeMarkerAction(range),
ShowNextChangeMarkerAction(range),
CopyLineStatusRangeAction(range),
ShowDiffAction(range),
ToggleByWordDiffAction()
val actions = listOfNotNull(
createRevertAction(range),
createPrevChangeAction(range),
createNextChangeAction(range),
createCopyLineAction(range),
createShowDiffAction(range),
createToggleByWordDiffAction()
)
val toolbar = LineStatusMarkerPopupPanel.buildToolbar(editor, actions, disposable)
return LineStatusMarkerPopupPanel.create(editor, toolbar, editorComponent, null)
}
protected open fun createRevertAction(range: Range): AnAction? = null
protected open fun createPrevChangeAction(range: Range): AnAction? = ShowPrevChangeMarkerAction(range)
protected open fun createNextChangeAction(range: Range): AnAction? = ShowNextChangeMarkerAction(range)
protected open fun createCopyLineAction(range: Range): AnAction? = CopyLineStatusRangeAction(range)
protected open fun createShowDiffAction(range: Range): AnAction? = ShowDiffAction(range)
protected open fun createToggleByWordDiffAction(): AnAction? = ToggleByWordDiffAction()
private fun createPopupEditor(project: Project?, mainEditor: Editor, vcsContent: String, disposable: Disposable): Editor {
val factory = EditorFactory.getInstance()
val editor = factory.createViewer(factory.createDocument(vcsContent), project, EditorKind.DIFF) as EditorEx
@@ -245,7 +258,7 @@ class CodeReviewEditorGutterChangesRenderer(private val model: CodeReviewEditorG
val disposable = Disposer.newDisposable("Editor code review changes renderer disposable")
editor.putUserData(CodeReviewEditorGutterActionableChangesModel.KEY, model)
try {
val renderer = CodeReviewEditorGutterChangesRenderer(model, editor, disposable)
val renderer = CodeReviewEditorGutterChangesRenderer(model, editor, disposable, ReviewInEditorUtil.REVIEW_STATUS_MARKER_COLOR_SCHEME)
model.reviewRanges.collect {
renderer.scheduleUpdate()
}

View File

@@ -1,4 +1,4 @@
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
// 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.openapi.vcs.ex
import com.intellij.diff.util.DiffDrawUtil
@@ -39,11 +39,16 @@ abstract class LineStatusMarkerRenderer internal constructor(
private val updateQueue = MergingUpdateQueue("LineStatusMarkerRenderer", 100, true, MergingUpdateQueue.ANY_COMPONENT, disposable)
private var disposed = false
private val gutterLayer = getGutterLayer()
private var gutterHighlighter: RangeHighlighter = createGutterHighlighter()
private val errorStripeHighlighters: MutableList<RangeHighlighter> = ArrayList()
protected abstract fun getRanges(): List<Range>?
protected open fun getGutterLayer(): Int {
return DiffDrawUtil.LST_LINE_MARKER_LAYER
}
init {
Disposer.register(disposable, Disposable {
disposed = true
@@ -89,7 +94,7 @@ abstract class LineStatusMarkerRenderer internal constructor(
private fun createGutterHighlighter(): RangeHighlighter {
val markupModel = DocumentMarkupModel.forDocument(document, project, true) as MarkupModelEx
return markupModel.addRangeHighlighterAndChangeAttributes(null, 0, document.textLength,
DiffDrawUtil.LST_LINE_MARKER_LAYER,
gutterLayer,
HighlighterTargetArea.LINES_IN_RANGE,
false) { it: RangeHighlighterEx ->
it.setGreedyToLeft(true)
@@ -184,7 +189,7 @@ abstract class LineStatusMarkerRenderer internal constructor(
private fun createErrorStripeHighlighter(markupModel: MarkupModelEx, textRange: TextRange, diffType: Byte): RangeHighlighter {
return markupModel.addRangeHighlighterAndChangeAttributes(null, textRange.startOffset, textRange.endOffset,
DiffDrawUtil.LST_LINE_MARKER_LAYER,
gutterLayer,
HighlighterTargetArea.LINES_IN_RANGE,
false) { it: RangeHighlighterEx ->
it.setThinErrorStripeMark(true)

View File

@@ -15,6 +15,7 @@ import com.intellij.openapi.editor.markup.LineMarkerRenderer
import com.intellij.openapi.editor.markup.MarkupEditorFilter
import com.intellij.openapi.project.Project
import com.intellij.openapi.util.Disposer
import com.intellij.openapi.util.NlsContexts
import com.intellij.openapi.vcs.ex.LineStatusMarkerPopupPanel.showPopupAt
import java.awt.Graphics
import java.awt.Point
@@ -61,6 +62,8 @@ abstract class LineStatusMarkerRendererWithPopup(
showPopupAt(editor, popup, mousePosition, popupDisposable)
}
protected open fun getTooltipText(): @NlsContexts.Tooltip String? = null
protected abstract fun createPopupPanel(editor: Editor, range: Range, mousePosition: Point?, disposable: Disposable)
: LineStatusMarkerPopupPanel
@@ -102,6 +105,10 @@ abstract class LineStatusMarkerRendererWithPopup(
showHint(editor, range, e)
}
}
override fun getTooltipText(): @NlsContexts.Tooltip String? {
return (this@LineStatusMarkerRendererWithPopup).getTooltipText()
}
}
companion object {