@@ -2,26 +2,30 @@ package com.github.xepozz.php_dump.services
22
33import com.intellij.execution.configurations.GeneralCommandLine
44import com.intellij.execution.process.KillableColoredProcessHandler
5+ import com.intellij.execution.process.ProcessAdapter
6+ import com.intellij.execution.process.ProcessEvent
7+ import com.intellij.execution.process.ProcessOutputTypes
58import com.intellij.execution.ui.ConsoleView
9+ import com.intellij.execution.ui.ConsoleViewContentType
610import com.intellij.openapi.Disposable
711import com.intellij.openapi.components.Service
812import com.intellij.openapi.project.Project
13+ import com.intellij.openapi.util.Key
914import com.intellij.ui.jcef.JBCefBrowser
1015import com.jetbrains.php.config.PhpProjectConfigurationFacade
1116import com.jetbrains.php.config.interpreters.PhpInterpretersManagerImpl
1217import kotlinx.coroutines.CoroutineScope
1318import kotlinx.coroutines.Dispatchers
1419import kotlinx.coroutines.launch
1520import kotlinx.coroutines.withContext
21+ import kotlin.math.log
1622
1723@Service(Service .Level .PROJECT )
1824class OpcodesDumperService (var project : Project ) : Disposable {
19- var browser: JBCefBrowser ? = null
2025 var consoleView: ConsoleView ? = null
2126
2227 override fun dispose () {
2328 consoleView?.dispose()
24- browser?.dispose()
2529 }
2630
2731 fun dump (file : String , callback : () -> Unit ) {
@@ -66,13 +70,19 @@ class OpcodesDumperService(var project: Project) : Disposable {
6670 val command = GeneralCommandLine (commandArgs)
6771 command.withRedirectErrorStream(false )
6872
69- val commandLine = command.commandLineString + " 1>/dev/null"
70- val processHandler = KillableColoredProcessHandler .Silent (command.createProcess(), commandLine, command.charset, emptySet())
73+ val processHandler = KillableColoredProcessHandler .Silent (command)
7174 processHandler.setShouldKillProcessSoftly(false )
7275 processHandler.setShouldDestroyProcessRecursively(true )
76+ processHandler.addProcessListener(object : ProcessAdapter () {
77+ override fun onTextAvailable (event : ProcessEvent , outputType : Key <* >) {
78+ if (outputType == ProcessOutputTypes .STDERR ) {
79+ consoleView?.print (event.text, ConsoleViewContentType .NORMAL_OUTPUT )
80+ }
81+ }
82+ })
7383
7484 consoleView?.clear()
75- consoleView?.attachToProcess(processHandler)
85+ // consoleView?.attachToProcess(processHandler)
7686// consoleView?.requestScrollingToEnd()
7787
7888 processHandler.startNotify()
0 commit comments