com.intellij.execution.Executor Java Examples

The following examples show how to use com.intellij.execution.Executor. 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: RunConfigurationsSEContributor.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Nullable
private static Executor findExecutor(@Nonnull RunnerAndConfigurationSettings settings, @MagicConstant(intValues = {RUN_MODE, DEBUG_MODE}) int mode) {
  Executor runExecutor = DefaultRunExecutor.getRunExecutorInstance();
  Executor debugExecutor = ExecutorRegistry.getInstance().getExecutorById(ToolWindowId.DEBUG);

  Executor executor = mode == RUN_MODE ? runExecutor : debugExecutor;
  if (executor == null) {
    return null;
  }

  RunConfiguration runConf = settings.getConfiguration();
  if (ProgramRunner.getRunner(executor.getId(), runConf) == null) {
    executor = runExecutor == executor ? debugExecutor : runExecutor;
  }

  return executor;
}
 
Example #2
Source File: BazelRunConfig.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@NotNull
@Override
public LaunchState getState(@NotNull Executor executor, @NotNull ExecutionEnvironment env) throws ExecutionException {
  final BazelFields launchFields = fields.copy();
  try {
    launchFields.checkRunnable(env.getProject());
  }
  catch (RuntimeConfigurationError e) {
    throw new ExecutionException(e);
  }

  final Workspace workspace = fields.getWorkspace(getProject());
  final VirtualFile workspaceRoot = workspace.getRoot();
  final RunMode mode = RunMode.fromEnv(env);
  final Module module = ModuleUtil.findModuleForFile(workspaceRoot, env.getProject());

  final LaunchState.CreateAppCallback createAppCallback = (@Nullable FlutterDevice device) -> {
    if (device == null) return null;

    final GeneralCommandLine command = getCommand(env, device);
    return FlutterApp.start(env, env.getProject(), module, mode, device, command,
                            StringUtil.capitalize(mode.mode()) + "BazelApp", "StopBazelApp");
  };

  return new LaunchState(env, workspaceRoot, workspaceRoot, this, createAppCallback);
}
 
Example #3
Source File: TestLaunchState.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Nullable
@Override
protected ConsoleView createConsole(@NotNull Executor executor) throws ExecutionException {
  if (!testConsoleEnabled) {
    return super.createConsole(executor);
  }

  // Create a console showing a test tree.
  final Project project = getEnvironment().getProject();
  final DartUrlResolver resolver = DartUrlResolver.getInstance(project, testFileOrDir);
  final ConsoleProps props = ConsoleProps.forPub(config, executor, resolver);
  final BaseTestsOutputConsoleView console = SMTestRunnerConnectionUtil.createConsole(ConsoleProps.pubFrameworkName, props);

  final Module module = ModuleUtil.findModuleForFile(testFileOrDir, project);
  console.addMessageFilter(new DartConsoleFilter(project, getTestFileOrDir()));
  final String baseDir = getBaseDir();
  if (baseDir != null) {
    console.addMessageFilter(new DartRelativePathsConsoleFilter(project, baseDir));
  }
  console.addMessageFilter(new UrlFilter());

  return console;
}
 
Example #4
Source File: BazelRunConfig.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@NotNull
@Override
public LaunchState getState(@NotNull Executor executor, @NotNull ExecutionEnvironment env) throws ExecutionException {
  final BazelFields launchFields = fields.copy();
  try {
    launchFields.checkRunnable(env.getProject());
  }
  catch (RuntimeConfigurationError e) {
    throw new ExecutionException(e);
  }

  final Workspace workspace = fields.getWorkspace(getProject());
  final VirtualFile workspaceRoot = workspace.getRoot();
  final RunMode mode = RunMode.fromEnv(env);
  final Module module = ModuleUtil.findModuleForFile(workspaceRoot, env.getProject());

  final LaunchState.CreateAppCallback createAppCallback = (@Nullable FlutterDevice device) -> {
    if (device == null) return null;

    final GeneralCommandLine command = getCommand(env, device);
    return FlutterApp.start(env, env.getProject(), module, mode, device, command,
                            StringUtil.capitalize(mode.mode()) + "BazelApp", "StopBazelApp");
  };

  return new LaunchState(env, workspaceRoot, workspaceRoot, this, createAppCallback);
}
 
