com.intellij.execution.DefaultExecutionResult Java Examples

The following examples show how to use com.intellij.execution.DefaultExecutionResult. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FreeRunConfiguration.java    From react-native-console with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private ExecutionResult buildExecutionResult() throws ExecutionException {
    GeneralCommandLine commandLine = createDefaultCommandLine();
    ProcessHandler processHandler = createProcessHandler(commandLine);
    ProcessTerminatedListener.attach(processHandler);
    ConsoleView console = new TerminalExecutionConsole(getProject(), processHandler);

    console.print(
        "Welcome to React Native Console, now please click one button on top toolbar to start.\n",
        ConsoleViewContentType.SYSTEM_OUTPUT);
    console.attachToProcess(processHandler);

    console.print(
        "Give a Star or Suggestion:\n",
        ConsoleViewContentType.NORMAL_OUTPUT);


    processHandler.destroyProcess();
    return new DefaultExecutionResult(console, processHandler);
}
 
Example #2
Source File: SmRunnerUtils.java    From intellij with Apache License 2.0 6 votes vote down vote up
@Nullable
public static AbstractRerunFailedTestsAction createRerunFailedTestsAction(
    DefaultExecutionResult result) {
  ExecutionConsole console = result.getExecutionConsole();
  if (!(console instanceof SMTRunnerConsoleView)) {
    return null;
  }
  SMTRunnerConsoleView smConsole = (SMTRunnerConsoleView) console;
  TestConsoleProperties consoleProperties = smConsole.getProperties();
  if (!(consoleProperties instanceof BlazeTestConsoleProperties)) {
    return null;
  }
  BlazeTestConsoleProperties properties = (BlazeTestConsoleProperties) consoleProperties;
  AbstractRerunFailedTestsAction action = properties.createRerunFailedTestsAction(smConsole);
  if (action != null) {
    action.init(properties);
    action.setModelProvider(smConsole::getResultsViewer);
  }
  return action;
}
 
Example #3
Source File: FastBuildRunProfileState.java    From intellij with Apache License 2.0 6 votes vote down vote up
@Override
public ExecutionResult execute(Executor executor, ProgramRunner runner)
    throws ExecutionException {
  DefaultExecutionResult result = (DefaultExecutionResult) super.execute(executor, runner);
  AbstractRerunFailedTestsAction rerunFailedAction =
      SmRunnerUtils.createRerunFailedTestsAction(result);
  RerunFastBuildConfigurationWithBlazeAction rerunWithBlazeAction =
      new RerunFastBuildConfigurationWithBlazeAction(
          getConfiguration().getProject(), getFastBuildInfo().label(), getEnvironment());
  if (rerunFailedAction != null) {
    result.setRestartActions(rerunFailedAction, rerunWithBlazeAction);
  } else {
    result.setRestartActions(rerunWithBlazeAction);
  }
  return result;
}
 
Example #4
Source File: GaugeCommandLineState.java    From Intellij-Plugin with Apache License 2.0 6 votes vote down vote up
@NotNull
@Override
public ExecutionResult execute(@NotNull Executor executor, @NotNull ProgramRunner runner) throws ExecutionException {
    addProjectClasspath();
    if (GaugeVersion.isGreaterOrEqual(GaugeRunConfiguration.TEST_RUNNER_SUPPORT_VERSION, false)
            && GaugeSettingsService.getSettings().useIntelliJTestRunner()) {
        ProcessHandler handler = startProcess();
        GaugeConsoleProperties properties = new GaugeConsoleProperties(config, "Gauge", executor, handler);
        ConsoleView console = SMTestRunnerConnectionUtil.createAndAttachConsole("Gauge", handler, properties);
        DefaultExecutionResult result = new DefaultExecutionResult(console, handler, createActions(console, handler));
        if (ActionManager.getInstance().getAction("RerunFailedTests") != null) {
            AbstractRerunFailedTestsAction action = properties.createRerunFailedTestsAction(console);
            if (action != null) {
                action.setModelProvider(((SMTRunnerConsoleView) console)::getResultsViewer);
                result.setRestartActions(action);
            }
        }
        return result;
    }
    return super.execute(executor, runner);
}
 
