Search in sources :

Example 1 with RunContentBuilder

use of com.intellij.execution.runners.RunContentBuilder 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 2 with RunContentBuilder

use of com.intellij.execution.runners.RunContentBuilder 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)

Example 3 with RunContentBuilder

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

the class FlexRunner method launchWebFlexUnit.

protected RunContentDescriptor launchWebFlexUnit(final Project project, final RunContentDescriptor contentToReuse, final ExecutionEnvironment env, final FlexUnitRunnerParameters params, final String swfFilePath) throws ExecutionException {
    final SwfPolicyFileConnection policyFileConnection = new SwfPolicyFileConnection();
    policyFileConnection.open(params.getSocketPolicyPort());
    final FlexUnitConnection flexUnitConnection = new FlexUnitConnection();
    flexUnitConnection.open(params.getPort());
    final ProcessHandler processHandler = new DefaultDebugProcessHandler() {

        @Override
        protected void destroyProcessImpl() {
            flexUnitConnection.write("Finish");
            flexUnitConnection.close();
            policyFileConnection.close();
            super.destroyProcessImpl();
        }

        @Override
        public boolean detachIsDefault() {
            return false;
        }
    };
    final ExecutionConsole console = createFlexUnitRunnerConsole(project, env, processHandler);
    flexUnitConnection.addListener(new FlexUnitListener(processHandler));
    launchWithSelectedApplication(swfFilePath, params.getLauncherParameters());
    final RunContentBuilder contentBuilder = new RunContentBuilder(new DefaultExecutionResult(console, processHandler), env);
    Disposer.register(project, contentBuilder);
    return contentBuilder.showRunContent(contentToReuse);
}
Also used : SwfPolicyFileConnection(com.intellij.lang.javascript.flex.flexunit.SwfPolicyFileConnection) FlexUnitConnection(com.intellij.lang.javascript.flex.flexunit.FlexUnitConnection) DefaultExecutionResult(com.intellij.execution.DefaultExecutionResult) DefaultDebugProcessHandler(com.intellij.xdebugger.DefaultDebugProcessHandler) DefaultDebugProcessHandler(com.intellij.xdebugger.DefaultDebugProcessHandler) ProcessHandler(com.intellij.execution.process.ProcessHandler) ExecutionConsole(com.intellij.execution.ui.ExecutionConsole) RunContentBuilder(com.intellij.execution.runners.RunContentBuilder)

Example 4 with RunContentBuilder

use of com.intellij.execution.runners.RunContentBuilder in project go-lang-idea-plugin by go-lang-plugin-org.

the class GoCoverageProgramRunner method doExecute.

@Nullable
@Override
protected RunContentDescriptor doExecute(@NotNull RunProfileState state, @NotNull ExecutionEnvironment environment) throws ExecutionException {
    assert state instanceof GoTestRunningState;
    GoTestRunningState runningState = (GoTestRunningState) state;
    GoTestRunConfiguration runConfiguration = ObjectUtils.tryCast(environment.getRunProfile(), GoTestRunConfiguration.class);
    if (runConfiguration == null) {
        return null;
    }
    FileDocumentManager.getInstance().saveAllDocuments();
    CoverageEnabledConfiguration coverageEnabledConfiguration = CoverageEnabledConfiguration.getOrCreate(runConfiguration);
    runningState.setCoverageFilePath(coverageEnabledConfiguration.getCoverageFilePath());
    ExecutionResult executionResult = state.execute(environment.getExecutor(), this);
    if (executionResult == null) {
        return null;
    }
    CoverageHelper.attachToProcess(runConfiguration, executionResult.getProcessHandler(), environment.getRunnerSettings());
    return new RunContentBuilder(executionResult, environment).showRunContent(environment.getContentToReuse());
}
Also used : CoverageEnabledConfiguration(com.intellij.execution.configurations.coverage.CoverageEnabledConfiguration) GoTestRunConfiguration(com.goide.runconfig.testing.GoTestRunConfiguration) ExecutionResult(com.intellij.execution.ExecutionResult) GoTestRunningState(com.goide.runconfig.testing.GoTestRunningState) RunContentBuilder(com.intellij.execution.runners.RunContentBuilder) Nullable(org.jetbrains.annotations.Nullable)

Example 5 with RunContentBuilder

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

the class FlexRunner method standardLaunch.

@Nullable
private RunContentDescriptor standardLaunch(final Project project, final RunProfileState state, final RunContentDescriptor contentToReuse, final ExecutionEnvironment environment) throws ExecutionException {
    final ExecutionResult executionResult = state.execute(environment.getExecutor(), this);
    if (executionResult == null)
        return null;
    final RunContentBuilder contentBuilder = new RunContentBuilder(executionResult, environment);
    return contentBuilder.showRunContent(contentToReuse);
}
Also used : ExecutionResult(com.intellij.execution.ExecutionResult) DefaultExecutionResult(com.intellij.execution.DefaultExecutionResult) RunContentBuilder(com.intellij.execution.runners.RunContentBuilder) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

RunContentBuilder (com.intellij.execution.runners.RunContentBuilder)6 ExecutionResult (com.intellij.execution.ExecutionResult)5 Nullable (org.jetbrains.annotations.Nullable)4 DefaultExecutionResult (com.intellij.execution.DefaultExecutionResult)3 JstdBrowserInfo (com.google.jstestdriver.idea.server.JstdBrowserInfo)2 JstdServerLifeCycleAdapter (com.google.jstestdriver.idea.server.JstdServerLifeCycleAdapter)2 CoverageEnabledConfiguration (com.intellij.execution.configurations.coverage.CoverageEnabledConfiguration)2 NopProcessHandler (com.intellij.execution.process.NopProcessHandler)2 ProcessHandler (com.intellij.execution.process.ProcessHandler)2 RunContentDescriptor (com.intellij.execution.ui.RunContentDescriptor)2 FlexUnitConnection (com.intellij.lang.javascript.flex.flexunit.FlexUnitConnection)2 SwfPolicyFileConnection (com.intellij.lang.javascript.flex.flexunit.SwfPolicyFileConnection)2 GoTestRunConfiguration (com.goide.runconfig.testing.GoTestRunConfiguration)1 GoTestRunningState (com.goide.runconfig.testing.GoTestRunningState)1 JstdRunConfiguration (com.google.jstestdriver.idea.execution.JstdRunConfiguration)1 JstdRunProfileState (com.google.jstestdriver.idea.execution.JstdRunProfileState)1 ProcessAdapter (com.intellij.execution.process.ProcessAdapter)1 ProcessEvent (com.intellij.execution.process.ProcessEvent)1 ExecutionConsole (com.intellij.execution.ui.ExecutionConsole)1 Alarm (com.intellij.util.Alarm)1