Search in sources :

Example 6 with ExecutionResult

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

the class JstdCoverageProgramRunner method start.

@Nullable
private static RunContentDescriptor start(@Nullable JstdServer server, @NotNull ExecutionEnvironment environment) throws ExecutionException {
    FileDocumentManager.getInstance().saveAllDocuments();
    JstdRunConfiguration runConfiguration = (JstdRunConfiguration) environment.getRunProfile();
    CoverageEnabledConfiguration coverageEnabledConfiguration = CoverageEnabledConfiguration.getOrCreate(runConfiguration);
    String coverageFilePath = coverageEnabledConfiguration.getCoverageFilePath();
    JstdRunProfileState jstdState = new JstdRunProfileState(environment, runConfiguration.getRunSettings(), coverageFilePath);
    ExecutionResult executionResult = jstdState.executeWithServer(server);
    RunContentBuilder contentBuilder = new RunContentBuilder(executionResult, environment);
    final RunContentDescriptor descriptor = contentBuilder.showRunContent(environment.getContentToReuse());
    ProcessHandler processHandler = executionResult.getProcessHandler();
    if (processHandler instanceof NopProcessHandler) {
        if (server != null) {
            server.addLifeCycleListener(new JstdServerLifeCycleAdapter() {

                @Override
                public void onBrowserCaptured(@NotNull JstdBrowserInfo info) {
                    ExecutionUtil.restartIfActive(descriptor);
                    server.removeLifeCycleListener(this);
                }
            }, contentBuilder);
        }
    } else {
        CoverageHelper.attachToProcess(runConfiguration, processHandler, environment.getRunnerSettings());
    }
    return descriptor;
}
Also used : JstdRunConfiguration(com.google.jstestdriver.idea.execution.JstdRunConfiguration) RunContentDescriptor(com.intellij.execution.ui.RunContentDescriptor) CoverageEnabledConfiguration(com.intellij.execution.configurations.coverage.CoverageEnabledConfiguration) JstdRunProfileState(com.google.jstestdriver.idea.execution.JstdRunProfileState) NopProcessHandler(com.intellij.execution.process.NopProcessHandler) ProcessHandler(com.intellij.execution.process.ProcessHandler) ExecutionResult(com.intellij.execution.ExecutionResult) NopProcessHandler(com.intellij.execution.process.NopProcessHandler) RunContentBuilder(com.intellij.execution.runners.RunContentBuilder) JstdServerLifeCycleAdapter(com.google.jstestdriver.idea.server.JstdServerLifeCycleAdapter) JstdBrowserInfo(com.google.jstestdriver.idea.server.JstdBrowserInfo) Nullable(org.jetbrains.annotations.Nullable)

Example 7 with ExecutionResult

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

the class ToolRunProfile method getState.

@Override
public RunProfileState getState(@NotNull final Executor executor, @NotNull final ExecutionEnvironment env) {
    final Project project = env.getProject();
    if (myCommandLine == null) {
        // can return null if creation of cmd line has been cancelled
        return null;
    }
    final CommandLineState commandLineState = new CommandLineState(env) {

        GeneralCommandLine createCommandLine() {
            return myCommandLine;
        }

        @Override
        @NotNull
        protected OSProcessHandler startProcess() throws ExecutionException {
            final GeneralCommandLine commandLine = createCommandLine();
            final OSProcessHandler processHandler = new ColoredProcessHandler(commandLine);
            ProcessTerminatedListener.attach(processHandler);
            return processHandler;
        }

        @Override
        @NotNull
        public ExecutionResult execute(@NotNull final Executor executor, @NotNull ProgramRunner runner) throws ExecutionException {
            final ExecutionResult result = super.execute(executor, runner);
            final ProcessHandler processHandler = result.getProcessHandler();
            if (processHandler != null) {
                processHandler.addProcessListener(new ToolProcessAdapter(project, myTool.synchronizeAfterExecution(), getName()));
                processHandler.addProcessListener(new ProcessAdapter() {

                    @Override
                    public void onTextAvailable(ProcessEvent event, Key outputType) {
                        if ((outputType == ProcessOutputTypes.STDOUT && myTool.isShowConsoleOnStdOut()) || (outputType == ProcessOutputTypes.STDERR && myTool.isShowConsoleOnStdErr())) {
                            ExecutionManager.getInstance(project).getContentManager().toFrontRunContent(executor, processHandler);
                        }
                    }
                });
            }
            return result;
        }
    };
    TextConsoleBuilder builder = TextConsoleBuilderFactory.getInstance().createBuilder(project);
    final FilterInfo[] outputFilters = myTool.getOutputFilters();
    for (FilterInfo outputFilter : outputFilters) {
        builder.addFilter(new RegexpFilter(project, outputFilter.getRegExp()));
    }
    commandLineState.setConsoleBuilder(builder);
    return commandLineState;
}
Also used : RegexpFilter(com.intellij.execution.filters.RegexpFilter) ExecutionResult(com.intellij.execution.ExecutionResult) NotNull(org.jetbrains.annotations.NotNull) Project(com.intellij.openapi.project.Project) Executor(com.intellij.execution.Executor) TextConsoleBuilder(com.intellij.execution.filters.TextConsoleBuilder) GeneralCommandLine(com.intellij.execution.configurations.GeneralCommandLine) CommandLineState(com.intellij.execution.configurations.CommandLineState) ProgramRunner(com.intellij.execution.runners.ProgramRunner) Key(com.intellij.openapi.util.Key)

