diff --git a/exts/devin-lang/src/main/kotlin/cc/unitmesh/devti/language/actions/DevInRunFileAction.kt b/exts/devin-lang/src/main/kotlin/cc/unitmesh/devti/language/actions/DevInRunFileAction.kt new file mode 100644 index 0000000000..c78bed4201 --- /dev/null +++ b/exts/devin-lang/src/main/kotlin/cc/unitmesh/devti/language/actions/DevInRunFileAction.kt @@ -0,0 +1,37 @@ +package cc.unitmesh.devti.language.actions + +import cc.unitmesh.devti.AutoDevNotifications +import com.intellij.execution.actions.ConfigurationContext +import com.intellij.openapi.actionSystem.ActionUpdateThread +import com.intellij.openapi.actionSystem.AnActionEvent +import com.intellij.openapi.actionSystem.CommonDataKeys +import com.intellij.openapi.project.DumbAwareAction +import org.jetbrains.annotations.NonNls + +class DevInRunFileAction : DumbAwareAction() { + override fun getActionUpdateThread(): ActionUpdateThread = ActionUpdateThread.BGT + + override fun update(e: AnActionEvent) { + val file = e.getData(CommonDataKeys.PSI_FILE) ?: return + if (e.presentation.text.isNullOrBlank()) { + e.presentation.text = "Run DevIn file: ${file.name}" + } + } + + override fun actionPerformed(e: AnActionEvent) { + val file = + e.getData(CommonDataKeys.PSI_FILE) ?: return + val virtualFile = file.virtualFile ?: return + + + val project = file.project + val context = ConfigurationContext.getFromContext(e.dataContext, e.place) + + AutoDevNotifications.notify(project, "Run file action") + } + + companion object { + val ID: @NonNls String = "runDevInFileAction" + } + +} diff --git a/exts/devin-lang/src/main/kotlin/cc/unitmesh/devti/language/run/DevInRunLineMarkersProvider.kt b/exts/devin-lang/src/main/kotlin/cc/unitmesh/devti/language/run/DevInRunLineMarkersProvider.kt new file mode 100644 index 0000000000..d547139a91 --- /dev/null +++ b/exts/devin-lang/src/main/kotlin/cc/unitmesh/devti/language/run/DevInRunLineMarkersProvider.kt @@ -0,0 +1,25 @@ +package cc.unitmesh.devti.language.run + +import cc.unitmesh.devti.language.DevInLanguage +import cc.unitmesh.devti.language.actions.DevInRunFileAction +import cc.unitmesh.devti.language.psi.DevInFile +import com.intellij.execution.lineMarker.RunLineMarkerContributor +import com.intellij.icons.AllIcons +import com.intellij.openapi.actionSystem.ActionManager +import com.intellij.openapi.actionSystem.AnAction +import com.intellij.psi.PsiElement + +class DevInRunLineMarkersProvider : RunLineMarkerContributor() { + override fun getInfo(element: PsiElement): Info? { + if (element.language !is DevInLanguage || element.textRange.startOffset != 0) return null + + val psiFile = element.containingFile + if (psiFile !is DevInFile) return null + + val actions = arrayOf(ActionManager.getInstance().getAction(DevInRunFileAction.ID)) + + return Info( + AllIcons.RunConfigurations.TestState.Run, { "Run DevIn file: ${psiFile.name}" }, *actions + ) + } +} diff --git a/exts/devin-lang/src/main/resources/cc.unitmesh.devti.language.xml b/exts/devin-lang/src/main/resources/cc.unitmesh.devti.language.xml index 7095b22249..9abfba396a 100644 --- a/exts/devin-lang/src/main/resources/cc.unitmesh.devti.language.xml +++ b/exts/devin-lang/src/main/resources/cc.unitmesh.devti.language.xml @@ -8,7 +8,8 @@ - + @@ -28,7 +29,18 @@ - - + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/messages/AutoDevBundle.properties b/src/main/resources/messages/AutoDevBundle.properties index 568487a2c9..41a041b291 100644 --- a/src/main/resources/messages/AutoDevBundle.properties +++ b/src/main/resources/messages/AutoDevBundle.properties @@ -147,3 +147,4 @@ autoarkui.generate=Auto Generate ArkUI autoarkui.generate.clarify=Clarify Requirements autoarkui.generate.design=Design Page devin.ref.loading=Loading git revision +line.marker.run.0=Run {0}