Example #5
Source File: RemoteExternalSystemCommunicationManager.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Inject
public RemoteExternalSystemCommunicationManager(@Nonnull ExternalSystemProgressNotificationManager notificationManager) {
  myProgressManager = (ExternalSystemProgressNotificationManagerImpl)notificationManager;
  mySupport = new RemoteProcessSupport<Object, RemoteExternalSystemFacade, String>(RemoteExternalSystemFacade.class) {
    @Override
    protected void fireModificationCountChanged() {
    }

    @Override
    protected String getName(Object o) {
      return RemoteExternalSystemFacade.class.getName();
    }

    @Override
    protected RunProfileState getRunProfileState(Object o, String configuration, Executor executor) throws ExecutionException {
      return createRunProfileState();
    }
  };

  ShutDownTracker.getInstance().registerShutdownTask(new Runnable() {
    public void run() {
      shutdown(false);
    }
  });
}
 
Example #6
Source File: TrackCoverageAction.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Nullable
private CoverageSuitesBundle getCurrentCoverageSuite() {
  if (myModel == null) {
    return null;
  }

  final RunProfile runConf = myModel.getProperties().getConfiguration();
  if (runConf instanceof ModuleBasedConfiguration) {

    // if coverage supported for run configuration
    if (CoverageEnabledConfiguration.isApplicableTo((ModuleBasedConfiguration) runConf)) {

      // Get coverage settings
      Executor executor = myProperties.getExecutor();
      if (executor != null && executor.getId().equals(CoverageExecutor.EXECUTOR_ID)) {
        return CoverageDataManager.getInstance(myProperties.getProject()).getCurrentSuitesBundle();
      }
    }
  }
  return null;
}
 
Example #7
Source File: BashTerminalCommandLineState.java    From BashSupport with Apache License 2.0 5 votes vote down vote up
@NotNull
@Override
public ExecutionResult execute(@NotNull Executor executor, @NotNull ProgramRunner runner) throws ExecutionException {
    String workingDir = BashRunConfigUtil.findWorkingDir(runConfig);
    GeneralCommandLine cmd = BashRunConfigUtil.createCommandLine(workingDir, runConfig);

    BashLocalTerminalRunner myRunner = new BashLocalTerminalRunner(runConfig.getProject(), runConfig.getScriptName(), cmd);
    myRunner.run();
    return new BashTerminalExecutionResult(myRunner.getProcessHandler());
}
 
Example #8
Source File: AndroidTestConsoleProvider.java    From intellij with Apache License 2.0 5 votes vote down vote up
@Override
public ConsoleView createAndAttach(Disposable parent, ProcessHandler handler, Executor executor)
    throws ExecutionException {
  switch (configState.getLaunchMethod()) {
    case BLAZE_TEST:
      ConsoleView console = createBlazeTestConsole(executor);
      console.attachToProcess(handler);
      return console;
    case NON_BLAZE:
    case MOBILE_INSTALL:
      return getStockConsoleProvider().createAndAttach(parent, handler, executor);
  }
  throw new AssertionError();
}
 
Example #9
Source File: Unity3dTestConfiguration.java    From consulo-unity3d with Apache License 2.0 5 votes vote down vote up
@Nullable
@Override
@RequiredUIAccess
public RunProfileState getState(@Nonnull Executor executor, @Nonnull final ExecutionEnvironment environment) throws ExecutionException
{
	return new Unity3dTestRunState(environment);
}
 
Example #10
Source File: ConsoleProps.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private ConsoleProps(@NotNull RunConfiguration config,
                     @NotNull Executor exec,
                     @NotNull DartUrlResolver resolver,
                     String testFrameworkName) {
  super(config, "FlutterTestRunner", exec);
  this.resolver = resolver;
  setUsePredefinedMessageFilter(false);
  setIdBasedTestTree(true);
}
 