Example 8 with ExecutionResult

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

the class DefaultJavaProgramRunner method doExecute.

@Override
protected RunContentDescriptor doExecute(@NotNull RunProfileState state, @NotNull ExecutionEnvironment env) throws ExecutionException {
    FileDocumentManager.getInstance().saveAllDocuments();
    ExecutionResult executionResult;
    boolean shouldAddDefaultActions = true;
    if (state instanceof JavaCommandLine) {
        final JavaParameters parameters = ((JavaCommandLine) state).getJavaParameters();
        patch(parameters, env.getRunnerSettings(), env.getRunProfile(), true);
        ProcessProxy proxy = ProcessProxyFactory.getInstance().createCommandLineProxy((JavaCommandLine) state);
        executionResult = state.execute(env.getExecutor(), this);
        if (proxy != null) {
            ProcessHandler handler = executionResult != null ? executionResult.getProcessHandler() : null;
            if (handler != null) {
                proxy.attach(handler);
                handler.addProcessListener(new ProcessAdapter() {

                    @Override
                    public void processTerminated(ProcessEvent event) {
                        proxy.destroy();
                    }
                });
            } else {
                proxy.destroy();
            }
        }
        if (state instanceof JavaCommandLineState && !((JavaCommandLineState) state).shouldAddJavaProgramRunnerActions()) {
            shouldAddDefaultActions = false;
        }
    } else {
        executionResult = state.execute(env.getExecutor(), this);
    }
    if (executionResult == null) {
        return null;
    }
    onProcessStarted(env.getRunnerSettings(), executionResult);
    final RunContentBuilder contentBuilder = new RunContentBuilder(executionResult, env);
    if (shouldAddDefaultActions) {
        addDefaultActions(contentBuilder, executionResult);
    }
    return contentBuilder.showRunContent(env.getContentToReuse());
}
Also used : ProcessAdapter(com.intellij.execution.process.ProcessAdapter) CapturingProcessAdapter(com.intellij.execution.process.CapturingProcessAdapter) ProcessEvent(com.intellij.execution.process.ProcessEvent) ProcessHandler(com.intellij.execution.process.ProcessHandler) ExecutionResult(com.intellij.execution.ExecutionResult)

Example 9 with ExecutionResult

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

the class KarmaRunProgramRunner method doExecute.

