Search in sources :

Example 1 with PerlConsoleView

use of com.perl5.lang.perl.idea.sdk.host.PerlConsoleView in project Perl5-IDEA by Camelcade.

the class GenericPerlRunConfiguration method createConsole.

@NotNull
public ConsoleView createConsole(@NotNull PerlRunProfileState runProfileState) throws ExecutionException {
    ExecutionEnvironment executionEnvironment = runProfileState.getEnvironment();
    PerlConsoleView console = ApplicationManager.getApplication().isUnitTestMode() ? new PerlRunConsole(runProfileState.getEnvironment().getProject()) : new PerlTerminalExecutionConsole(executionEnvironment.getProject());
    return console.withHostData(PerlHostData.from(getEffectiveSdk()));
}
Also used : ExecutionEnvironment(com.intellij.execution.runners.ExecutionEnvironment) PerlConsoleView(com.perl5.lang.perl.idea.sdk.host.PerlConsoleView) PerlTerminalExecutionConsole(com.perl5.lang.perl.idea.execution.PerlTerminalExecutionConsole) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with PerlConsoleView

use of com.perl5.lang.perl.idea.sdk.host.PerlConsoleView in project Perl5-IDEA by Camelcade.

the class PerlRunUtil method runInConsole.

public static void runInConsole(@NotNull PerlCommandLine perlCommandLine) {
    ApplicationManager.getApplication().assertIsDispatchThread();
    Executor runExecutor = DefaultRunExecutor.getRunExecutorInstance();
    Project project = perlCommandLine.getNonNullEffectiveProject();
    boolean isUnitTestMode = ApplicationManager.getApplication().isUnitTestMode();
    PerlConsoleView consoleView = isUnitTestMode ? new PerlRunConsole(project) : new PerlTerminalExecutionConsole(project);
    consoleView.withHostData(perlCommandLine.getEffectiveHostData());
    ProcessHandler processHandler = null;
    try {
        processHandler = PerlHostData.createConsoleProcessHandler(perlCommandLine.withPty(!isUnitTestMode));
        if (isUnitTestMode) {
            processHandler.addProcessListener(new ProcessAdapter() {

                @Override
                public void onTextAvailable(@NotNull ProcessEvent event, @NotNull Key outputType) {
                    LOG.info(outputType + ": " + event.getText());
                }
            });
        }
    } catch (ExecutionException e) {
        consoleView.print(e.getMessage(), ConsoleViewContentType.ERROR_OUTPUT);
        LOG.warn(e);
    }
    RunContentDescriptor runContentDescriptor = new RunContentDescriptor(consoleView, processHandler, consoleView.getComponent(), ObjectUtils.notNull(perlCommandLine.getConsoleTitle(), perlCommandLine.getCommandLineString()), ObjectUtils.notNull(perlCommandLine.getConsoleIcon(), PerlIcons.PERL_LANGUAGE_ICON));
    RunContentManager.getInstance(project).showRunContent(runExecutor, runContentDescriptor);
    if (processHandler != null) {
        consoleView.attachToProcess(processHandler);
        processHandler.startNotify();
        if (ApplicationManager.getApplication().isUnitTestMode()) {
            LOG.assertTrue(ourTestDisposable != null);
            TEST_CONSOLE_DESCRIPTORS.add(runContentDescriptor);
            Disposer.register(ourTestDisposable, runContentDescriptor.getExecutionConsole());
        }
    }
}
Also used : ProcessAdapter(com.intellij.execution.process.ProcessAdapter) RunContentDescriptor(com.intellij.execution.ui.RunContentDescriptor) ProcessEvent(com.intellij.execution.process.ProcessEvent) PerlTerminalExecutionConsole(com.perl5.lang.perl.idea.execution.PerlTerminalExecutionConsole) PerlRunConsole(com.perl5.lang.perl.idea.run.PerlRunConsole) Project(com.intellij.openapi.project.Project) DefaultRunExecutor(com.intellij.execution.executors.DefaultRunExecutor) Executor(com.intellij.execution.Executor) PerlConsoleView(com.perl5.lang.perl.idea.sdk.host.PerlConsoleView) ProcessHandler(com.intellij.execution.process.ProcessHandler) ExecutionException(com.intellij.execution.ExecutionException) Key(com.intellij.openapi.util.Key)

Aggregations

PerlTerminalExecutionConsole (com.perl5.lang.perl.idea.execution.PerlTerminalExecutionConsole)2 PerlConsoleView (com.perl5.lang.perl.idea.sdk.host.PerlConsoleView)2 ExecutionException (com.intellij.execution.ExecutionException)1 Executor (com.intellij.execution.Executor)1 DefaultRunExecutor (com.intellij.execution.executors.DefaultRunExecutor)1 ProcessAdapter (com.intellij.execution.process.ProcessAdapter)1 ProcessEvent (com.intellij.execution.process.ProcessEvent)1 ProcessHandler (com.intellij.execution.process.ProcessHandler)1 ExecutionEnvironment (com.intellij.execution.runners.ExecutionEnvironment)1 RunContentDescriptor (com.intellij.execution.ui.RunContentDescriptor)1 Project (com.intellij.openapi.project.Project)1 Key (com.intellij.openapi.util.Key)1 PerlRunConsole (com.perl5.lang.perl.idea.run.PerlRunConsole)1 NotNull (org.jetbrains.annotations.NotNull)1