|
| 1 | +package com.intellij.plugin.powershell.ide.actions |
| 2 | + |
| 3 | +import com.intellij.execution.DefaultExecutionResult |
| 4 | +import com.intellij.execution.configurations.GeneralCommandLine |
| 5 | +import com.intellij.execution.configurations.PtyCommandLine |
| 6 | +import com.intellij.execution.process.KillableProcessHandler |
| 7 | +import com.intellij.execution.runners.showRunContent |
| 8 | +import com.intellij.execution.util.ExecUtil |
| 9 | +import com.intellij.openapi.actionSystem.AnAction |
| 10 | +import com.intellij.openapi.actionSystem.AnActionEvent |
| 11 | +import com.intellij.openapi.diagnostic.logger |
| 12 | +import com.intellij.openapi.diagnostic.runAndLogException |
| 13 | +import com.intellij.openapi.fileEditor.FileEditorManager |
| 14 | +import com.intellij.openapi.options.advanced.AdvancedSettings |
| 15 | +import com.intellij.openapi.progress.ModalTaskOwner.project |
| 16 | +import com.intellij.openapi.project.Project |
| 17 | +import com.intellij.openapi.rd.util.withUiContext |
| 18 | +import com.intellij.plugin.powershell.ide.run.PowerShellScriptCommandLineState |
| 19 | +import com.intellij.plugin.powershell.lang.lsp.LSPInitMain |
| 20 | +import com.intellij.psi.PsiDocumentManager |
| 21 | +import com.intellij.terminal.TerminalExecutionConsole |
| 22 | +import java.nio.charset.Charset |
| 23 | + |
| 24 | + |
| 25 | +class PowerShellStartDebugAction : AnAction(){ |
| 26 | + val logger = logger<PowerShellStartDebugAction>() |
| 27 | + |
| 28 | + override fun actionPerformed(e: AnActionEvent) { |
| 29 | + logger.info("PowerShellStartDebugAction LOG STARTED") |
| 30 | + val currentProject: Project = e.project ?: return |
| 31 | + var currentDoc = FileEditorManager.getInstance(currentProject).selectedTextEditor?.getDocument() |
| 32 | + val psiFile = PsiDocumentManager.getInstance(currentProject).getPsiFile(currentDoc ?: return) |
| 33 | + val vFile = psiFile!!.originalFile.virtualFile |
| 34 | + val path = vFile.path |
| 35 | + val pwshExe = LSPInitMain.getInstance().getPowerShellExecutable() |
| 36 | + val commandLine = GeneralCommandLine(pwshExe, "-File", "c:\\debugger.ps1", path, "7") |
| 37 | + commandLine.setCharset(Charset.forName("UTF-8")) |
| 38 | + commandLine.setWorkDirectory(currentProject.basePath) |
| 39 | + val result = ExecUtil.execAndGetOutput(commandLine) |
| 40 | + logger.info(result.toString()) |
| 41 | + } |
| 42 | + |
| 43 | + private fun getTerminalCharSet(): Charset { |
| 44 | + val name = AdvancedSettings.getString("terminal.character.encoding") |
| 45 | + return logger.runAndLogException { charset(name) } ?: Charsets.UTF_8 |
| 46 | + } |
| 47 | +} |
| 48 | + |
0 commit comments