@Nullable
@Override
protected RunContentDescriptor doExecute(@NotNull RunProfileState state, @NotNull ExecutionEnvironment environment) throws ExecutionException {
    FileDocumentManager.getInstance().saveAllDocuments();
    ExecutionResult executionResult = state.execute(environment.getExecutor(), this);
    if (executionResult == null) {
        return null;
    }
    KarmaConsoleView consoleView = KarmaConsoleView.get(executionResult, state);
    final RunContentDescriptor descriptor = KarmaUtil.createDefaultDescriptor(executionResult, environment);
    if (consoleView == null) {
        return descriptor;
    }
    KarmaServer server = consoleView.getKarmaExecutionSession().getKarmaServer();
    if (!server.areBrowsersReady()) {
        server.onBrowsersReady(() -> ExecutionUtil.restartIfActive(descriptor));
    } else {
        RerunTestsNotification.showRerunNotification(environment.getContentToReuse(), executionResult.getExecutionConsole());
    }
    RerunTestsAction.register(descriptor);
    return descriptor;
}
Also used : KarmaServer(com.intellij.javascript.karma.server.KarmaServer) RunContentDescriptor(com.intellij.execution.ui.RunContentDescriptor) ExecutionResult(com.intellij.execution.ExecutionResult) Nullable(org.jetbrains.annotations.Nullable)

Example 10 with ExecutionResult

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

the class JstdRunProgramRunner method start.

public static RunContentDescriptor start(@Nullable JstdServer server, boolean fromDebug, @NotNull RunProfileState state, @NotNull ExecutionEnvironment environment) throws ExecutionException {
    FileDocumentManager.getInstance().saveAllDocuments();
    JstdRunProfileState jstdState = JstdRunProfileState.cast(state);
    ExecutionResult executionResult = jstdState.executeWithServer(server);
    RunContentBuilder contentBuilder = new RunContentBuilder(executionResult, environment);
    final RunContentDescriptor descriptor = contentBuilder.showRunContent(environment.getContentToReuse());
    if (server != null && executionResult.getProcessHandler() instanceof NopProcessHandler) {
        server.addLifeCycleListener(new JstdServerLifeCycleAdapter() {

            @Override
            public void onBrowserCaptured(@NotNull JstdBrowserInfo info) {
                if (fromDebug) {
                    final Alarm alarm = new Alarm(Alarm.ThreadToUse.SWING_THREAD, descriptor);
                    alarm.addRequest(() -> ExecutionUtil.restartIfActive(descriptor), 1000);
                } else {
                    ExecutionUtil.restartIfActive(descriptor);
                }
                server.removeLifeCycleListener(this);
            }
        }, contentBuilder);
    }
    return descriptor;
}
Also used : RunContentDescriptor(com.intellij.execution.ui.RunContentDescriptor) Alarm(com.intellij.util.Alarm) ExecutionResult(com.intellij.execution.ExecutionResult) NopProcessHandler(com.intellij.execution.process.NopProcessHandler) RunContentBuilder(com.intellij.execution.runners.RunContentBuilder) JstdServerLifeCycleAdapter(com.google.jstestdriver.idea.server.JstdServerLifeCycleAdapter) JstdBrowserInfo(com.google.jstestdriver.idea.server.JstdBrowserInfo)

Aggregations

ExecutionResult (com.intellij.execution.ExecutionResult)25 Nullable (org.jetbrains.annotations.Nullable)10 NotNull (org.jetbrains.annotations.NotNull)9 DefaultExecutionResult (com.intellij.execution.DefaultExecutionResult)6 RunContentBuilder (com.intellij.execution.runners.RunContentBuilder)6 RunContentDescriptor (com.intellij.execution.ui.RunContentDescriptor)6 ProcessHandler (com.intellij.execution.process.ProcessHandler)5 XDebugProcessStarter (com.intellij.xdebugger.XDebugProcessStarter)5 XDebugSession (com.intellij.xdebugger.XDebugSession)5 ExecutionException (com.intellij.execution.ExecutionException)4 Project (com.intellij.openapi.project.Project)3 XDebugProcess (com.intellij.xdebugger.XDebugProcess)3 DartUrlResolver (com.jetbrains.lang.dart.util.DartUrlResolver)3 JstdBrowserInfo (com.google.jstestdriver.idea.server.JstdBrowserInfo)2 JstdServerLifeCycleAdapter (com.google.jstestdriver.idea.server.JstdServerLifeCycleAdapter)2 DebugEnvironment (com.intellij.debugger.DebugEnvironment)2 DebugProcessImpl (com.intellij.debugger.engine.DebugProcessImpl)2 RunProfile (com.intellij.execution.configurations.RunProfile)2 NopProcessHandler (com.intellij.execution.process.NopProcessHandler)2 ProcessAdapter (com.intellij.execution.process.ProcessAdapter)2