Example #5
Source File: ReplGenericState.java    From reasonml-idea-plugin with MIT License 5 votes vote down vote up
@Nullable
@Override
public ExecutionResult execute(Executor executor, @NotNull ProgramRunner runner) throws ExecutionException {
    ProcessHandler processHandler = startProcess();
    if (processHandler == null) {
        return null;
    }

    PromptConsoleView consoleView = new PromptConsoleView(m_environment.getProject(), true, true);
    consoleView.attachToProcess(processHandler);

    return new DefaultExecutionResult(consoleView, processHandler);
}
 
Example #6
Source File: BlazeAndroidRunState.java    From intellij with Apache License 2.0 5 votes vote down vote up
@Nullable
@Override
public ExecutionResult execute(Executor executor, ProgramRunner runner)
    throws ExecutionException {
  DefaultExecutionResult result = executeInner(executor, runner);
  if (result == null) {
    return null;
  }
  return SmRunnerUtils.attachRerunFailedTestsAction(result);
}
 
Example #7
Source File: SmRunnerUtils.java    From intellij with Apache License 2.0 5 votes vote down vote up
public static DefaultExecutionResult attachRerunFailedTestsAction(DefaultExecutionResult result) {
  AbstractRerunFailedTestsAction action = createRerunFailedTestsAction(result);
  if (action != null) {
    result.setRestartActions(action);
  }
  return result;
}
 
Example #8
Source File: BlazeJavaRunProfileState.java    From intellij with Apache License 2.0 5 votes vote down vote up
@Override
public ExecutionResult execute(Executor executor, ProgramRunner runner)
    throws ExecutionException {
  if (BlazeCommandRunConfigurationRunner.isDebugging(getEnvironment())) {
    new MultiRunDebuggerSessionListener(getEnvironment(), this).startListening();
  }
  DefaultExecutionResult result = (DefaultExecutionResult) super.execute(executor, runner);
  return SmRunnerUtils.attachRerunFailedTestsAction(result);
}
 
Example #9
Source File: RoboVmRunner.java    From robovm-idea with GNU General Public License v2.0 5 votes vote down vote up
@Nullable
protected RunContentDescriptor attachVirtualMachine(RunProfileState state,
                                                    @NotNull ExecutionEnvironment env,
                                                    RemoteConnection connection,
                                                    boolean pollConnection) throws ExecutionException {
    DebugEnvironment environment = new DefaultDebugUIEnvironment(env, state, connection, pollConnection).getEnvironment();
    final DebuggerSession debuggerSession = DebuggerManagerEx.getInstanceEx(env.getProject()).attachVirtualMachine(environment);
    if (debuggerSession == null) {
        return null;
    }

    final DebugProcessImpl debugProcess = debuggerSession.getProcess();
    if (debugProcess.isDetached() || debugProcess.isDetaching()) {
        debuggerSession.dispose();
        return null;
    }
    // optimization: that way BatchEvaluator will not try to lookup the class file in remote VM
    // which is an expensive operation when executed first time
    debugProcess.putUserData(BatchEvaluator.REMOTE_SESSION_KEY, Boolean.TRUE);

    return XDebuggerManager.getInstance(env.getProject()).startSession(env, new XDebugProcessStarter() {
        @Override
        @NotNull
        public XDebugProcess start(@NotNull XDebugSession session) {
            XDebugSessionImpl sessionImpl = (XDebugSessionImpl)session;
            ExecutionResult executionResult = debugProcess.getExecutionResult();
            sessionImpl.addExtraActions(executionResult.getActions());
            if (executionResult instanceof DefaultExecutionResult) {
                sessionImpl.addRestartActions(((DefaultExecutionResult)executionResult).getRestartActions());
                sessionImpl.addExtraStopActions(((DefaultExecutionResult)executionResult).getAdditionalStopActions());
            }
            return JavaDebugProcess.create(session, debuggerSession);
        }
    }).getRunContentDescriptor();
}
 
Example #10
Source File: TestExecutionState.java    From buck with Apache License 2.0 5 votes vote down vote up
@Nullable
@Override
public ExecutionResult execute(Executor executor, @NotNull ProgramRunner runner)
    throws ExecutionException {
  final ProcessHandler processHandler = runBuildCommand(executor);
  final TestConsoleProperties properties =
      new BuckTestConsoleProperties(
          processHandler, mProject, mConfiguration, "Buck test", executor);
  final ConsoleView console =
      SMTestRunnerConnectionUtil.createAndAttachConsole("buck test", processHandler, properties);
  return new DefaultExecutionResult(console, processHandler, AnAction.EMPTY_ARRAY);
}
 
