generated from JetBrains/intellij-platform-plugin-template
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(terminal): add ShireTerminalAction for custom assistants
Add ShireTerminalAction class to enable custom assistants in ShireLang.
- Loading branch information
Showing
2 changed files
with
34 additions
and
0 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
shirelang/src/main/kotlin/com/phodal/shirelang/actions/terminal/ShireTerminalAction.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package com.phodal.shirelang.actions.terminal | ||
|
||
import com.intellij.openapi.actionSystem.ActionUpdateThread | ||
import com.intellij.openapi.actionSystem.AnActionEvent | ||
import com.intellij.openapi.project.DumbAwareAction | ||
import com.phodal.shirecore.config.ShireActionLocation | ||
import com.phodal.shirelang.actions.ShireRunFileAction | ||
import com.phodal.shirelang.actions.dynamic.DynamicShireActionService | ||
|
||
class ShireTerminalAction : DumbAwareAction() { | ||
override fun getActionUpdateThread() = ActionUpdateThread.EDT | ||
|
||
private fun shireActionConfigs() = | ||
DynamicShireActionService.getInstance().getAction(ShireActionLocation.TERMINAL_MENU) | ||
|
||
override fun update(e: AnActionEvent) { | ||
e.presentation.isVisible = shireActionConfigs().size == 1 | ||
e.presentation.isEnabled = shireActionConfigs().size == 1 | ||
} | ||
|
||
override fun actionPerformed(e: AnActionEvent) { | ||
val project = e.project ?: return | ||
|
||
val config = shireActionConfigs().first() | ||
ShireRunFileAction.executeShireFile(project, config, null) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters