Skip to content

Commit b2932ee

Browse files
committed
refactor(renderer): remove unnecessary methods and dependencies
Removed unused methods and deprecated dependencies from LLMInlayRenderer and LLMInlayManagerImpl. Simplified condition check in LLMInlayManagerImpl to use type check directly instead of class name string matching. Replaced StringUtils usage with Kotlin standard library function.
1 parent 86d0840 commit b2932ee

File tree

2 files changed

+4
-28
lines changed

2 files changed

+4
-28
lines changed

src/main/kotlin/com/intellij/temporary/inlay/codecomplete/LLMInlayManagerImpl.kt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import cc.unitmesh.devti.util.parser.Code
66
import cc.unitmesh.devti.util.parser.PostCodeProcessor
77
import com.intellij.injected.editor.EditorWindow
88
import com.intellij.openapi.Disposable
9-
import com.intellij.openapi.application.ApplicationManager
109
import com.intellij.openapi.command.WriteCommandAction
1110
import com.intellij.openapi.diagnostic.logger
1211
import com.intellij.openapi.editor.Editor
@@ -15,7 +14,6 @@ import com.intellij.openapi.editor.Inlay
1514
import com.intellij.openapi.editor.ex.EditorEx
1615
import com.intellij.openapi.editor.impl.ImaginaryEditor
1716
import com.intellij.openapi.editor.impl.InlayModelImpl
18-
import com.intellij.openapi.fileEditor.FileDocumentSynchronizationVetoer
1917
import com.intellij.openapi.project.Project
2018
import com.intellij.openapi.util.Disposer
2119
import com.intellij.openapi.util.Key
@@ -136,9 +134,7 @@ class LLMInlayManagerImpl : LLMInlayManager {
136134
val inlays = collectInlays(editor, tabRange.startOffset, tabRange.endOffset)
137135
if (inlays.isEmpty()) return 0
138136

139-
val completionCount = inlays.count {
140-
it.getInlay()?.renderer?.javaClass?.name?.contains("LLMInlayRenderer") ?: false
141-
}
137+
val completionCount = inlays.count { it.getInlay()?.renderer is LLMInlayRenderer }
142138

143139
if (completionCount > 0) {
144140
logger.debug("Completion inlays found: $completionCount")

src/main/kotlin/com/intellij/temporary/inlay/codecomplete/presentation/LLMInlayRenderer.kt

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,38 +5,22 @@ import com.intellij.openapi.editor.EditorCustomElementRenderer
55
import com.intellij.openapi.editor.Inlay
66
import com.intellij.openapi.editor.markup.TextAttributes
77
import com.intellij.temporary.inlay.presentation.LLMTextInlayPainter
8-
import org.apache.commons.lang.StringUtils
98
import org.jetbrains.annotations.NonNls
109
import java.awt.Graphics
1110
import java.awt.Rectangle
1211

1312
class LLMInlayRenderer(editor: Editor, lines: List<String?>) : EditorCustomElementRenderer {
1413
private val lines: List<String>
1514
private val content: String
16-
fun setCachedWidth(cachedWidth: Int) {
17-
this.cachedWidth = cachedWidth
18-
}
15+
private var cachedWidth = -1
16+
private var cachedHeight = -1
1917

2018
private val textAttributes: TextAttributes
2119
private var inlay: Inlay<EditorCustomElementRenderer>? = null
22-
fun setCachedHeight(cachedHeight: Int) {
23-
this.cachedHeight = cachedHeight
24-
}
25-
26-
fun getLines(): List<String> {
27-
return lines
28-
}
29-
30-
fun getContent(): String {
31-
return content
32-
}
33-
34-
private var cachedWidth = -1
35-
private var cachedHeight = -1
3620

3721
init {
3822
this.lines = PresentationUtil.replaceLeadingTabs(lines, 4)
39-
content = StringUtils.join(lines, "\n")
23+
content = lines.joinToString("\n")
4024
textAttributes = PresentationUtil.getTextAttributes(editor)
4125
}
4226

@@ -48,10 +32,6 @@ class LLMInlayRenderer(editor: Editor, lines: List<String?>) : EditorCustomEleme
4832
this.inlay = inlay
4933
}
5034

51-
fun getContentLines(): List<String> {
52-
return lines
53-
}
54-
5535
override fun getContextMenuGroupId(inlay: Inlay<*>): @NonNls String {
5636
return "copilot.inlayContextMenu"
5737
}

0 commit comments

Comments
 (0)