Skip to content

Commit 4b0234f

Browse files
committed
refactor(gui): initialize AIAssistantFoldLabel and hide chatRole in SimpleMessage
Updated the `AIAssistantFoldLabel` class to use property initialization for the `side` parameter. This change removes the need for a separate init block for the variable. Additionally, the `chatRole` property in the `SimpleMessage` class has been made private to encapsulate the field. The commit adheres to the Conventional Commits specification, providing a clear and concise description of the changes made.
1 parent a8b11fa commit 4b0234f

File tree

2 files changed

+3
-7
lines changed

2 files changed

+3
-7
lines changed

core/src/main/kotlin/com/intellij/temporary/gui/block/EditorFragment.kt

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,8 @@ import javax.swing.Box
2323
import javax.swing.JComponent
2424

2525

26-
class AIAssistantFoldLabel(side: ChatRole) : JBLabel("", 0) {
27-
private val side: ChatRole
28-
26+
class AIAssistantFoldLabel(private val side: ChatRole) : JBLabel("", 0) {
2927
init {
30-
this.side = side
3128
setOpaque(true)
3229
isVisible = false
3330
}
@@ -57,12 +54,11 @@ class EditorPadding(private val editor: Editor, pad: Int) :
5754

5855
class EditorFragment(private val project: Project, private val editor: EditorEx, message: CompletableMessage) {
5956
private val editorLineThreshold = 6
60-
private val expandCollapseTextLabel: AIAssistantFoldLabel
57+
private val expandCollapseTextLabel: AIAssistantFoldLabel = AIAssistantFoldLabel(message.getRole())
6158
private val content: BorderLayoutPanel
6259
private var collapsed = false
6360

6461
init {
65-
expandCollapseTextLabel = AIAssistantFoldLabel(message.getRole())
6662
content = object : BorderLayoutPanel() {
6763
override fun getPreferredSize(): Dimension {
6864
val preferredSize = super.getPreferredSize()

core/src/main/kotlin/com/intellij/temporary/gui/block/SimpleMessage.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import cc.unitmesh.devti.gui.chat.message.ChatMessageRating
77
class SimpleMessage(
88
override val displayText: String,
99
override val text: String,
10-
val chatRole: ChatRole,
10+
private val chatRole: ChatRole,
1111
override var rating: ChatMessageRating = ChatMessageRating.None
1212
) : CompletableMessage {
1313
private val textListeners: MutableList<MessageBlockTextListener> = mutableListOf()

0 commit comments

Comments
 (0)