Example #11
Source File: ImportedTestRunnableState.java    From consulo with Apache License 2.0 5 votes vote down vote up
@javax.annotation.Nullable
@Override
public ExecutionResult execute(Executor executor, @Nonnull ProgramRunner runner) throws ExecutionException {
  final MyEmptyProcessHandler handler = new MyEmptyProcessHandler();
  final SMTRunnerConsoleProperties properties = myRunProfile.getProperties();
  RunProfile configuration;
  final String frameworkName;
  if (properties != null) {
    configuration = properties.getConfiguration();
    frameworkName = properties.getTestFrameworkName();
  }
  else {
    configuration = myRunProfile;
    frameworkName = "Import Test Results";
  }
  final ImportedTestConsoleProperties consoleProperties = new ImportedTestConsoleProperties(properties, myFile, handler, myRunProfile.getProject(),
                                                                                            configuration, frameworkName, executor);
  final BaseTestsOutputConsoleView console = SMTestRunnerConnectionUtil.createConsole(consoleProperties.getTestFrameworkName(),
                                                                                      consoleProperties);
  final JComponent component = console.getComponent();
  AbstractRerunFailedTestsAction rerunFailedTestsAction = null;
  if (component instanceof TestFrameworkRunningModel) {
    rerunFailedTestsAction = consoleProperties.createRerunFailedTestsAction(console);
    if (rerunFailedTestsAction != null) {
      rerunFailedTestsAction.setModelProvider(new Getter<TestFrameworkRunningModel>() {
        @Override
        public TestFrameworkRunningModel get() {
          return (TestFrameworkRunningModel)component;
        }
      });
    }
  }

  console.attachToProcess(handler);
  final DefaultExecutionResult result = new DefaultExecutionResult(console, handler);
  if (rerunFailedTestsAction != null) {
    result.setRestartActions(rerunFailedTestsAction);
  }
  return result;
}
 
Example #12
Source File: BlazeAndroidRunState.java    From intellij with Apache License 2.0 4 votes vote down vote up
@Nullable
private DefaultExecutionResult executeInner(Executor executor, ProgramRunner<?> runner)
    throws ExecutionException {
  ProcessHandler processHandler;
  ConsoleView console;

  ApplicationIdProvider applicationIdProvider = runContext.getApplicationIdProvider();

  String applicationId;
  try {
    applicationId = applicationIdProvider.getPackageName();
  } catch (ApkProvisionException e) {
    throw new ExecutionException("Unable to obtain application id", e);
  }

  if (executor instanceof LaunchOptionsProvider) {
    launchOptionsBuilder.addExtraOptions(((LaunchOptionsProvider) executor).getLaunchOptions());
  }

  LaunchTasksProvider launchTasksProvider =
      runContext.getLaunchTasksProvider(launchOptionsBuilder, isDebug, debuggerManager);

  DeviceFutures deviceFutures = deviceSession.deviceFutures;
  assert deviceFutures != null;
  ProcessHandler previousSessionProcessHandler =
      deviceSession.sessionInfo != null ? deviceSession.sessionInfo.getProcessHandler() : null;

  boolean isSwap = env.getUserData(SwapInfo.SWAP_INFO_KEY) != null;
  if (!isSwap) {
    // In the case of cold swap, there is an existing process that is connected,
    // but we are going to launch a new one.
    // Detach the previous process handler so that we don't end up with
    // 2 run tabs for the same launch (the existing one and the new one).
    if (previousSessionProcessHandler != null) {
      RunContentManager manager = RunContentManager.getInstance(env.getProject());
      RunContentDescriptor descriptor =
          manager.findContentDescriptor(executor, previousSessionProcessHandler);
      if (descriptor != null) {
        manager.removeRunContent(executor, descriptor);
      }
      previousSessionProcessHandler.detachProcess();
    }

    processHandler = new AndroidProcessHandler(env.getProject(), applicationId);
    console =
        runContext
            .getConsoleProvider()
            .createAndAttach(module.getProject(), processHandler, executor);
    // Stash the console. When we swap, we need the console, as that has the method to print a
    // hyperlink.
    // (If we only need normal text output, we can call ProcessHandler#notifyTextAvailable
    // instead.)
    processHandler.putCopyableUserData(CONSOLE_VIEW_KEY, console);
  } else {
    assert previousSessionProcessHandler != null
        : "No process handler from previous session, yet current tasks don't create one";
    processHandler = previousSessionProcessHandler;
    console = processHandler.getCopyableUserData(CONSOLE_VIEW_KEY);
    assert console != null;
  }

  LaunchInfo launchInfo = new LaunchInfo(executor, runner, env, runContext.getConsoleProvider());

  LaunchTaskRunner task =
      new LaunchTaskRunner(
          module.getProject(),
          launchConfigName,
          applicationId,
          env.getExecutionTarget().getDisplayName(),
          launchInfo,
          processHandler,
          deviceFutures,
          launchTasksProvider,
          RunStats.from(env),
          console::printHyperlink);

  ProgressManager.getInstance().run(task);

  return console == null ? null : new DefaultExecutionResult(console, processHandler);
}
 
