@@ -4,6 +4,7 @@ import cc.unitmesh.devti.language.actions.DevInsRunFileAction
4
4
import cc.unitmesh.devti.language.ast.action.PatternActionFuncDef
5
5
import cc.unitmesh.devti.language.ast.action.PatternProcessor
6
6
import cc.unitmesh.devti.language.compiler.error.DEVINS_ERROR
7
+ import cc.unitmesh.devti.language.processor.shell.ShireShellCommandRunner
7
8
import cc.unitmesh.devti.language.provider.http.HttpHandler
8
9
import cc.unitmesh.devti.language.provider.http.HttpHandlerType
9
10
import cc.unitmesh.devti.language.psi.DevInFile
@@ -17,14 +18,12 @@ import com.intellij.psi.PsiFile
17
18
import com.intellij.psi.PsiManager
18
19
import com.intellij.sh.psi.ShFile
19
20
import com.intellij.sh.run.ShRunner
20
- import cc.unitmesh.devti.language.processor.shell.ShireShellCommandRunner
21
- import java.util.concurrent.CompletableFuture
22
21
23
22
24
23
object ThreadProcessor : PatternProcessor {
25
24
override val type: PatternActionFuncDef = PatternActionFuncDef .THREAD
26
25
27
- fun execute (
26
+ suspend fun execute (
28
27
myProject : Project , fileName : String , variablesName : Array <String >, variableTable : MutableMap <String , Any ?>,
29
28
): String {
30
29
val file = myProject.lookupFile(fileName) ? : return " File not found: $fileName "
@@ -46,6 +45,7 @@ object ThreadProcessor : PatternProcessor {
46
45
PsiManager .getInstance(myProject).findFile(file)
47
46
} ? : return " Failed to find PSI file for $fileName "
48
47
48
+ // console.print("Prepare for running ${configuration.name}...\n", ConsoleViewContentType.NORMAL_OUTPUT)
49
49
when (psiFile) {
50
50
is DevInFile -> {
51
51
return when (val output = variableTable[" output" ]) {
@@ -93,24 +93,11 @@ object ThreadProcessor : PatternProcessor {
93
93
}
94
94
}
95
95
96
- private fun executeShFile (psiFile : ShFile , myProject : Project , processVariables : Map <String , String >): String {
96
+ suspend fun executeShFile (psiFile : ShFile , myProject : Project , processVariables : Map <String , String >): String {
97
97
val virtualFile = psiFile.virtualFile
98
- val shRunner = ApplicationManager .getApplication().getService(ShRunner ::class .java)
99
- ? : return " $DEVINS_ERROR : Shell runner not found"
100
-
101
- val future = CompletableFuture <String >()
102
- ApplicationManager .getApplication().invokeLater {
103
- if (shRunner.isAvailable(myProject)) {
104
- try {
105
- val output = ShireShellCommandRunner .runShellCommand(virtualFile, myProject, processVariables)
106
- future.complete(output)
107
- } catch (t: Throwable ) {
108
- future.completeExceptionally(t)
109
- }
110
- }
111
- }
98
+ ApplicationManager .getApplication().getService(ShRunner ::class .java) ? : return " $DEVINS_ERROR : Shell runner not found"
112
99
113
- return future.get( )
100
+ return ShireShellCommandRunner .runShellCommand(virtualFile, myProject, processVariables )
114
101
}
115
102
116
103
private fun executeTask (
0 commit comments