feat: std.Progress support in debugging
This commit is contained in:
parent
2f8bc57fe1
commit
09ec2d79cc
5 changed files with 17 additions and 6 deletions
|
@ -23,6 +23,8 @@
|
||||||
package com.falsepattern.zigbrains.debugger.runner.base
|
package com.falsepattern.zigbrains.debugger.runner.base
|
||||||
|
|
||||||
import com.falsepattern.zigbrains.project.run.ZigProcessHandler
|
import com.falsepattern.zigbrains.project.run.ZigProcessHandler
|
||||||
|
import com.falsepattern.zigbrains.shared.ipc.IPCUtil
|
||||||
|
import com.falsepattern.zigbrains.shared.ipc.ipc
|
||||||
import com.intellij.execution.ExecutionException
|
import com.intellij.execution.ExecutionException
|
||||||
import com.intellij.execution.configurations.GeneralCommandLine
|
import com.intellij.execution.configurations.GeneralCommandLine
|
||||||
import com.intellij.execution.process.ProcessEvent
|
import com.intellij.execution.process.ProcessEvent
|
||||||
|
@ -30,6 +32,7 @@ import com.intellij.execution.process.ProcessHandler
|
||||||
import com.intellij.execution.process.ProcessListener
|
import com.intellij.execution.process.ProcessListener
|
||||||
import com.intellij.execution.ui.ConsoleView
|
import com.intellij.execution.ui.ConsoleView
|
||||||
import com.intellij.execution.ui.ConsoleViewContentType
|
import com.intellij.execution.ui.ConsoleViewContentType
|
||||||
|
import com.intellij.openapi.project.Project
|
||||||
import com.intellij.platform.util.progress.withProgressText
|
import com.intellij.platform.util.progress.withProgressText
|
||||||
import com.intellij.util.io.awaitExit
|
import com.intellij.util.io.awaitExit
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
|
@ -43,9 +46,14 @@ class PreLaunchProcessListener(val console: ConsoleView) : ProcessListener {
|
||||||
private set
|
private set
|
||||||
|
|
||||||
@Throws(ExecutionException::class)
|
@Throws(ExecutionException::class)
|
||||||
suspend fun executeCommandLineWithHook(commandLine: GeneralCommandLine): Boolean {
|
suspend fun executeCommandLineWithHook(project: Project, commandLine: GeneralCommandLine): Boolean {
|
||||||
return withProgressText(commandLine.commandLineString) {
|
return withProgressText(commandLine.commandLineString) {
|
||||||
val processHandler = ZigProcessHandler(commandLine)
|
val ipc = IPCUtil.wrapWithIPC(commandLine)
|
||||||
|
val cli = ipc?.cli ?: commandLine
|
||||||
|
val processHandler = ZigProcessHandler(cli)
|
||||||
|
if (ipc != null) {
|
||||||
|
project.ipc?.launchWatcher(ipc, processHandler.process)
|
||||||
|
}
|
||||||
this@PreLaunchProcessListener.processHandler = processHandler
|
this@PreLaunchProcessListener.processHandler = processHandler
|
||||||
hook(processHandler)
|
hook(processHandler)
|
||||||
processHandler.startNotify()
|
processHandler.startNotify()
|
||||||
|
|
|
@ -54,7 +54,7 @@ abstract class ZigDebugParametersEmitBinaryBase<ProfileState: ZigProfileState<*>
|
||||||
val exe = tmpDir.resolve("executable")
|
val exe = tmpDir.resolve("executable")
|
||||||
commandLine.addParameters("-femit-bin=${exe.absolutePathString()}")
|
commandLine.addParameters("-femit-bin=${exe.absolutePathString()}")
|
||||||
|
|
||||||
if (listener.executeCommandLineWithHook(commandLine))
|
if (listener.executeCommandLineWithHook(profileState.environment.project, commandLine))
|
||||||
throw ExecutionException(ZigDebugBundle.message("debug.base.compile.failed.generic"))
|
throw ExecutionException(ZigDebugBundle.message("debug.base.compile.failed.generic"))
|
||||||
|
|
||||||
return withContext(Dispatchers.IO) {
|
return withContext(Dispatchers.IO) {
|
||||||
|
|
|
@ -82,6 +82,7 @@ abstract class ZigDebugRunnerBase<ProfileState : ZigProfileState<*>> : ZigProgra
|
||||||
} catch (e: ExecutionException) {
|
} catch (e: ExecutionException) {
|
||||||
console.print("\n", ConsoleViewContentType.ERROR_OUTPUT)
|
console.print("\n", ConsoleViewContentType.ERROR_OUTPUT)
|
||||||
e.message?.let { listener.console.print(it, ConsoleViewContentType.SYSTEM_OUTPUT) }
|
e.message?.let { listener.console.print(it, ConsoleViewContentType.SYSTEM_OUTPUT) }
|
||||||
|
throw e;
|
||||||
}
|
}
|
||||||
if (listener.isBuildFailed) {
|
if (listener.isBuildFailed) {
|
||||||
val executionResult = DefaultExecutionResult(console, listener.processHandler)
|
val executionResult = DefaultExecutionResult(console, listener.processHandler)
|
||||||
|
|
|
@ -61,7 +61,7 @@ class ZigDebugParametersBuild(
|
||||||
withProgressText("Building zig project") {
|
withProgressText("Building zig project") {
|
||||||
withContext(Dispatchers.IO) {
|
withContext(Dispatchers.IO) {
|
||||||
val commandLine = profileState.getCommandLine(toolchain, true)
|
val commandLine = profileState.getCommandLine(toolchain, true)
|
||||||
if (listener.executeCommandLineWithHook(commandLine))
|
if (listener.executeCommandLineWithHook(profileState.environment.project, commandLine))
|
||||||
throw ExecutionException(ZigDebugBundle.message("debug.build.compile.failed.generic"))
|
throw ExecutionException(ZigDebugBundle.message("debug.build.compile.failed.generic"))
|
||||||
val cfg = profileState.configuration
|
val cfg = profileState.configuration
|
||||||
val workingDir = cfg.workingDirectory.path
|
val workingDir = cfg.workingDirectory.path
|
||||||
|
|
|
@ -85,8 +85,10 @@ exec.option.label.compiler-args=Extra compiler command line arguments
|
||||||
exec.option.label.exe-args=Output program command line arguments
|
exec.option.label.exe-args=Output program command line arguments
|
||||||
exec.option.label.build.steps=Build steps
|
exec.option.label.build.steps=Build steps
|
||||||
exec.option.label.build.args=Extra command line arguments
|
exec.option.label.build.args=Extra command line arguments
|
||||||
exec.option.label.build.exe-args-debug=Output program command line arguments (debug only)
|
exec.option.label.build.steps-debug=Debug Build steps
|
||||||
exec.option.label.build.exe-path-debug=Output executable created by the build (debug only, autodetect if empty)
|
exec.option.label.build.args-debug=Debug Extra command line arguments
|
||||||
|
exec.option.label.build.exe-args-debug=Debug output program command line arguments
|
||||||
|
exec.option.label.build.exe-path-debug=Debug output executable created by the build
|
||||||
exception.zig.empty-file-path=Empty file path
|
exception.zig.empty-file-path=Empty file path
|
||||||
exception.translate-command-line.unbalanced-quotes=Unbalanced quotes in {0}
|
exception.translate-command-line.unbalanced-quotes=Unbalanced quotes in {0}
|
||||||
exception.zig-profile-state.start-process.no-toolchain=Failed to get zig toolchain from project
|
exception.zig-profile-state.start-process.no-toolchain=Failed to get zig toolchain from project
|
||||||
|
|
Loading…
Add table
Reference in a new issue