Example #11
Source File: BazelTestLaunchState.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Nullable
@Override
protected ConsoleView createConsole(@NotNull Executor executor) throws ExecutionException {
  // If the --machine output flag is not turned on, then don't activate the new window.
  if (fields.getAdditionalArgs() != null && fields.getAdditionalArgs().contains(BazelTestFields.Flags.noMachine)) {
    return super.createConsole(executor);
  }

  // Create a console showing a test tree.
  final Project project = getEnvironment().getProject();
  final Workspace workspace = WorkspaceCache.getInstance(project).get();

  // Fail gracefully if we have an unexpected null.
  if (workspace == null) {
    return super.createConsole(executor);
  }

  final DartUrlResolver resolver = DartUrlResolver.getInstance(project, workspace.getRoot());
  final ConsoleProps props = ConsoleProps.forBazel(config, executor, resolver);
  final BaseTestsOutputConsoleView console = SMTestRunnerConnectionUtil.createConsole(ConsoleProps.bazelFrameworkName, props);

  // TODO(devoncarew): Will DartConsoleFilter work well in a Bazel context?
  console.addMessageFilter(new DartConsoleFilter(project, testFile));
  final String baseDir = workspace.getRoot().getPath();
  console.addMessageFilter(new DartRelativePathsConsoleFilter(project, baseDir));
  console.addMessageFilter(new UrlFilter());
  return console;
}
 
Example #12
Source File: BlazeCidrRunConfigurationHandler.java    From intellij with Apache License 2.0 5 votes vote down vote up
@Override
public BlazeCommandRunConfigurationRunner createRunner(
    Executor executor, ExecutionEnvironment environment) {
  RunnerAndConfigurationSettings settings = environment.getRunnerAndConfigurationSettings();
  RunConfiguration config = settings != null ? settings.getConfiguration() : null;
  if (config instanceof BlazeCommandRunConfiguration
      && RunConfigurationUtils.canUseClionRunner((BlazeCommandRunConfiguration) config)) {
    return new BlazeCidrRunConfigurationRunner((BlazeCommandRunConfiguration) config);
  }
  return new BlazeCommandGenericRunConfigurationRunner();
}
 
Example #13
Source File: RunFlutterAction.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Nullable
public static Executor getExecutor(@NotNull String executorId) {
  for (Executor executor : Executor.EXECUTOR_EXTENSION_NAME.getExtensions()) {
    if (executorId.equals(executor.getId())) {
      return executor;
    }
  }

  return null;
}
 
Example #14
Source File: RunAnythingCommandProvider.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void execute(@Nonnull DataContext dataContext, @Nonnull String value) {
  VirtualFile workDirectory = dataContext.getData(CommonDataKeys.VIRTUAL_FILE);
  Executor executor = dataContext.getData(RunAnythingAction.EXECUTOR_KEY);
  LOG.assertTrue(workDirectory != null);
  LOG.assertTrue(executor != null);

  runCommand(workDirectory, value, executor, dataContext);
}
 
Example #15
Source File: ExecutorAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
private String getActionName(DataContext dataContext, @Nonnull Executor executor) {
  List<ConfigurationFromContext> list = getConfigurations(dataContext);
  if (list.isEmpty()) return null;
  ConfigurationFromContext configuration = list.get(myOrder < list.size() ? myOrder : 0);
  String actionName = BaseRunConfigurationAction.suggestRunActionName((LocatableConfiguration)configuration.getConfiguration());
  return executor.getActionText(actionName);
}
 
Example #16
Source File: HaxeFlashDebuggingUtil.java    From intellij-haxe with Apache License 2.0 5 votes vote down vote up
public static RunContentDescriptor getOpenFLDescriptor(final HaxeDebugRunner runner,
                                                       final Module module,
                                                       final ExecutionEnvironment env,
                                                       final Executor executor, String flexSdkName) throws ExecutionException {
  final Sdk flexSdk = FlexSdkUtils.findFlexOrFlexmojosSdk(flexSdkName);
  if (flexSdk == null) {
    throw new ExecutionException(HaxeBundle.message("flex.sdk.not.found", flexSdkName));
  }

  final FlexBuildConfiguration bc = new FakeFlexBuildConfiguration(flexSdk, null);

  final XDebugSession debugSession =
    XDebuggerManager.getInstance(module.getProject()).startSession(env, new XDebugProcessStarter() {
      @NotNull
      public XDebugProcess start(@NotNull final XDebugSession session) throws ExecutionException {
        try {
          OpenFLRunningState runningState = new OpenFLRunningState(env, module, false, true);
          final ExecutionResult executionResult = runningState.execute(executor, runner);
          final BCBasedRunnerParameters params = new BCBasedRunnerParameters();
          params.setModuleName(module.getName());
          return new HaxeDebugProcess(session, bc, params);
        }
        catch (IOException e) {
          throw new ExecutionException(e.getMessage(), e);
        }
      }
    });

  return debugSession.getRunContentDescriptor();
}
 
