generated from JetBrains/intellij-platform-plugin-template
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(devin-lang): add DevInRunFileAction and related changes #101
This commit introduces a new action, `DevInRunFileAction`, which allows users to run a DevIn file directly from the IDE. It also includes modifications to the `cc.unitmesh.devti.language.xml` file to add the necessary configuration for the new action, as well as updates to the `AutoDevBundle.properties` file to include a new message for the run line marker. Additionally, a new file `DevInRunLineMarkersProvider.kt` is added to provide support for run line markers in DevIn files.
- Loading branch information
Showing
4 changed files
with
78 additions
and
3 deletions.
There are no files selected for viewing
37 changes: 37 additions & 0 deletions
37
exts/devin-lang/src/main/kotlin/cc/unitmesh/devti/language/actions/DevInRunFileAction.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,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" | ||
} | ||
|
||
} |
25 changes: 25 additions & 0 deletions
25
.../devin-lang/src/main/kotlin/cc/unitmesh/devti/language/run/DevInRunLineMarkersProvider.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,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<AnAction>(ActionManager.getInstance().getAction(DevInRunFileAction.ID)) | ||
|
||
return Info( | ||
AllIcons.RunConfigurations.TestState.Run, { "Run DevIn file: ${psiFile.name}" }, *actions | ||
) | ||
} | ||
} |
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
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