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()));
}
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());
}
}
}
Aggregations