Example #17
Source File: CppRunner.java    From CppTools with Apache License 2.0 5 votes vote down vote up
@Nullable
@Override
protected RunContentDescriptor doExecute(Project project, RunProfileState runProfileState, RunContentDescriptor runContentDescriptor, ExecutionEnvironment executionEnvironment) throws ExecutionException {
  FileDocumentManager.getInstance().saveAllDocuments();
  Executor executor = executionEnvironment.getExecutor();

  ExecutionResult executionResult = runProfileState.execute(executor, this);
  if (executionResult == null) return null;
  final RunContentBuilder contentBuilder = new RunContentBuilder(executionResult, executionEnvironment);
  onProcessStarted(executionEnvironment.getRunnerSettings(), executionResult);

  return contentBuilder.showRunContent(runContentDescriptor);
}
 
Example #18
Source File: BuckTestConsoleProperties.java    From buck with Apache License 2.0 5 votes vote down vote up
public BuckTestConsoleProperties(
    ProcessHandler handler,
    Project project,
    RunProfile runConfiguration,
    String frameworkName,
    Executor executor) {
  super(project, runConfiguration, frameworkName, executor);
  mHandler = handler;
}
 
Example #19
Source File: FreeRunConfiguration.java    From freeline with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Nullable
@Override
protected ConsoleView createConsole(@NotNull Executor executor) throws ExecutionException {
    ConsoleView console = super.createConsole(executor);
    // before run new task,clean log
    if (console != null) {
        console.clear();
    }
    return console;
}
 
Example #20
Source File: ExecutorAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
private ExecutorAction(@Nonnull AnAction origin,
                       @Nonnull Executor executor,
                       int order) {
  myOrigin = origin;
  myExecutor = executor;
  myOrder = order;
  copyFrom(origin);
}
 
Example #21
Source File: BlazeAndroidDeviceSelector.java    From intellij with Apache License 2.0 5 votes vote down vote up
DeviceSession getDevice(
Project project,
AndroidFacet facet,
BlazeAndroidRunConfigurationDeployTargetManager deployTargetManager,
Executor executor,
ExecutionEnvironment env,
AndroidSessionInfo info,
boolean debug,
int runConfigId)
throws ExecutionException;
 
Example #22
Source File: BlazeAndroidDeviceSelector.java    From intellij with Apache License 2.0 5 votes vote down vote up
@Override
public DeviceSession getDevice(
    Project project,
    AndroidFacet facet,
    BlazeAndroidRunConfigurationDeployTargetManager deployTargetManager,
    Executor executor,
    ExecutionEnvironment env,
    AndroidSessionInfo info,
    boolean debug,
    int runConfigId)
    throws ExecutionException {
  // If there is an existing session, then terminate those sessions
  if (info != null) {
    boolean continueLaunch = promptAndKillSession(executor, project, info);
    if (!continueLaunch) {
      return null;
    }
  }

  DeployTarget deployTarget =
      deployTargetManager.getDeployTarget(executor, env, facet, runConfigId);
  if (deployTarget == null) {
    return null;
  }

  DeviceFutures deviceFutures = null;
  DeployTargetState deployTargetState = deployTargetManager.getCurrentDeployTargetState();
  if (!deployTarget.hasCustomRunProfileState(executor)) {
    deviceFutures =
        deployTarget.getDevices(
            deployTargetState, facet, deployTargetManager.getDeviceCount(), debug, runConfigId);
  }
  return new DeviceSession(deployTarget, deviceFutures, info);
}
 
Example #23
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 #24
Source File: RunConfigurationNode.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nullable
private Image getExecutorIcon() {
  Content content = getContent();
  if (content != null) {
    if (!RunContentManagerImpl.isTerminated(content)) {
      Executor executor = RunContentManagerImpl.getExecutorByContent(content);
      if (executor != null) {
        return executor.getIcon();
      }
    }
  }
  return null;
}
 
