From 0fb80efeeb13f16ce3d4e4a12e3b1d5c954b3d55 Mon Sep 17 00:00:00 2001 From: Andrew Charneski Date: Sun, 8 Dec 2024 15:05:40 -0500 Subject: [PATCH] fix --- .../simiacryptus/aicoder/actions/SelectionAction.kt | 2 +- .../simiacryptus/aicoder/actions/code/CustomEditAction.kt | 2 +- .../simiacryptus/aicoder/actions/code/DescribeAction.kt | 4 ++-- .../simiacryptus/aicoder/actions/legacy/CommentsAction.kt | 6 +----- .../aicoder/actions/legacy/RenameVariablesAction.kt | 8 +------- 5 files changed, 6 insertions(+), 16 deletions(-) diff --git a/src/main/kotlin/com/github/simiacryptus/aicoder/actions/SelectionAction.kt b/src/main/kotlin/com/github/simiacryptus/aicoder/actions/SelectionAction.kt index a16e662a..05bdf809 100644 --- a/src/main/kotlin/com/github/simiacryptus/aicoder/actions/SelectionAction.kt +++ b/src/main/kotlin/com/github/simiacryptus/aicoder/actions/SelectionAction.kt @@ -180,7 +180,7 @@ abstract class SelectionAction( ) open fun isLanguageSupported(computerLanguage: ComputerLanguage?): Boolean { - return LanguageUtils.isLanguageSupported(computerLanguage) + return true // LanguageUtils.isLanguageSupported(computerLanguage) } open fun defaultSelection(editorState: EditorState, offset: Int) = editorState.line diff --git a/src/main/kotlin/com/github/simiacryptus/aicoder/actions/code/CustomEditAction.kt b/src/main/kotlin/com/github/simiacryptus/aicoder/actions/code/CustomEditAction.kt index f2f44c02..8b54d03d 100644 --- a/src/main/kotlin/com/github/simiacryptus/aicoder/actions/code/CustomEditAction.kt +++ b/src/main/kotlin/com/github/simiacryptus/aicoder/actions/code/CustomEditAction.kt @@ -81,7 +81,7 @@ open class CustomEditAction : SelectionAction() { val result = proxy.editCode( state.selectedText ?: "", instruction, - state.language?.name ?: "text", + state.language?.name ?: state.editor?.virtualFile?.extension ?: "unknown", outputHumanLanguage ) result.code ?: state.selectedText ?: "" diff --git a/src/main/kotlin/com/github/simiacryptus/aicoder/actions/code/DescribeAction.kt b/src/main/kotlin/com/github/simiacryptus/aicoder/actions/code/DescribeAction.kt index 643bddf2..65af5dcf 100644 --- a/src/main/kotlin/com/github/simiacryptus/aicoder/actions/code/DescribeAction.kt +++ b/src/main/kotlin/com/github/simiacryptus/aicoder/actions/code/DescribeAction.kt @@ -71,14 +71,14 @@ class DescribeAction : SelectionAction() { override fun isEnabled(event: AnActionEvent): Boolean { if (!super.isEnabled(event)) return false val state = getState(event) - return state?.language != null && state.selectedText?.isNotBlank() == true + return state?.selectedText?.isNotBlank() == true } override fun processSelection(state: SelectionAction.SelectionState, config: String?): String { try { val description = proxy.describeCode( IndentedText.fromString(state.selectedText).textBlock.toString().trim(), - state.language?.name ?: "", + state.language?.name ?: state.editor?.virtualFile?.extension ?: "", AppSettingsState.instance.humanLanguage ).text ?: throw IllegalStateException("Failed to generate description") val wrapping = com.github.simiacryptus.aicoder.util.StringUtil.lineWrapping(description.trim(), 120) diff --git a/src/main/kotlin/com/github/simiacryptus/aicoder/actions/legacy/CommentsAction.kt b/src/main/kotlin/com/github/simiacryptus/aicoder/actions/legacy/CommentsAction.kt index 26f46c2d..78fd13d1 100644 --- a/src/main/kotlin/com/github/simiacryptus/aicoder/actions/legacy/CommentsAction.kt +++ b/src/main/kotlin/com/github/simiacryptus/aicoder/actions/legacy/CommentsAction.kt @@ -25,14 +25,10 @@ class CommentsAction : SelectionAction() { return "" } - override fun isLanguageSupported(computerLanguage: ComputerLanguage?): Boolean { - return LanguageUtils.isLanguageSupported(computerLanguage) - } - override fun processSelection(state: SelectionState, config: String?): String { try { val selectedText = state.selectedText ?: return "" - val language = state.language?.toString() ?: return selectedText + val language = state.language?.toString() ?: state.editor?.virtualFile?.extension ?: return selectedText return ChatProxy( clazz = CommentsAction_VirtualAPI::class.java, api = api, diff --git a/src/main/kotlin/com/github/simiacryptus/aicoder/actions/legacy/RenameVariablesAction.kt b/src/main/kotlin/com/github/simiacryptus/aicoder/actions/legacy/RenameVariablesAction.kt index 078d7c2f..d61520d2 100644 --- a/src/main/kotlin/com/github/simiacryptus/aicoder/actions/legacy/RenameVariablesAction.kt +++ b/src/main/kotlin/com/github/simiacryptus/aicoder/actions/legacy/RenameVariablesAction.kt @@ -57,7 +57,6 @@ open class RenameVariablesAction : SelectionAction() { } @Throws(Exception::class) - override fun processSelection(event: AnActionEvent?, state: SelectionState, config: String?): String { try { val renameSuggestions = UITools.run(event?.project, "Analyzing Code", true, true) { progress -> @@ -65,7 +64,7 @@ open class RenameVariablesAction : SelectionAction() { proxy .suggestRenames( state.selectedText ?: "", - state.language?.name ?: "", + state.language?.name ?: state.editor?.virtualFile?.extension ?: "", AppSettingsState.instance.humanLanguage ) .suggestions @@ -93,11 +92,6 @@ open class RenameVariablesAction : SelectionAction() { } } - - override fun isLanguageSupported(computerLanguage: ComputerLanguage?): Boolean { - return LanguageUtils.isLanguageSupported(computerLanguage) - } - companion object { fun choose(renameSuggestions: Map): Set { return UITools.showCheckboxDialog(