Skip to content

Commit

Permalink
feat: init for sql ddl
Browse files Browse the repository at this point in the history
  • Loading branch information
phodal committed Jul 12, 2023
1 parent 6553535 commit 43970b1
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
@@ -1,5 +1,6 @@
package cc.unitmesh.devti.actions.chat

import cc.unitmesh.devti.gui.DevtiFlowToolWindowFactory
import cc.unitmesh.devti.prompting.JavaActionPrompting
import cc.unitmesh.devti.gui.chat.ChatBotActionType
import cc.unitmesh.devti.gui.chat.ChatCodingComponent
Expand All @@ -11,8 +12,12 @@ import com.intellij.openapi.wm.ToolWindowManager

abstract class ChatBaseAction : AnAction() {
override fun actionPerformed(event: AnActionEvent) {
executeAction(event)
}

open fun executeAction(event: AnActionEvent) {
val project = event.project
val toolWindowManager = ToolWindowManager.getInstance(project!!).getToolWindow("DevTiFlow")
val toolWindowManager = ToolWindowManager.getInstance(project!!).getToolWindow(DevtiFlowToolWindowFactory.id)
val contentManager = toolWindowManager?.contentManager

val caretModel = event.getData(CommonDataKeys.EDITOR)?.caretModel
Expand Down Expand Up @@ -41,7 +46,6 @@ abstract class ChatBaseAction : AnAction() {
JavaActionPrompting(chatCodingService.actionType, lang, selectedText, file, project),
getReplaceableAction(event)
)

}

open fun getReplaceableAction(event: AnActionEvent): ((response: String) -> Unit)? {
Expand Down
@@ -1,11 +1,20 @@
package cc.unitmesh.devti.actions.chat

import cc.unitmesh.devti.gui.chat.ChatBotActionType
import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.actionSystem.CommonDataKeys.PSI_FILE

class CreateDdlAction : ChatBaseAction() {
override fun getActionType(): ChatBotActionType {
return ChatBotActionType.CREATE_DDL
}

override fun actionPerformed(event: AnActionEvent) {
val fileType = event.getData(PSI_FILE)?.fileType?.name
if (fileType != "SQL") {
return
}

super.actionPerformed(event)
}
}
Expand Up @@ -12,6 +12,10 @@ import com.intellij.openapi.wm.ToolWindowFactory
import com.intellij.ui.content.ContentFactory

class DevtiFlowToolWindowFactory : ToolWindowFactory, DumbAware {
companion object {
val id = "DevTiFlow"
}

private val contentFactory = ApplicationManager.getApplication().getService(
ContentFactory::class.java
)
Expand Down

0 comments on commit 43970b1

Please sign in to comment.