Example #25
Source File: MongoRunConfiguration.java    From nosql4idea with Apache License 2.0 5 votes vote down vote up
@Nullable
@Override
public RunProfileState getState(@NotNull Executor executor, @NotNull ExecutionEnvironment env) throws ExecutionException {
    final VirtualFile script = getScriptPath();
    if (script == null) {
        throw new CantRunException("Cannot find script " + scriptPath);
    }

    final MongoCommandLineState state = new MongoCommandLineState(this, env);
    state.setConsoleBuilder(TextConsoleBuilderFactory.getInstance().createBuilder(getProject()));
    return state;
}
 
Example #26
Source File: BlazeJavaRunConfigurationHandler.java    From intellij with Apache License 2.0 5 votes vote down vote up
@Override
public RunProfileState getRunProfileState(Executor executor, ExecutionEnvironment env) {
  FastBuildSuggestion.getInstance()
      .displayNotification(BlazeCommandRunConfigurationRunner.getConfiguration(env));
  if (!BlazeCommandRunConfigurationRunner.isDebugging(env)
      || BlazeCommandName.BUILD.equals(
          BlazeCommandRunConfigurationRunner.getBlazeCommand(env))) {
    return new BlazeCommandRunProfileState(env);
  }
  ClassFileManifestBuilder.initState(env);
  return new BlazeJavaRunProfileState(env);
}
 
Example #27
Source File: MavenDebugConfigurationType.java    From MavenHelper with Apache License 2.0 5 votes vote down vote up
public static void debugConfiguration(Project project, ProgramRunner.Callback callback,
		RunnerAndConfigurationSettings configSettings, Executor executor) {
	ProgramRunner runner = ProgramRunner.findRunnerById(DefaultDebugExecutor.EXECUTOR_ID);
	ExecutionEnvironment env = new ExecutionEnvironment(executor, runner, configSettings, project);

	try {
		runner.execute(env, callback);
	} catch (ExecutionException e) {
		MavenUtil.showError(project, "Failed to execute Maven goal", e);
	}
}
 
Example #28
Source File: HaskellTestRunConfiguration.java    From intellij-haskforce with Apache License 2.0 5 votes vote down vote up
@Nullable
@Override
public RunProfileState getState(@NotNull Executor executor, @NotNull ExecutionEnvironment executionEnvironment) throws ExecutionException {
    // TODO: How do we integrate with the test output UI?

    // Running the tests should automatically enable tests in the build settings.
    HaskellBuildSettings.getInstance(getProject()).setEnableTests(true);
    return new HaskellTestCommandLineState(executionEnvironment, this);
}
 
Example #29
Source File: BlazeTestConsoleProperties.java    From intellij with Apache License 2.0 5 votes vote down vote up
public BlazeTestConsoleProperties(
    BlazeCommandRunConfiguration runConfiguration,
    Executor executor,
    BlazeTestUiSession testUiSession) {
  super(runConfiguration, SmRunnerUtils.BLAZE_FRAMEWORK, executor);
  this.runConfiguration = runConfiguration;
  this.testUiSession = testUiSession;
}
 
Example #30
Source File: HaxeDebugRunner.java    From intellij-haxe with Apache License 2.0 5 votes vote down vote up
private RunContentDescriptor runFlash(final Module module,
                                      final HaxeModuleSettings settings,
                                      final ExecutionEnvironment env,
                                      final Executor executor,
                                      final String launchPath)
  throws ExecutionException {
  final IdeaPluginDescriptor plugin =
    PluginManager.getPlugin(PluginId.getId("com.intellij.flex"));
  if (plugin == null) {
    throw new ExecutionException
      (HaxeBundle.message("install.flex.plugin"));
  }
  if (!plugin.isEnabled()) {
    throw new ExecutionException
      (HaxeBundle.message("enable.flex.plugin"));
  }

  String flexSdkName = settings.getFlexSdkName();
  if (StringUtil.isEmpty(flexSdkName)) {
    throw new ExecutionException
      (HaxeBundle.message("flex.sdk.not.specified"));
  }

  if (settings.isUseNmmlToBuild()) {
    return HaxeFlashDebuggingUtil.getNMEDescriptor
      (this, module, env, executor, flexSdkName);
  }
  else if (settings.isUseOpenFLToBuild()) {
    return HaxeFlashDebuggingUtil.getOpenFLDescriptor
      (this, module, env, executor, flexSdkName);
  }
  else {
    return HaxeFlashDebuggingUtil.getDescriptor
      (module, env, launchPath, flexSdkName);
  }
}