Skip to content

Commit 8a641b1

Browse files
committed
refactor(devin-runner): add RunContentManager to DevInsRunConfigurationProfileState #100
Import RunContentManager and use it to manage run content descriptors. Also, add executor and runner parameters to the run method for proper execution.
1 parent d354989 commit 8a641b1

File tree

2 files changed

+28
-11
lines changed

2 files changed

+28
-11
lines changed

exts/devins-lang/src/main/kotlin/cc/unitmesh/devti/language/compiler/exec/ShellInsCommand.kt

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,17 @@ package cc.unitmesh.devti.language.compiler.exec
33
import cc.unitmesh.devti.language.utils.lookupFile
44
import com.intellij.execution.DefaultExecutionResult
55
import com.intellij.execution.ExecutionException
6-
import com.intellij.execution.configurations.GeneralCommandLine
7-
import com.intellij.execution.configurations.PtyCommandLine
6+
import com.intellij.execution.configurations.*
87
import com.intellij.execution.process.KillableProcessHandler
98
import com.intellij.execution.process.ProcessHandler
109
import com.intellij.execution.process.ProcessTerminatedListener
10+
import com.intellij.execution.runners.ExecutionEnvironment
11+
import com.intellij.execution.runners.ProgramRunner
1112
import com.intellij.execution.ui.ConsoleView
13+
import com.intellij.execution.ui.RunContentDescriptor
14+
import com.intellij.execution.ui.RunContentManager
1215
import com.intellij.openapi.application.ApplicationManager
16+
import com.intellij.openapi.fileEditor.FileDocumentManager
1317
import com.intellij.openapi.project.Project
1418
import com.intellij.sh.run.ShConfigurationType
1519
import com.intellij.sh.run.ShRunner
@@ -28,7 +32,6 @@ class ShellInsCommand(val myProject: Project, val prop: String) : InsCommand {
2832
shRunner.run(myProject, virtualFile.path, workingDirectory, "RunDevInsShell", true)
2933
}
3034

31-
// TODO: after run done
3235
// runInTerminal(virtualFile.path, workingDirectory, myProject)
3336

3437
return ""
@@ -50,13 +53,14 @@ class ShellInsCommand(val myProject: Project, val prop: String) : InsCommand {
5053
command: String
5154
): GeneralCommandLine {
5255
val commandLine = PtyCommandLine()
53-
commandLine.withConsoleMode(false)
54-
commandLine.withInitialColumns(120)
55-
commandLine.withParentEnvironmentType(GeneralCommandLine.ParentEnvironmentType.CONSOLE)
56+
.withConsoleMode(false)
57+
.withInitialColumns(120)
58+
.withParentEnvironmentType(GeneralCommandLine.ParentEnvironmentType.CONSOLE)
59+
.withExePath(ShConfigurationType.getDefaultShell(project))
60+
.withParameters("-c")
61+
.withParameters(command)
62+
5663
commandLine.setWorkDirectory(workingDirectory)
57-
commandLine.withExePath(ShConfigurationType.getDefaultShell(project))
58-
commandLine.withParameters("-c")
59-
commandLine.withParameters(command)
6064
return commandLine
6165
}
6266

exts/devins-lang/src/main/kotlin/cc/unitmesh/devti/language/run/DevInsRunConfigurationProfileState.kt

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ import com.intellij.execution.process.ProcessHandler
1919
import com.intellij.execution.process.ProcessTerminatedListener
2020
import com.intellij.execution.runners.ProgramRunner
2121
import com.intellij.execution.ui.ConsoleViewContentType
22+
import com.intellij.execution.ui.RunContentDescriptor
23+
import com.intellij.execution.ui.RunContentManager
2224
import com.intellij.openapi.actionSystem.ActionManager
2325
import com.intellij.openapi.actionSystem.DefaultActionGroup
2426
import com.intellij.openapi.application.ApplicationManager
@@ -29,6 +31,7 @@ import com.intellij.ui.components.panels.NonOpaquePanel
2931
import kotlinx.coroutines.flow.*
3032
import kotlinx.coroutines.launch
3133
import kotlinx.coroutines.runBlocking
34+
import org.jetbrains.concurrency.resolvedPromise
3235
import java.awt.BorderLayout
3336
import java.io.OutputStream
3437
import javax.swing.JComponent
@@ -78,7 +81,7 @@ open class DevInsRunConfigurationProfileState(
7881
if (agent != null) {
7982
agentRun(output, console, processHandler, agent)
8083
} else {
81-
defaultRun(output, console, processHandler, compileResult.isLocalCommand)
84+
defaultRun(output, console, processHandler, compileResult.isLocalCommand, executor, runner)
8285
}
8386

8487
return DefaultExecutionResult(console, processHandler)
@@ -122,7 +125,9 @@ open class DevInsRunConfigurationProfileState(
122125
output: String,
123126
console: ConsoleViewWrapperBase,
124127
processHandler: ProcessHandler,
125-
isLocalMode: Boolean
128+
isLocalMode: Boolean,
129+
executor: Executor?,
130+
runner: ProgramRunner<*>
126131
) {
127132
// contains <DevInsError> means error
128133
output.split("\n").forEach {
@@ -153,6 +158,14 @@ open class DevInsRunConfigurationProfileState(
153158
console.print("\nDone!", ConsoleViewContentType.SYSTEM_OUTPUT)
154159
processHandler.detachProcess()
155160
}
161+
162+
// val manager = RunContentManager.getInstance(myProject)
163+
// val descriptor = manager.findContentDescriptor(executor, processHandler)
164+
// resolvedPromise(descriptor).then {
165+
// if (descriptor != null) {
166+
// println(descriptor)
167+
// }
168+
// }
156169
}
157170
}
158171

0 commit comments

Comments
 (0)