@@ -5,36 +5,19 @@ import com.intellij.openapi.editor.EditorCustomElementRenderer
5
5
import com.intellij.openapi.editor.Inlay
6
6
import com.intellij.openapi.editor.markup.TextAttributes
7
7
import com.intellij.temporary.inlay.presentation.LLMTextInlayPainter
8
- import org.jetbrains.annotations.NonNls
9
8
import java.awt.Graphics
10
9
import java.awt.Rectangle
11
10
12
11
class LLMInlayRenderer (editor : Editor , lines : List <String ?>) : EditorCustomElementRenderer {
13
- private val lines: List <String >
14
- private val content: String
12
+ private val lines: List <String > = PresentationUtil .replaceLeadingTabs(lines, 4 )
13
+ private val content: String = lines.joinToString(" \n " )
14
+ private val textAttributes: TextAttributes = PresentationUtil .getTextAttributes(editor)
15
+ var inlay: Inlay <EditorCustomElementRenderer >? = null
16
+
15
17
private var cachedWidth = - 1
16
18
private var cachedHeight = - 1
17
19
18
- private val textAttributes: TextAttributes
19
- private var inlay: Inlay <EditorCustomElementRenderer >? = null
20
-
21
- init {
22
- this .lines = PresentationUtil .replaceLeadingTabs(lines, 4 )
23
- content = lines.joinToString(" \n " )
24
- textAttributes = PresentationUtil .getTextAttributes(editor)
25
- }
26
-
27
- fun getInlay (): Inlay <EditorCustomElementRenderer >? {
28
- return inlay
29
- }
30
-
31
- fun setInlay (inlay : Inlay <EditorCustomElementRenderer >) {
32
- this .inlay = inlay
33
- }
34
-
35
- override fun getContextMenuGroupId (inlay : Inlay <* >): @NonNls String {
36
- return " copilot.inlayContextMenu"
37
- }
20
+ override fun getContextMenuGroupId (inlay : Inlay <* >): String = " autodev.inlayContextMenu"
38
21
39
22
override fun calcHeightInPixels (inlay : Inlay <* >): Int {
40
23
return if (cachedHeight < 0 ) {
@@ -47,7 +30,7 @@ class LLMInlayRenderer(editor: Editor, lines: List<String?>) : EditorCustomEleme
47
30
override fun calcWidthInPixels (inlay : Inlay <* >): Int {
48
31
if (cachedWidth < 0 ) {
49
32
val width = LLMTextInlayPainter .calculateWidth(inlay.editor, content, lines)
50
- return Math .max( 1 , width).also { cachedWidth = it }
33
+ return 1 .coerceAtLeast( width).also { cachedWidth = it }
51
34
}
52
35
return cachedWidth
53
36
}
0 commit comments