Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
acharneski committed Dec 8, 2024
1 parent 0d54984 commit 0fb80ef
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ abstract class SelectionAction<T : Any>(
)

open fun isLanguageSupported(computerLanguage: ComputerLanguage?): Boolean {
return LanguageUtils.isLanguageSupported(computerLanguage)
return true // LanguageUtils.isLanguageSupported(computerLanguage)
}

open fun defaultSelection(editorState: EditorState, offset: Int) = editorState.line
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ open class CustomEditAction : SelectionAction<String>() {
val result = proxy.editCode(
state.selectedText ?: "",
instruction,
state.language?.name ?: "text",
state.language?.name ?: state.editor?.virtualFile?.extension ?: "unknown",
outputHumanLanguage
)
result.code ?: state.selectedText ?: ""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,14 @@ class DescribeAction : SelectionAction<String>() {
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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,10 @@ class CommentsAction : SelectionAction<String>() {
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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,14 @@ open class RenameVariablesAction : SelectionAction<String>() {
}

@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 ->
progress.text = "Generating rename suggestions..."
proxy
.suggestRenames(
state.selectedText ?: "",
state.language?.name ?: "",
state.language?.name ?: state.editor?.virtualFile?.extension ?: "",
AppSettingsState.instance.humanLanguage
)
.suggestions
Expand Down Expand Up @@ -93,11 +92,6 @@ open class RenameVariablesAction : SelectionAction<String>() {
}
}


override fun isLanguageSupported(computerLanguage: ComputerLanguage?): Boolean {
return LanguageUtils.isLanguageSupported(computerLanguage)
}

companion object {
fun choose(renameSuggestions: Map<String, String>): Set<String> {
return UITools.showCheckboxDialog(
Expand Down

0 comments on commit 0fb80ef

Please sign in to comment.