From 08fc7f38a14151d2b9d8444829d21065812758b7 Mon Sep 17 00:00:00 2001 From: Phodal Huang Date: Mon, 3 Feb 2025 13:06:58 +0800 Subject: [PATCH] feat(commands): add commandName property to all ShireCommand implementations Add a `commandName` property to the `ShireCommand` interface and implement it in all command classes. This property is used to identify the command type via the `BuiltinCommand` enum. --- .../compiler/execute/command/BrowseShireCommand.kt | 6 +++++- .../compiler/execute/command/CommitShireCommand.kt | 3 +++ .../compiler/execute/command/DatabaseShireCommand.kt | 2 ++ .../shirelang/compiler/execute/command/DirShireCommand.kt | 3 +++ .../compiler/execute/command/FileFuncShireCommand.kt | 3 +++ .../shirelang/compiler/execute/command/FileShireCommand.kt | 3 +++ .../shirelang/compiler/execute/command/GotoShireCommand.kt | 3 +++ .../compiler/execute/command/LocalSearchShireCommand.kt | 3 +++ .../shirelang/compiler/execute/command/OpenShireCommand.kt | 3 +++ .../shirelang/compiler/execute/command/PatchShireCommand.kt | 3 +++ .../shirelang/compiler/execute/command/PrintShireCommand.kt | 4 ++++ .../compiler/execute/command/RefactorShireCommand.kt | 3 +++ .../compiler/execute/command/RelatedSymbolInsCommand.kt | 3 +++ .../shirelang/compiler/execute/command/RevShireCommand.kt | 3 +++ .../compiler/execute/command/RipgrepSearchShireCommand.kt | 3 +++ .../shirelang/compiler/execute/command/RunShireCommand.kt | 3 +++ .../shirelang/compiler/execute/command/ShellShireCommand.kt | 3 +++ .../shirelang/compiler/execute/command/ShireCommand.kt | 4 ++++ .../compiler/execute/command/StructureShireCommand.kt | 6 ++++-- .../compiler/execute/command/SymbolShireCommand.kt | 3 +++ .../shirelang/compiler/execute/command/WriteShireCommand.kt | 3 +++ 21 files changed, 67 insertions(+), 3 deletions(-) diff --git a/shirelang/src/main/kotlin/com/phodal/shirelang/compiler/execute/command/BrowseShireCommand.kt b/shirelang/src/main/kotlin/com/phodal/shirelang/compiler/execute/command/BrowseShireCommand.kt index d96c27a8e..56b34fcea 100644 --- a/shirelang/src/main/kotlin/com/phodal/shirelang/compiler/execute/command/BrowseShireCommand.kt +++ b/shirelang/src/main/kotlin/com/phodal/shirelang/compiler/execute/command/BrowseShireCommand.kt @@ -3,8 +3,12 @@ package com.phodal.shirelang.compiler.execute.command import com.phodal.shirecore.agent.agenttool.browse.BrowseTool import com.intellij.openapi.application.runInEdt import com.intellij.openapi.project.Project +import com.phodal.shirelang.completion.dataprovider.BuiltinCommand + +class BrowseShireCommand(val myProject: Project, private val prop: String, +) : ShireCommand { + override val commandName = BuiltinCommand.BROWSE -class BrowseShireCommand(val myProject: Project, private val prop: String) : ShireCommand { override suspend fun doExecute(): String? { var body: String? = null runInEdt { diff --git a/shirelang/src/main/kotlin/com/phodal/shirelang/compiler/execute/command/CommitShireCommand.kt b/shirelang/src/main/kotlin/com/phodal/shirelang/compiler/execute/command/CommitShireCommand.kt index 51e07df43..6b71eb1c5 100644 --- a/shirelang/src/main/kotlin/com/phodal/shirelang/compiler/execute/command/CommitShireCommand.kt +++ b/shirelang/src/main/kotlin/com/phodal/shirelang/compiler/execute/command/CommitShireCommand.kt @@ -3,8 +3,11 @@ package com.phodal.shirelang.compiler.execute.command import com.intellij.openapi.project.Project import com.phodal.shirecore.provider.shire.RevisionProvider import com.phodal.shirecore.utils.markdown.CodeFence +import com.phodal.shirelang.completion.dataprovider.BuiltinCommand class CommitShireCommand(val myProject: Project, val commitMsg: String) : ShireCommand { + override val commandName = BuiltinCommand.COMMIT + override suspend fun doExecute(): String { RevisionProvider.provide()?.let { return it.commitCode(myProject, commitMsg) diff --git a/shirelang/src/main/kotlin/com/phodal/shirelang/compiler/execute/command/DatabaseShireCommand.kt b/shirelang/src/main/kotlin/com/phodal/shirelang/compiler/execute/command/DatabaseShireCommand.kt index bfeaf7262..6b7f4656e 100644 --- a/shirelang/src/main/kotlin/com/phodal/shirelang/compiler/execute/command/DatabaseShireCommand.kt +++ b/shirelang/src/main/kotlin/com/phodal/shirelang/compiler/execute/command/DatabaseShireCommand.kt @@ -3,9 +3,11 @@ package com.phodal.shirelang.compiler.execute.command import com.intellij.openapi.project.Project import com.phodal.shirecore.provider.function.ToolchainFunctionProvider import com.phodal.shirecore.utils.markdown.CodeFence +import com.phodal.shirelang.completion.dataprovider.BuiltinCommand class DatabaseShireCommand(val myProject: Project, private val prop: String, private val codeContent: String?) : ShireCommand { + override val commandName = BuiltinCommand.DATABASE override suspend fun doExecute(): String { val args = if (codeContent != null) { diff --git a/shirelang/src/main/kotlin/com/phodal/shirelang/compiler/execute/command/DirShireCommand.kt b/shirelang/src/main/kotlin/com/phodal/shirelang/compiler/execute/command/DirShireCommand.kt index 58601758e..2ab638303 100644 --- a/shirelang/src/main/kotlin/com/phodal/shirelang/compiler/execute/command/DirShireCommand.kt +++ b/shirelang/src/main/kotlin/com/phodal/shirelang/compiler/execute/command/DirShireCommand.kt @@ -6,6 +6,7 @@ import com.intellij.openapi.roots.ProjectFileIndex import com.intellij.psi.PsiDirectory import com.intellij.psi.PsiManager import com.phodal.shirecore.lookupFile +import com.phodal.shirelang.completion.dataprovider.BuiltinCommand /** * The `DirShireCommand` class is responsible for listing files and directories in a tree-like structure for a given directory path within a project. @@ -29,6 +30,8 @@ import com.phodal.shirecore.lookupFile * @param dir The path of the directory to list. */ class DirShireCommand(private val myProject: Project, private val dir: String) : ShireCommand { + override val commandName = BuiltinCommand.DIR + private val output = StringBuilder() override suspend fun doExecute(): String? { diff --git a/shirelang/src/main/kotlin/com/phodal/shirelang/compiler/execute/command/FileFuncShireCommand.kt b/shirelang/src/main/kotlin/com/phodal/shirelang/compiler/execute/command/FileFuncShireCommand.kt index b8fbf1b87..4b410b393 100644 --- a/shirelang/src/main/kotlin/com/phodal/shirelang/compiler/execute/command/FileFuncShireCommand.kt +++ b/shirelang/src/main/kotlin/com/phodal/shirelang/compiler/execute/command/FileFuncShireCommand.kt @@ -6,8 +6,11 @@ import com.intellij.openapi.roots.ProjectFileIndex import com.intellij.openapi.vfs.VirtualFile import com.phodal.shirelang.completion.dataprovider.FileFunc import com.phodal.shirecore.canBeAdded +import com.phodal.shirelang.completion.dataprovider.BuiltinCommand class FileFuncShireCommand(val myProject: Project, private val prop: String) : ShireCommand { + override val commandName = BuiltinCommand.FILE_FUNC + override suspend fun doExecute(): String { val (functionName, args) = parseRegex(prop) ?: return """$SHIRE_ERROR: file-func is not in the format @file-func:(, , ...) diff --git a/shirelang/src/main/kotlin/com/phodal/shirelang/compiler/execute/command/FileShireCommand.kt b/shirelang/src/main/kotlin/com/phodal/shirelang/compiler/execute/command/FileShireCommand.kt index 841e5b60e..61fe01eb7 100644 --- a/shirelang/src/main/kotlin/com/phodal/shirelang/compiler/execute/command/FileShireCommand.kt +++ b/shirelang/src/main/kotlin/com/phodal/shirelang/compiler/execute/command/FileShireCommand.kt @@ -8,6 +8,7 @@ import com.phodal.shirecore.ShirelangNotifications import com.phodal.shirecore.findFile import com.phodal.shirecore.lookupFile import com.phodal.shirelang.compiler.ast.LineInfo +import com.phodal.shirelang.completion.dataprovider.BuiltinCommand /** * FileAutoCommand is responsible for reading a file and returning its contents. @@ -17,6 +18,8 @@ import com.phodal.shirelang.compiler.ast.LineInfo * */ class FileShireCommand(private val myProject: Project, private val prop: String) : ShireCommand { + override val commandName = BuiltinCommand.FILE + override suspend fun doExecute(): String? { val range: LineInfo? = LineInfo.fromString(prop) diff --git a/shirelang/src/main/kotlin/com/phodal/shirelang/compiler/execute/command/GotoShireCommand.kt b/shirelang/src/main/kotlin/com/phodal/shirelang/compiler/execute/command/GotoShireCommand.kt index 11faf0cb9..a15df8d66 100644 --- a/shirelang/src/main/kotlin/com/phodal/shirelang/compiler/execute/command/GotoShireCommand.kt +++ b/shirelang/src/main/kotlin/com/phodal/shirelang/compiler/execute/command/GotoShireCommand.kt @@ -9,6 +9,7 @@ import com.phodal.shirecore.lookupFile import com.phodal.shirecore.provider.shire.ShireSymbolProvider import com.phodal.shirelang.compiler.ast.LineInfo import com.phodal.shirelang.compiler.parser.SHIRE_ERROR +import com.phodal.shirelang.completion.dataprovider.BuiltinCommand import com.phodal.shirelang.psi.ShireUsed /** @@ -23,6 +24,8 @@ import com.phodal.shirelang.psi.ShireUsed * and move the cursor to line 10, column 8. */ class GotoShireCommand(val myProject: Project, private val argument: String, val used: ShireUsed) : ShireCommand { + override val commandName = BuiltinCommand.GOTO + override suspend fun doExecute(): String { if (argument.contains(".")) { return gotoSymbol() diff --git a/shirelang/src/main/kotlin/com/phodal/shirelang/compiler/execute/command/LocalSearchShireCommand.kt b/shirelang/src/main/kotlin/com/phodal/shirelang/compiler/execute/command/LocalSearchShireCommand.kt index 269a2f882..2c3bcfce2 100644 --- a/shirelang/src/main/kotlin/com/phodal/shirelang/compiler/execute/command/LocalSearchShireCommand.kt +++ b/shirelang/src/main/kotlin/com/phodal/shirelang/compiler/execute/command/LocalSearchShireCommand.kt @@ -6,6 +6,7 @@ import com.intellij.openapi.roots.ProjectFileIndex import com.intellij.openapi.vfs.VirtualFile import com.phodal.shirecore.canBeAdded import com.phodal.shirecore.relativePath +import com.phodal.shirelang.completion.dataprovider.BuiltinCommand import kotlin.collections.component1 import kotlin.collections.component2 @@ -23,6 +24,8 @@ import kotlin.collections.component2 * */ class LocalSearchShireCommand(val myProject: Project, private val scope: String, val text: String?) : ShireCommand { + override val commandName = BuiltinCommand.LOCAL_SEARCH + private val MAX_LINE_SIZE = 180 private val OVERLAP = 4 diff --git a/shirelang/src/main/kotlin/com/phodal/shirelang/compiler/execute/command/OpenShireCommand.kt b/shirelang/src/main/kotlin/com/phodal/shirelang/compiler/execute/command/OpenShireCommand.kt index c8f267156..34a21b8be 100644 --- a/shirelang/src/main/kotlin/com/phodal/shirelang/compiler/execute/command/OpenShireCommand.kt +++ b/shirelang/src/main/kotlin/com/phodal/shirelang/compiler/execute/command/OpenShireCommand.kt @@ -4,8 +4,11 @@ import com.intellij.openapi.fileEditor.FileDocumentManager import com.intellij.openapi.fileEditor.FileEditorManager import com.intellij.openapi.project.Project import com.phodal.shirecore.lookupFile +import com.phodal.shirelang.completion.dataprovider.BuiltinCommand class OpenShireCommand(val myProject: Project, private val filename: String) : ShireCommand { + override val commandName = BuiltinCommand.OPEN + override suspend fun doExecute(): String? { FileDocumentManager.getInstance().saveAllDocuments() diff --git a/shirelang/src/main/kotlin/com/phodal/shirelang/compiler/execute/command/PatchShireCommand.kt b/shirelang/src/main/kotlin/com/phodal/shirelang/compiler/execute/command/PatchShireCommand.kt index 54272bcae..511a13044 100644 --- a/shirelang/src/main/kotlin/com/phodal/shirelang/compiler/execute/command/PatchShireCommand.kt +++ b/shirelang/src/main/kotlin/com/phodal/shirelang/compiler/execute/command/PatchShireCommand.kt @@ -10,9 +10,12 @@ import com.intellij.openapi.vcs.changes.patch.ApplyPatchDefaultExecutor import com.intellij.openapi.vcs.changes.patch.MatchPatchPaths import com.intellij.openapi.vfs.VirtualFile import com.intellij.util.containers.MultiMap +import com.phodal.shirelang.completion.dataprovider.BuiltinCommand class PatchShireCommand(val myProject: Project, private val prop: String, private val codeContent: String) : ShireCommand { + override val commandName = BuiltinCommand.PATCH + override suspend fun doExecute(): String { FileDocumentManager.getInstance().saveAllDocuments() diff --git a/shirelang/src/main/kotlin/com/phodal/shirelang/compiler/execute/command/PrintShireCommand.kt b/shirelang/src/main/kotlin/com/phodal/shirelang/compiler/execute/command/PrintShireCommand.kt index 9cc0f451d..b449fe136 100644 --- a/shirelang/src/main/kotlin/com/phodal/shirelang/compiler/execute/command/PrintShireCommand.kt +++ b/shirelang/src/main/kotlin/com/phodal/shirelang/compiler/execute/command/PrintShireCommand.kt @@ -1,6 +1,10 @@ package com.phodal.shirelang.compiler.execute.command +import com.phodal.shirelang.completion.dataprovider.BuiltinCommand + class PrintShireCommand(private val value: String) : ShireCommand { + override val commandName = BuiltinCommand.FILE_FUNC + override suspend fun doExecute(): String { return value } diff --git a/shirelang/src/main/kotlin/com/phodal/shirelang/compiler/execute/command/RefactorShireCommand.kt b/shirelang/src/main/kotlin/com/phodal/shirelang/compiler/execute/command/RefactorShireCommand.kt index 16f5640d6..57cf291c5 100644 --- a/shirelang/src/main/kotlin/com/phodal/shirelang/compiler/execute/command/RefactorShireCommand.kt +++ b/shirelang/src/main/kotlin/com/phodal/shirelang/compiler/execute/command/RefactorShireCommand.kt @@ -8,6 +8,7 @@ import com.intellij.psi.PsiFile import com.intellij.psi.PsiManager import com.phodal.shirelang.completion.dataprovider.BuiltinRefactorCommand import com.phodal.shirecore.provider.shire.RefactoringTool +import com.phodal.shirelang.completion.dataprovider.BuiltinCommand import com.phodal.shirelang.psi.ShireFile /** @@ -48,6 +49,8 @@ import com.phodal.shirelang.psi.ShireFile */ class RefactorShireCommand(val myProject: Project, private val argument: String, private val textSegment: String) : ShireCommand { + override val commandName = BuiltinCommand.REFACTOR + override suspend fun doExecute(): String? { var currentEditFile: PsiFile? = null val editor = FileEditorManager.getInstance(myProject).selectedTextEditor diff --git a/shirelang/src/main/kotlin/com/phodal/shirelang/compiler/execute/command/RelatedSymbolInsCommand.kt b/shirelang/src/main/kotlin/com/phodal/shirelang/compiler/execute/command/RelatedSymbolInsCommand.kt index d3cd0933e..830b0e07b 100644 --- a/shirelang/src/main/kotlin/com/phodal/shirelang/compiler/execute/command/RelatedSymbolInsCommand.kt +++ b/shirelang/src/main/kotlin/com/phodal/shirelang/compiler/execute/command/RelatedSymbolInsCommand.kt @@ -3,8 +3,11 @@ package com.phodal.shirelang.compiler.execute.command import com.intellij.openapi.project.Project import com.phodal.shirecore.provider.psi.RelatedClassesProvider import com.phodal.shirecore.provider.shire.ShireSymbolProvider +import com.phodal.shirelang.completion.dataprovider.BuiltinCommand class RelatedSymbolInsCommand(val myProject: Project, private val symbol: String) : ShireCommand { + override val commandName = BuiltinCommand.RELATED + override suspend fun doExecute(): String? { val elements = ShireSymbolProvider.all().map { it.resolveSymbol(myProject, symbol) diff --git a/shirelang/src/main/kotlin/com/phodal/shirelang/compiler/execute/command/RevShireCommand.kt b/shirelang/src/main/kotlin/com/phodal/shirelang/compiler/execute/command/RevShireCommand.kt index 0db6c9072..4213ef9a1 100644 --- a/shirelang/src/main/kotlin/com/phodal/shirelang/compiler/execute/command/RevShireCommand.kt +++ b/shirelang/src/main/kotlin/com/phodal/shirelang/compiler/execute/command/RevShireCommand.kt @@ -2,6 +2,7 @@ package com.phodal.shirelang.compiler.execute.command import com.intellij.openapi.project.Project import com.phodal.shirecore.provider.shire.RevisionProvider +import com.phodal.shirelang.completion.dataprovider.BuiltinCommand /** * RevAutoCommand is used to execute a command that retrieves the committed change list for a given revision using Git. @@ -11,6 +12,8 @@ import com.phodal.shirecore.provider.shire.RevisionProvider * */ class RevShireCommand(private val myProject: Project, private val revision: String) : ShireCommand { + override val commandName = BuiltinCommand.REV + override suspend fun doExecute(): String { return RevisionProvider.provide()?.let { val changes = it.fetchChanges(myProject, revision) diff --git a/shirelang/src/main/kotlin/com/phodal/shirelang/compiler/execute/command/RipgrepSearchShireCommand.kt b/shirelang/src/main/kotlin/com/phodal/shirelang/compiler/execute/command/RipgrepSearchShireCommand.kt index 431bbb45a..48efbcba0 100644 --- a/shirelang/src/main/kotlin/com/phodal/shirelang/compiler/execute/command/RipgrepSearchShireCommand.kt +++ b/shirelang/src/main/kotlin/com/phodal/shirelang/compiler/execute/command/RipgrepSearchShireCommand.kt @@ -2,10 +2,13 @@ package com.phodal.shirelang.compiler.execute.command import com.intellij.openapi.project.Project import com.phodal.shirelang.compiler.execute.command.search.RipgrepSearcher +import com.phodal.shirelang.completion.dataprovider.BuiltinCommand class RipgrepSearchShireCommand( val myProject: Project, private val scope: String, val text: String?, ) : ShireCommand { + override val commandName = BuiltinCommand.RIPGREP_SEARCH + override fun isApplicable(): Boolean { return RipgrepSearcher.findRipgrepBinary() != null } diff --git a/shirelang/src/main/kotlin/com/phodal/shirelang/compiler/execute/command/RunShireCommand.kt b/shirelang/src/main/kotlin/com/phodal/shirelang/compiler/execute/command/RunShireCommand.kt index 5ee3f10cc..4b7763424 100644 --- a/shirelang/src/main/kotlin/com/phodal/shirelang/compiler/execute/command/RunShireCommand.kt +++ b/shirelang/src/main/kotlin/com/phodal/shirelang/compiler/execute/command/RunShireCommand.kt @@ -7,6 +7,7 @@ import com.phodal.shirecore.lookupFile import com.phodal.shirecore.provider.TestingService import com.phodal.shirecore.provider.shire.ProjectRunService import com.phodal.shirelang.compiler.parser.SHIRE_ERROR +import com.phodal.shirelang.completion.dataprovider.BuiltinCommand /** * The `RunAutoCommand` class is responsible for executing an auto command on a given project. @@ -16,6 +17,8 @@ import com.phodal.shirelang.compiler.parser.SHIRE_ERROR * */ class RunShireCommand(val myProject: Project, private val argument: String) : ShireCommand { + override val commandName = BuiltinCommand.RUN + override suspend fun doExecute(): String { val task = ProjectRunService.all().mapNotNull { projectRun -> val hasTasks = projectRun.tasks(myProject).any { task -> task.contains(argument) } diff --git a/shirelang/src/main/kotlin/com/phodal/shirelang/compiler/execute/command/ShellShireCommand.kt b/shirelang/src/main/kotlin/com/phodal/shirelang/compiler/execute/command/ShellShireCommand.kt index fe8a811c6..3f0ab6c75 100644 --- a/shirelang/src/main/kotlin/com/phodal/shirelang/compiler/execute/command/ShellShireCommand.kt +++ b/shirelang/src/main/kotlin/com/phodal/shirelang/compiler/execute/command/ShellShireCommand.kt @@ -8,6 +8,7 @@ import com.intellij.psi.PsiManager import com.intellij.sh.psi.ShFile import com.intellij.sh.run.ShRunner import com.phodal.shirecore.lookupFile +import com.phodal.shirelang.completion.dataprovider.BuiltinCommand import com.phodal.shirelang.runner.ShellFileRunService /** @@ -20,6 +21,8 @@ import com.phodal.shirelang.runner.ShellFileRunService * @param argument The path to the file within the project whose content should be executed as a shell command. */ class ShellShireCommand(val myProject: Project, private val argument: String) : ShireCommand { + override val commandName = BuiltinCommand.SHELL + override suspend fun doExecute(): String { val virtualFile = myProject.lookupFile(argument.trim()) ?: return "$SHIRE_ERROR: File not found: $argument" val psiFile = PsiManager.getInstance(myProject).findFile(virtualFile) as? ShFile diff --git a/shirelang/src/main/kotlin/com/phodal/shirelang/compiler/execute/command/ShireCommand.kt b/shirelang/src/main/kotlin/com/phodal/shirelang/compiler/execute/command/ShireCommand.kt index da74cdbca..77d0ba4eb 100644 --- a/shirelang/src/main/kotlin/com/phodal/shirelang/compiler/execute/command/ShireCommand.kt +++ b/shirelang/src/main/kotlin/com/phodal/shirelang/compiler/execute/command/ShireCommand.kt @@ -1,6 +1,10 @@ package com.phodal.shirelang.compiler.execute.command +import com.phodal.shirelang.completion.dataprovider.BuiltinCommand + interface ShireCommand { + val commandName: BuiltinCommand + fun isApplicable(): Boolean { return true } diff --git a/shirelang/src/main/kotlin/com/phodal/shirelang/compiler/execute/command/StructureShireCommand.kt b/shirelang/src/main/kotlin/com/phodal/shirelang/compiler/execute/command/StructureShireCommand.kt index 3602999d2..3cd5c4492 100644 --- a/shirelang/src/main/kotlin/com/phodal/shirelang/compiler/execute/command/StructureShireCommand.kt +++ b/shirelang/src/main/kotlin/com/phodal/shirelang/compiler/execute/command/StructureShireCommand.kt @@ -7,15 +7,17 @@ import com.intellij.openapi.project.Project import com.intellij.psi.PsiFile import com.intellij.psi.PsiManager import com.phodal.shirecore.provider.codemodel.FileStructureProvider +import com.phodal.shirelang.completion.dataprovider.BuiltinCommand import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.withContext class StructureShireCommand(val myProject: Project, val prop: String) : ShireCommand { - private val logger = logger() + override val commandName = BuiltinCommand.STRUCTURE + override suspend fun doExecute(): String? { val virtualFile = FileShireCommand.file(myProject, prop) if (virtualFile == null) { - logger.warn("File not found: $prop") + logger().warn("File not found: $prop") return null } diff --git a/shirelang/src/main/kotlin/com/phodal/shirelang/compiler/execute/command/SymbolShireCommand.kt b/shirelang/src/main/kotlin/com/phodal/shirelang/compiler/execute/command/SymbolShireCommand.kt index 80405dfba..3b2c14056 100644 --- a/shirelang/src/main/kotlin/com/phodal/shirelang/compiler/execute/command/SymbolShireCommand.kt +++ b/shirelang/src/main/kotlin/com/phodal/shirelang/compiler/execute/command/SymbolShireCommand.kt @@ -3,9 +3,12 @@ package com.phodal.shirelang.compiler.execute.command import com.phodal.shirelang.compiler.parser.SHIRE_ERROR import com.intellij.openapi.project.Project import com.phodal.shirecore.provider.shire.ShireSymbolProvider +import com.phodal.shirelang.completion.dataprovider.BuiltinCommand class SymbolShireCommand(val myProject: Project, private val prop: String) : ShireCommand { + override val commandName = BuiltinCommand.SYMBOL + override suspend fun doExecute(): String { val result = ShireSymbolProvider.all().mapNotNull { val found = it.resolveSymbol(myProject, prop) diff --git a/shirelang/src/main/kotlin/com/phodal/shirelang/compiler/execute/command/WriteShireCommand.kt b/shirelang/src/main/kotlin/com/phodal/shirelang/compiler/execute/command/WriteShireCommand.kt index 01039d420..ab3974444 100644 --- a/shirelang/src/main/kotlin/com/phodal/shirelang/compiler/execute/command/WriteShireCommand.kt +++ b/shirelang/src/main/kotlin/com/phodal/shirelang/compiler/execute/command/WriteShireCommand.kt @@ -16,9 +16,12 @@ import com.intellij.psi.PsiManager import com.phodal.shirecore.lookupFile import com.phodal.shirelang.psi.ShireUsed import com.phodal.shirecore.utils.markdown.CodeFence +import com.phodal.shirelang.completion.dataprovider.BuiltinCommand class WriteShireCommand(val myProject: Project, val argument: String, val content: String, private val used: ShireUsed) : ShireCommand { + override val commandName = BuiltinCommand.WRITE + private val pathSeparator = "/" override suspend fun doExecute(): String {