Skip to content

Commit ccc3c3d

Browse files
committed
refactor(gui): optimize code structure and remove unused components
- Remove unused data class FilePresentationWrapper - Delete unused functions and properties - Consolidate focusableComponent property - Clean up unnecessary imports
1 parent 1bb2822 commit ccc3c3d

File tree

1 file changed

+2
-22
lines changed

1 file changed

+2
-22
lines changed

core/src/main/kotlin/cc/unitmesh/devti/gui/chat/ui/AutoDevInputSection.kt

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,15 @@ package cc.unitmesh.devti.gui.chat.ui
22

33
import cc.unitmesh.devti.AutoDevBundle
44
import cc.unitmesh.devti.AutoDevIcons
5-
import cc.unitmesh.devti.settings.customize.customizeSetting
65
import cc.unitmesh.devti.agent.custom.model.CustomAgentConfig
76
import cc.unitmesh.devti.agent.custom.model.CustomAgentState
87
import cc.unitmesh.devti.gui.chat.ui.viewmodel.FileListViewModel
98
import cc.unitmesh.devti.llms.tokenizer.Tokenizer
109
import cc.unitmesh.devti.llms.tokenizer.TokenizerFactory
1110
import cc.unitmesh.devti.provider.RelatedClassesProvider
1211
import cc.unitmesh.devti.settings.AutoDevSettingsState
13-
import cc.unitmesh.devti.util.isInProject
12+
import cc.unitmesh.devti.settings.customize.customizeSetting
1413
import com.intellij.codeInsight.lookup.LookupManagerListener
15-
import com.intellij.diff.editor.DiffVirtualFileBase
1614
import com.intellij.icons.AllIcons
1715
import com.intellij.ide.IdeTooltip
1816
import com.intellij.ide.IdeTooltipManager
@@ -60,8 +58,6 @@ import javax.swing.*
6058
import kotlin.math.max
6159
import kotlin.math.min
6260

63-
data class FilePresentationWrapper(val virtualFile: VirtualFile, var panel: JPanel? = null, var namePanel: JPanel? = null)
64-
6561
class AutoDevInputSection(private val project: Project, val disposable: Disposable?, showAgent: Boolean = true) :
6662
BorderLayoutPanel() {
6763
private val input: AutoDevInput
@@ -72,6 +68,7 @@ class AutoDevInputSection(private val project: Project, val disposable: Disposab
7268
private val stopButton: ActionButton
7369
private val buttonPanel = JPanel(CardLayout())
7470
private val inputPanel = BorderLayoutPanel()
71+
val focusableComponent: JComponent get() = input
7572

7673
private val fileListViewModel = FileListViewModel(project)
7774
private val elementsList = JBList(fileListViewModel.getListModel())
@@ -397,23 +394,6 @@ class AutoDevInputSection(private val project: Project, val disposable: Disposab
397394
val contentManager = decorator?.contentManager ?: return JBUI.scale(200)
398395
return contentManager.component.height / 2
399396
}
400-
401-
val focusableComponent: JComponent get() = input
402-
403-
fun DefaultListModel<FilePresentation>.addIfAbsent(vfile: VirtualFile, first: Boolean = false) {
404-
if (!vfile.isValid || vfile.fileType.isBinary) return
405-
if (!isInProject(vfile, project)) return
406-
if (vfile is DiffVirtualFileBase) return
407-
408-
if (elements().asSequence().none { it.virtualFile == vfile }) {
409-
val filePresentation = FilePresentation(vfile)
410-
if (first) {
411-
insertElementAt(filePresentation, 0)
412-
} else {
413-
addElement(filePresentation)
414-
}
415-
}
416-
}
417397
}
418398

419399
private const val FONT_KEY = "FontFunction"

0 commit comments

Comments
 (0)