Example #13
Source File: BlazeCommandGenericRunConfigurationRunner.java    From intellij with Apache License 2.0 4 votes vote down vote up
@Override
public ExecutionResult execute(Executor executor, ProgramRunner runner)
    throws ExecutionException {
  DefaultExecutionResult result = (DefaultExecutionResult) super.execute(executor, runner);
  return SmRunnerUtils.attachRerunFailedTestsAction(result);
}
 
Example #14
Source File: Unity3dAttachConfiguration.java    From consulo-unity3d with Apache License 2.0 4 votes vote down vote up
@Nullable
@Override
public RunProfileState getState(@Nonnull Executor executor, @Nonnull ExecutionEnvironment env) throws ExecutionException
{
	return (executor1, runner) -> new DefaultExecutionResult(null, new Unity3dDebugProcessHander());
}
 
Example #15
Source File: Unity3dTestRunState.java    From consulo-unity3d with Apache License 2.0 4 votes vote down vote up
@Nullable
@Override
@RequiredUIAccess
public ExecutionResult execute(Executor executor, @Nonnull ProgramRunner runner) throws ExecutionException
{
	Unity3dTestConfiguration profile = (Unity3dTestConfiguration) myEnvironment.getRunProfile();

	TestConsoleProperties testConsoleProperties = new SMTRunnerConsoleProperties(profile, TEST_FRAMEWORK_NAME, executor);

	testConsoleProperties.setIfUndefined(TestConsoleProperties.HIDE_PASSED_TESTS, false);

	String splitterPropertyName = SMTestRunnerConnectionUtil.getSplitterPropertyName(TEST_FRAMEWORK_NAME);

	final SMTRunnerConsoleView consoleView = new SMTRunnerConsoleView(testConsoleProperties, splitterPropertyName);

	final SimpleReference<UUID> ref = SimpleReference.create();

	consoleView.addAttachToProcessListener(new AttachToProcessListener()
	{
		@Override
		public void onAttachToProcess(@Nonnull ProcessHandler processHandler)
		{
			SMTestRunnerResultsForm resultsForm = consoleView.getResultsViewer();

			ref.set(attachEventsProcessors(consoleView.getProperties(), resultsForm, resultsForm.getStatisticsPane(), processHandler, TEST_FRAMEWORK_NAME));
		}
	});
	consoleView.setHelpId("reference.runToolWindow.testResultsTab");
	consoleView.initUI();

	final ProcessHandler osProcessHandler = new DefaultDebugProcessHandler();

	consoleView.attachToProcess(osProcessHandler);

	UnityRunTest runTest = new UnityRunTest();
	runTest.uuid = ref.get().toString();
	runTest.type = "";

	if(!UnityEditorCommunication.request(profile.getProject(), runTest, true))
	{
		ApplicationManager.getApplication().executeOnPooledThread(new Runnable()
		{
			@Override
			public void run()
			{
				osProcessHandler.notifyTextAvailable("UnityEditor dont received request, maybe is not run", ProcessOutputTypes.STDERR);
				osProcessHandler.destroyProcess();
			}
		});
	}

	return new DefaultExecutionResult(consoleView, osProcessHandler);
}
 
Example #16
Source File: RunContentDescriptor.java    From consulo with Apache License 2.0 4 votes vote down vote up
public RunContentDescriptor(@Nonnull RunProfile profile, @Nonnull ExecutionResult executionResult, @Nonnull RunnerLayoutUi ui) {
  this(executionResult.getExecutionConsole(), executionResult.getProcessHandler(), ui.getComponent(), profile.getName(), profile.getIcon(), null,
       executionResult instanceof DefaultExecutionResult ? ((DefaultExecutionResult)executionResult).getRestartActions() : null);
  myRunnerLayoutUi = ui;
}