Search in sources :

Example 46 with OSProcessHandler

use of com.intellij.execution.process.OSProcessHandler in project intellij-elixir by KronicDeth.

the class ElixirXDebugProcess method runDebugTarget.

@NotNull
private OSProcessHandler runDebugTarget() throws ExecutionException {
    OSProcessHandler elixirProcessHandler;
    LOG.debug("Preparing to run debug target.");
    ArrayList<String> elixirParams = new ArrayList<>();
    elixirParams.addAll(myRunningState.setupElixirParams());
    elixirParams.addAll(setUpElixirDebuggerCodePath());
    List<String> mixParams = new ArrayList<>();
    mixParams.addAll(Arrays.asList("intellij_elixir.debug_task", "--debugger-port", "" + myDebuggerNode.getLocalDebuggerPort(), "--"));
    List<String> mixCommandArgs = getRunConfiguration().getMixArgs();
    mixParams.addAll(mixCommandArgs);
    if (getRunConfiguration() instanceof MixExUnitRunConfiguration && !mixCommandArgs.contains("--trace")) {
        // Prevents tests from timing out while debugging
        mixParams.add("--trace");
    }
    GeneralCommandLine commandLine = MixRunningStateUtil.commandLine(getRunConfiguration(), elixirParams, mixParams);
    LOG.debug("Running debugger process. Command line (platform-independent): ");
    LOG.debug(commandLine.getCommandLineString());
    Process process = commandLine.createProcess();
    elixirProcessHandler = new OSProcessHandler(process, commandLine.getCommandLineString());
    LOG.debug("Debugger process started.");
    return elixirProcessHandler;
}
Also used : OSProcessHandler(com.intellij.execution.process.OSProcessHandler) MixExUnitRunConfiguration(org.elixir_lang.mix.runner.exunit.MixExUnitRunConfiguration) GeneralCommandLine(com.intellij.execution.configurations.GeneralCommandLine) ArrayList(java.util.ArrayList) XDebugProcess(com.intellij.xdebugger.XDebugProcess) NotNull(org.jetbrains.annotations.NotNull)

Example 47 with OSProcessHandler

use of com.intellij.execution.process.OSProcessHandler in project intellij-plugins by JetBrains.

the class KarmaDebugProgramRunner method resumeTestRunning.

private static void resumeTestRunning(@NotNull ProcessHandler processHandler) {
    if (processHandler instanceof OSProcessHandler) {
        // process's input stream will be closed on process termination
        @SuppressWarnings({ "IOResourceOpenedButNotSafelyClosed", "ConstantConditions" }) PrintWriter writer = new PrintWriter(processHandler.getProcessInput());
        writer.print("resume-test-running\n");
        writer.flush();
    }
}
Also used : OSProcessHandler(com.intellij.execution.process.OSProcessHandler) PrintWriter(java.io.PrintWriter)

Example 48 with OSProcessHandler

use of com.intellij.execution.process.OSProcessHandler in project intellij-plugins by JetBrains.

the class BndTestState method startProcess.

@NotNull
@Override
protected OSProcessHandler startProcess() throws ExecutionException {
    OSProcessHandler processHandler = super.startProcess();
    processHandler.addProcessListener(new ProcessAdapter() {

        @Override
        public void processTerminated(ProcessEvent event) {
            cleanup();
        }
    });
    return processHandler;
}
Also used : ProcessAdapter(com.intellij.execution.process.ProcessAdapter) ProcessEvent(com.intellij.execution.process.ProcessEvent) OSProcessHandler(com.intellij.execution.process.OSProcessHandler) NotNull(org.jetbrains.annotations.NotNull)

Example 49 with OSProcessHandler

use of com.intellij.execution.process.OSProcessHandler in project intellij-plugins by JetBrains.

the class BndLaunchState method startProcess.

@NotNull
@Override
protected OSProcessHandler startProcess() throws ExecutionException {
    OSProcessHandler handler = super.startProcess();
    MessageBusConnection connection = myProject.getMessageBus().connect();
    connection.subscribe(CompilerTopics.COMPILATION_STATUS, this);
    HotSwapUI hotSwapManager = HotSwapUI.getInstance(myProject);
    hotSwapManager.addListener(this);
    handler.addProcessListener(new ProcessAdapter() {

        @Override
        public void processTerminated(ProcessEvent event) {
            connection.disconnect();
            hotSwapManager.removeListener(BndLaunchState.this);
            myLauncher.cleanup();
        }
    });
    return handler;
}
Also used : MessageBusConnection(com.intellij.util.messages.MessageBusConnection) ProcessAdapter(com.intellij.execution.process.ProcessAdapter) HotSwapUI(com.intellij.debugger.ui.HotSwapUI) ProcessEvent(com.intellij.execution.process.ProcessEvent) OSProcessHandler(com.intellij.execution.process.OSProcessHandler) NotNull(org.jetbrains.annotations.NotNull)

Example 50 with OSProcessHandler

use of com.intellij.execution.process.OSProcessHandler in project intellij-plugins by JetBrains.

the class PhoneGapExecutableChecker method check.

public static void check(Project project) {
    PhoneGapSettings instance = PhoneGapSettings.getInstance();
    if (StringUtil.isEmpty(instance.getExecutablePath())) {
        noPhoneGap();
        return;
    }
    String phoneGapExecutablePath = instance.getExecutablePath();
    final GeneralCommandLine generalCommandLine = new GeneralCommandLine(phoneGapExecutablePath, "--version");
    generalCommandLine.setWorkDirectory(project.getBasePath());
    try {
        final OSProcessHandler handler = new OSProcessHandler(generalCommandLine);
        handler.startNotify();
        generalCommandLine.createProcess();
    } catch (Exception e) {
        noPhoneGap();
    }
}
Also used : OSProcessHandler(com.intellij.execution.process.OSProcessHandler) GeneralCommandLine(com.intellij.execution.configurations.GeneralCommandLine) PhoneGapSettings(com.github.masahirosuzuka.PhoneGapIntelliJPlugin.settings.PhoneGapSettings)

Aggregations

OSProcessHandler (com.intellij.execution.process.OSProcessHandler)55 ExecutionException (com.intellij.execution.ExecutionException)25 GeneralCommandLine (com.intellij.execution.configurations.GeneralCommandLine)24 ProcessEvent (com.intellij.execution.process.ProcessEvent)24 ProcessAdapter (com.intellij.execution.process.ProcessAdapter)23 NotNull (org.jetbrains.annotations.NotNull)18 Key (com.intellij.openapi.util.Key)14 ProcessHandler (com.intellij.execution.process.ProcessHandler)6 Project (com.intellij.openapi.project.Project)6 VirtualFile (com.intellij.openapi.vfs.VirtualFile)6 File (java.io.File)6 Module (com.intellij.openapi.module.Module)5 Sdk (com.intellij.openapi.projectRoots.Sdk)5 IOException (java.io.IOException)5 ProgramRunner (com.intellij.execution.runners.ProgramRunner)4 Nullable (org.jetbrains.annotations.Nullable)4 Executor (com.intellij.execution.Executor)3 RunContentExecutor (com.intellij.execution.RunContentExecutor)3 KillableColoredProcessHandler (com.intellij.execution.process.KillableColoredProcessHandler)3 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)3