Search in sources :

Example 16 with DefaultExecutionResult

use of com.intellij.execution.DefaultExecutionResult in project intellij-community by JetBrains.

the class AntRunProfileState method execute.

@Nullable
@Override
public ExecutionResult execute(Executor executor, @NotNull ProgramRunner runner) throws ExecutionException {
    final RunProfile profile = myEnvironment.getRunProfile();
    if (profile instanceof AntRunConfiguration) {
        final AntRunConfiguration runConfig = (AntRunConfiguration) profile;
        if (runConfig.getTarget() == null) {
            return null;
        }
        final ProcessHandler processHandler = ExecutionHandler.executeRunConfiguration(runConfig, myEnvironment.getDataContext(), runConfig.getProperties(), AntBuildListener.NULL);
        if (processHandler == null) {
            return null;
        }
        return new DefaultExecutionResult(null, processHandler);
    }
    return null;
}
Also used : DefaultExecutionResult(com.intellij.execution.DefaultExecutionResult) ProcessHandler(com.intellij.execution.process.ProcessHandler) RunProfile(com.intellij.execution.configurations.RunProfile) Nullable(org.jetbrains.annotations.Nullable)

Example 17 with DefaultExecutionResult

use of com.intellij.execution.DefaultExecutionResult in project intellij-community by JetBrains.

the class PythonScriptCommandLineState method execute.

@Override
public ExecutionResult execute(Executor executor, PythonProcessStarter processStarter, final CommandLinePatcher... patchers) throws ExecutionException {
    if (myConfig.showCommandLineAfterwards() && !myConfig.emulateTerminal()) {
        if (executor.getId() == DefaultDebugExecutor.EXECUTOR_ID) {
            return super.execute(executor, processStarter, ArrayUtil.append(patchers, new CommandLinePatcher() {

                @Override
                public void patchCommandLine(GeneralCommandLine commandLine) {
                    commandLine.getParametersList().getParamsGroup(PythonCommandLineState.GROUP_DEBUGGER).addParameterAt(1, "--cmd-line");
                }
            }));
        }
        PythonScriptWithConsoleRunner runner = new PythonScriptWithConsoleRunner(myConfig.getProject(), myConfig.getSdk(), PyConsoleType.PYTHON, myConfig.getWorkingDirectory(), myConfig.getEnvs(), patchers, PyConsoleOptions.getInstance(myConfig.getProject()).getPythonConsoleSettings());
        runner.setEnableAfterConnection(false);
        runner.runSync();
        // runner.getProcessHandler() would be null if execution error occurred
        if (runner.getProcessHandler() == null) {
            return null;
        }
        runner.getPydevConsoleCommunication().setConsoleView(runner.getConsoleView());
        List<AnAction> actions = Lists.newArrayList(createActions(runner.getConsoleView(), runner.getProcessHandler()));
        actions.add(new ShowVarsAction(runner.getConsoleView(), runner.getPydevConsoleCommunication()));
        return new DefaultExecutionResult(runner.getConsoleView(), runner.getProcessHandler(), actions.toArray(new AnAction[actions.size()]));
    } else if (myConfig.emulateTerminal()) {
        setRunWithPty(true);
        final ProcessHandler processHandler = startProcess(processStarter, patchers);
        TerminalExecutionConsole executeConsole = new TerminalExecutionConsole(myConfig.getProject(), processHandler);
        executeConsole.addMessageFilter(myConfig.getProject(), new PythonTracebackFilter(myConfig.getProject()));
        executeConsole.addMessageFilter(myConfig.getProject(), new UrlFilter());
        processHandler.startNotify();
        return new DefaultExecutionResult(executeConsole, processHandler, AnAction.EMPTY_ARRAY);
    } else {
        return super.execute(executor, processStarter, patchers);
    }
}
Also used : DefaultExecutionResult(com.intellij.execution.DefaultExecutionResult) ShowVarsAction(com.jetbrains.python.console.actions.ShowVarsAction) TerminalExecutionConsole(com.intellij.terminal.TerminalExecutionConsole) GeneralCommandLine(com.intellij.execution.configurations.GeneralCommandLine) OSProcessHandler(com.intellij.execution.process.OSProcessHandler) ProcessHandler(com.intellij.execution.process.ProcessHandler) UrlFilter(com.intellij.execution.filters.UrlFilter) AnAction(com.intellij.openapi.actionSystem.AnAction)

Example 18 with DefaultExecutionResult

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

the class CfmlUnitRunConfiguration method getState.

@Override
public RunProfileState getState(@NotNull Executor executor, @NotNull final ExecutionEnvironment env) throws ExecutionException {
    return new RunProfileState() {

        @Override
        public ExecutionResult execute(Executor executor, @NotNull ProgramRunner runner) throws ExecutionException {
            final ProcessHandler processHandler = new MyProcessHandler();
            final ConsoleView console = createConsole(getProject(), processHandler, env, executor);
            console.addMessageFilter(new CfmlStackTraceFilterProvider(getProject()));
            // processHandler.startNotify();
            runTests(processHandler);
            return new DefaultExecutionResult(console, processHandler);
        }
    };
}
Also used : Executor(com.intellij.execution.Executor) DefaultExecutionResult(com.intellij.execution.DefaultExecutionResult) BaseTestsOutputConsoleView(com.intellij.execution.testframework.ui.BaseTestsOutputConsoleView) ConsoleView(com.intellij.execution.ui.ConsoleView) ProcessHandler(com.intellij.execution.process.ProcessHandler) ProgramRunner(com.intellij.execution.runners.ProgramRunner) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

DefaultExecutionResult (com.intellij.execution.DefaultExecutionResult)18 ProcessHandler (com.intellij.execution.process.ProcessHandler)14 ConsoleView (com.intellij.execution.ui.ConsoleView)9 NotNull (org.jetbrains.annotations.NotNull)8 Nullable (org.jetbrains.annotations.Nullable)6 OSProcessHandler (com.intellij.execution.process.OSProcessHandler)4 ToggleAutoTestAction (com.intellij.execution.testframework.autotest.ToggleAutoTestAction)4 SMTRunnerConsoleView (com.intellij.execution.testframework.sm.runner.ui.SMTRunnerConsoleView)4 Executor (com.intellij.execution.Executor)3 ProgramRunner (com.intellij.execution.runners.ProgramRunner)3 AbstractRerunFailedTestsAction (com.intellij.execution.testframework.actions.AbstractRerunFailedTestsAction)3 BaseTestsOutputConsoleView (com.intellij.execution.testframework.ui.BaseTestsOutputConsoleView)3 ExecutionException (com.intellij.execution.ExecutionException)2 GeneralCommandLine (com.intellij.execution.configurations.GeneralCommandLine)2 RunProfile (com.intellij.execution.configurations.RunProfile)2 ConsoleViewImpl (com.intellij.execution.impl.ConsoleViewImpl)2 TestConsoleProperties (com.intellij.execution.testframework.TestConsoleProperties)2 SMTRunnerConsoleProperties (com.intellij.execution.testframework.sm.runner.SMTRunnerConsoleProperties)2 File (java.io.File)2 InstantRunBuildInfo (com.android.tools.fd.client.InstantRunBuildInfo)1