From 4b0234fa7526a8a1515a36a03f8fb0d6034a2f28 Mon Sep 17 00:00:00 2001 From: Phodal Huang Date: Mon, 25 Nov 2024 21:34:54 +0800 Subject: [PATCH] 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. --- .../com/intellij/temporary/gui/block/EditorFragment.kt | 8 ++------ .../com/intellij/temporary/gui/block/SimpleMessage.kt | 2 +- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/core/src/main/kotlin/com/intellij/temporary/gui/block/EditorFragment.kt b/core/src/main/kotlin/com/intellij/temporary/gui/block/EditorFragment.kt index 390b935557..14e161b616 100644 --- a/core/src/main/kotlin/com/intellij/temporary/gui/block/EditorFragment.kt +++ b/core/src/main/kotlin/com/intellij/temporary/gui/block/EditorFragment.kt @@ -23,11 +23,8 @@ import javax.swing.Box import javax.swing.JComponent -class AIAssistantFoldLabel(side: ChatRole) : JBLabel("", 0) { - private val side: ChatRole - +class AIAssistantFoldLabel(private val side: ChatRole) : JBLabel("", 0) { init { - this.side = side setOpaque(true) isVisible = false } @@ -57,12 +54,11 @@ class EditorPadding(private val editor: Editor, pad: Int) : class EditorFragment(private val project: Project, private val editor: EditorEx, message: CompletableMessage) { private val editorLineThreshold = 6 - private val expandCollapseTextLabel: AIAssistantFoldLabel + private val expandCollapseTextLabel: AIAssistantFoldLabel = AIAssistantFoldLabel(message.getRole()) private val content: BorderLayoutPanel private var collapsed = false init { - expandCollapseTextLabel = AIAssistantFoldLabel(message.getRole()) content = object : BorderLayoutPanel() { override fun getPreferredSize(): Dimension { val preferredSize = super.getPreferredSize() diff --git a/core/src/main/kotlin/com/intellij/temporary/gui/block/SimpleMessage.kt b/core/src/main/kotlin/com/intellij/temporary/gui/block/SimpleMessage.kt index 5c6b0f7ecd..035e34165a 100644 --- a/core/src/main/kotlin/com/intellij/temporary/gui/block/SimpleMessage.kt +++ b/core/src/main/kotlin/com/intellij/temporary/gui/block/SimpleMessage.kt @@ -7,7 +7,7 @@ import cc.unitmesh.devti.gui.chat.message.ChatMessageRating class SimpleMessage( override val displayText: String, override val text: String, - val chatRole: ChatRole, + private val chatRole: ChatRole, override var rating: ChatMessageRating = ChatMessageRating.None ) : CompletableMessage { private val textListeners: MutableList = mutableListOf()