Java Code Examples for com.intellij.execution.Executor

The following are top voted examples for showing how to use com.intellij.execution.Executor. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: react-native-console   File: RunnerUtil.java   View source code 6 votes vote down vote up
public static final ConsoleView showHelperProcessRunContent(String header, OSProcessHandler runHandler, Project project, Executor defaultExecutor) {
        ProcessTerminatedListener.attach(runHandler);

        ConsoleViewImpl consoleView = new ConsoleViewImpl(project, true);
        DefaultActionGroup toolbarActions = new DefaultActionGroup();

        JPanel panel = new JPanel((LayoutManager) new BorderLayout());
        panel.add((Component) consoleView.getComponent(), "Center");
        ActionToolbar toolbar = ActionManager.getInstance().createActionToolbar("unknown", (ActionGroup) toolbarActions, false);
        toolbar.setTargetComponent(consoleView.getComponent());
        panel.add((Component) toolbar.getComponent(), "West");

        RunContentDescriptor runDescriptor = new RunContentDescriptor((ExecutionConsole) consoleView,
                (ProcessHandler) runHandler, (JComponent) panel, header, AllIcons.RunConfigurations.Application);
        AnAction[]
                consoleActions = consoleView.createConsoleActions();
        toolbarActions.addAll((AnAction[]) Arrays.copyOf(consoleActions, consoleActions.length));
        toolbarActions.add((AnAction) new StopProcessAction("Stop process", "Stop process", (ProcessHandler) runHandler));
        toolbarActions.add((AnAction) new CloseAction(defaultExecutor, runDescriptor, project));

        consoleView.attachToProcess((ProcessHandler) runHandler);
//        ExecutionManager.getInstance(environment.getProject()).getContentManager().showRunContent(environment.getExecutor(), runDescriptor);
        showConsole(project, defaultExecutor, runDescriptor);
        return (ConsoleView) consoleView;
    }
 
Example 2
Project: intellij   File: BlazeAndroidTestRunConfigurationHandler.java   View source code 6 votes vote down vote up
@Override
public BlazeCommandRunConfigurationRunner createRunner(
    Executor executor, ExecutionEnvironment environment) throws ExecutionException {
  Project project = environment.getProject();

  Module module = getModule();
  AndroidFacet facet = module != null ? AndroidFacet.getInstance(module) : null;
  ProjectViewSet projectViewSet = ProjectViewManager.getInstance(project).getProjectViewSet();
  BlazeAndroidRunConfigurationValidationUtil.validateExecution(module, facet, projectViewSet);

  ImmutableList<String> blazeFlags =
      configState
          .getCommonState()
          .getExpandedBuildFlags(project, projectViewSet, BlazeCommandName.TEST);
  ImmutableList<String> exeFlags =
      ImmutableList.copyOf(configState.getCommonState().getExeFlagsState().getExpandedFlags());
  BlazeAndroidRunContext runContext =
      createRunContext(project, facet, environment, blazeFlags, exeFlags);

  return new BlazeAndroidRunConfigurationRunner(
      module,
      runContext,
      getCommonState().getDeployTargetManager(),
      getCommonState().getDebuggerManager(),
      configuration.getUniqueID());
}
 
Example 3
Project: intellij-ce-playground   File: TrackCoverageAction.java   View source code 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 4
Project: tomcat-runner   File: TomcatProgramDebugger.java   View source code 6 votes vote down vote up
@Override
@Nullable
protected RunContentDescriptor createContentDescriptor(RunProfileState state, ExecutionEnvironment env)
        throws ExecutionException {
    // Now we figure out if it the Debug button has been hit
    Executor executor = env.getExecutor();
    // If was the debug, then we do some extra magic
    if (executor instanceof DefaultDebugExecutor) {
        // Get hold of the JavaParameters
        JavaCommandLine javaCommandLine = (JavaCommandLine) state;
        JavaParameters javaParameters = javaCommandLine.getJavaParameters();
        // Making the assumption that it's JVM 7 onwards
        javaParameters.getVMParametersList().addParametersString(XDEBUG);
        // Debugger port
        String debuggerPort = DebuggerUtils.getInstance().findAvailableDebugAddress(true);
        String remotePort = JDWP + debuggerPort;
        javaParameters.getVMParametersList().addParametersString(remotePort);
        // Creating a 'Remote' configuration on the fly
        RemoteConnection connection = new RemoteConnection(true, LOCALHOST, debuggerPort, false);
        // Attaches the remote configuration to the VM and then starts it up
        return super.attachVirtualMachine(state, env, connection, true);
    } else {
        // If it was something else then we don't do anything special
        return super.createContentDescriptor(state, env);
    }
}
 
Example 5
Project: tmc-intellij   File: ProjectExecutor.java   View source code 6 votes vote down vote up
public void executeConfiguration(Project project, ModuleBasedConfiguration appCon) {
    if (noProjectsAreOpen()) {
        logger.warn("No open projects found, can't execute the project.");
        return;
    }
    logger.info("Starting to build execution environment.");
    RunManager runManager = RunManager.getInstance(project);
    Executor executor = DefaultRunExecutor.getRunExecutorInstance();
    RunnerAndConfigurationSettingsImpl selectedConfiguration =
            getApplicationRunnerAndConfigurationSettings(runManager, appCon);
    ProgramRunner runner = getRunner(executor, selectedConfiguration);
    logger.info("Creating ExecutionEnvironment.");
    ExecutionEnvironment environment =
            new ExecutionEnvironment(
                    new DefaultRunExecutor(), runner, selectedConfiguration, project);
    try {
        logger.info("Executing project.");
        runner.execute(environment);
    } catch (ExecutionException e1) {
        JavaExecutionUtil.showExecutionErrorMessage(e1, "Error", project);
    }
}
 
Example 6
Project: intellij-ce-playground   File: ResetConfigurationModuleAdapter.java   View source code 6 votes vote down vote up
@Override
protected void hyperlinkActivated(HyperlinkEvent e) {
  final Module moduleByName = ModuleManager.getInstance(myProject).findModuleByName(e.getDescription());
  if (moduleByName != null) {
    myConfiguration.getConfigurationModule().setModule(moduleByName);
    try {
      Executor executor = myIsDebug ? DefaultDebugExecutor.getDebugExecutorInstance()
                                    : DefaultRunExecutor.getRunExecutorInstance();
      ExecutionEnvironmentBuilder.create(myProject, executor, myConfiguration).contentToReuse(null).buildAndExecute();
      Balloon balloon = myToolWindowManager.getToolWindowBalloon(myTestRunDebugId);
      if (balloon != null) {
        balloon.hide();
      }
    }
    catch (ExecutionException e1) {
      LOG.error(e1);
    }
  }
}
 
Example 7
Project: intellij-ce-playground   File: DeployToServerRunConfiguration.java   View source code 6 votes vote down vote up
@Nullable
@Override
public RunProfileState getState(@NotNull Executor executor, @NotNull ExecutionEnvironment env) throws ExecutionException {
  String serverName = getServerName();
  if (serverName == null) {
    throw new ExecutionException("Server is not specified");
  }

  RemoteServer<S> server = findServer();
  if (server == null) {
    throw new ExecutionException("Server '" + serverName + " not found");
  }

  if (myDeploymentSource == null) {
    throw new ExecutionException("Deployment is not selected");
  }

  return new DeployToServerState(server, myDeploymentSource, myDeploymentConfiguration, env);
}
 
Example 8
Project: intellij-ce-playground   File: DeployToServerState.java   View source code 6 votes vote down vote up
@Nullable
@Override
public ExecutionResult execute(Executor executor, @NotNull ProgramRunner runner) throws ExecutionException {
  final ServerConnection connection = ServerConnectionManager.getInstance().getOrCreateConnection(myServer);
  final Project project = myEnvironment.getProject();
  RemoteServersView.getInstance(project).showServerConnection(connection);

  final DebugConnector<?,?> debugConnector;
  if (DefaultDebugExecutor.getDebugExecutorInstance().equals(executor)) {
    debugConnector = myServer.getType().createDebugConnector();
  }
  else {
    debugConnector = null;
  }
  connection.deploy(new DeploymentTaskImpl(mySource, myConfiguration, project, debugConnector, myEnvironment),
                    new ParameterizedRunnable<String>() {
                      @Override
                      public void run(String s) {
                        RemoteServersView.getInstance(project).showDeployment(connection, s);
                      }
                    });
  return null;
}
 
Example 9
Project: intellij-ce-playground   File: PythonTestCommandLineStateBase.java   View source code 6 votes vote down vote up
@Override
public ExecutionResult execute(Executor executor, CommandLinePatcher... patchers) throws ExecutionException {
  final ProcessHandler processHandler = startProcess(patchers);
  final ConsoleView console = createAndAttachConsole(myConfiguration.getProject(), processHandler, executor);

  List<AnAction> actions = Lists
    .newArrayList(createActions(console, processHandler));

  DefaultExecutionResult executionResult =
    new DefaultExecutionResult(console, processHandler, actions.toArray(new AnAction[actions.size()]));

  PyRerunFailedTestsAction rerunFailedTestsAction = new PyRerunFailedTestsAction(console);
  if (console instanceof SMTRunnerConsoleView) {
    rerunFailedTestsAction.init(((BaseTestsOutputConsoleView)console).getProperties());
    rerunFailedTestsAction.setModelProvider(new Getter<TestFrameworkRunningModel>() {
    @Override
    public TestFrameworkRunningModel get() {
      return ((SMTRunnerConsoleView)console).getResultsViewer();
    }
  });
  }

  executionResult.setRestartActions(rerunFailedTestsAction, new ToggleAutoTestAction());
  return executionResult;
}
 
Example 10
Project: intellij-ce-playground   File: RemoteExternalSystemCommunicationManager.java   View source code 6 votes vote down vote up
public RemoteExternalSystemCommunicationManager(@NotNull 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(configuration);
    }
  };

  ShutDownTracker.getInstance().registerShutdownTask(new Runnable() {
    public void run() {
      shutdown(false);
    }
  });
}
 
Example 11
Project: intellij-ce-playground   File: PyRerunFailedTestsAction.java   View source code 6 votes vote down vote up
@Nullable
@Override
public RunProfileState getState(@NotNull Executor executor, @NotNull ExecutionEnvironment env) throws ExecutionException {
  final AbstractPythonRunConfiguration configuration = ((AbstractPythonRunConfiguration)getPeer());

  // If configuration wants to take care about rerun itself
  if (configuration instanceof TestRunConfigurationReRunResponsible) {
    // TODO: Extract method
    final Set<PsiElement> failedTestElements = new HashSet<PsiElement>();
    for (final AbstractTestProxy proxy : getFailedTests(getProject())) {
      final Location<?> location = proxy.getLocation(getProject(), GlobalSearchScope.allScope(getProject()));
      if (location != null) {
        failedTestElements.add(location.getPsiElement());
      }
    }
    return ((TestRunConfigurationReRunResponsible)configuration).rerunTests(executor, env, failedTestElements);
  }
  return new FailedPythonTestCommandLineStateBase(configuration, env,
                                                  (PythonTestCommandLineStateBase)configuration.getState(executor, env));
}
 
Example 12
Project: intellij   File: SmRunnerUtils.java   View source code 6 votes vote down vote up
public static SMTRunnerConsoleView getConsoleView(
    Project project,
    BlazeCommandRunConfiguration configuration,
    Executor executor,
    BlazeTestUiSession testUiSession) {
  SMTRunnerConsoleProperties properties =
      new BlazeTestConsoleProperties(configuration, executor, testUiSession);
  SMTRunnerConsoleView console =
      (SMTRunnerConsoleView)
          SMTestRunnerConnectionUtil.createConsole(BLAZE_FRAMEWORK, properties);
  Disposer.register(project, console);
  console
      .getResultsViewer()
      .getTreeView()
      .getSelectionModel()
      .setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION);
  return console;
}
 
Example 13
Project: intellij-ce-playground   File: ExecutorAction.java   View source code 6 votes vote down vote up
private String getActionName(DataContext dataContext, @NotNull Executor executor) {
  final ConfigurationContext context = ConfigurationContext.getFromContext(dataContext);
  List<RunConfigurationProducer<?>> producers = RunConfigurationProducer.getProducers(context.getProject());
  List<ConfigurationFromContext> list = ContainerUtil.mapNotNull(producers,
                                                                 new Function<RunConfigurationProducer<?>, ConfigurationFromContext>() {
                                                                   @Override
                                                                   public ConfigurationFromContext fun(RunConfigurationProducer<?> producer) {
                                                                     return createConfiguration(producer, context);
                                                                   }
                                                                 }
  );
  if (list.isEmpty()) return null;
  ConfigurationFromContext configuration = list.get(myOrder < list.size() ? myOrder : 0);
  String actionName = BaseRunConfigurationAction.suggestRunActionName((LocatableConfiguration)configuration.getConfiguration());
  return executor.getStartActionText(actionName);
}
 
Example 14
Project: intellij-ce-playground   File: RunIdeConsoleAction.java   View source code 6 votes vote down vote up
@NotNull
private static RunContentDescriptor createConsoleView(@NotNull Project project, @NotNull PsiFile psiFile) {
  ConsoleView consoleView = TextConsoleBuilderFactory.getInstance().createBuilder(project).getConsole();

  DefaultActionGroup toolbarActions = new DefaultActionGroup();
  JComponent panel = new JPanel(new BorderLayout());
  panel.add(consoleView.getComponent(), BorderLayout.CENTER);
  ActionToolbar toolbar = ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, toolbarActions, false);
  toolbar.setTargetComponent(consoleView.getComponent());
  panel.add(toolbar.getComponent(), BorderLayout.WEST);

  final RunContentDescriptor descriptor = new RunContentDescriptor(consoleView, null, panel, psiFile.getName()) {
    @Override
    public boolean isContentReuseProhibited() {
      return true;
    }
  };
  Executor executor = DefaultRunExecutor.getRunExecutorInstance();
  toolbarActions.addAll(consoleView.createConsoleActions());
  toolbarActions.add(new CloseAction(executor, descriptor, project));
  ExecutionManager.getInstance(project).getContentManager().showRunContent(executor, descriptor);

  return descriptor;
}
 
Example 15
Project: intellij-ce-playground   File: AntRunProfileState.java   View source code 6 votes vote down vote up
@Nullable
@Override
public ExecutionResult execute(Executor executor, @NotNull ProgramRunner runner) throws ExecutionException {
  RunProfile profile = myEnvironment.getRunProfile();
  if (profile instanceof AntRunConfiguration) {
    AntRunConfiguration antRunConfiguration = (AntRunConfiguration)profile;
    AntBuildTarget target = antRunConfiguration.getTarget();
    if (target == null) return null;
    ProcessHandler processHandler = ExecutionHandler
      .executeRunConfiguration(antRunConfiguration, myEnvironment.getDataContext(), new ArrayList<BuildFileProperty>(),
                               new AntBuildListener() {
                                 @Override
                                 public void buildFinished(int state, int errorCount) {

                                 }
                               });
    if (processHandler == null) return null;
    return new DefaultExecutionResult(null, processHandler);
  }
  return null;
}
 
Example 16
Project: intellij-ce-playground   File: SearchEverywhereAction.java   View source code 6 votes vote down vote up
@Nullable
private ChooseRunConfigurationPopup.ItemWrapper getRunConfigurationByName(String name) {
  final ChooseRunConfigurationPopup.ItemWrapper[] wrappers =
    ChooseRunConfigurationPopup.createSettingsList(project, new ExecutorProvider() {
      @Override
      public Executor getExecutor() {
        return ExecutorRegistry.getInstance().getExecutorById(ToolWindowId.DEBUG);
      }
    }, false);

  for (ChooseRunConfigurationPopup.ItemWrapper wrapper : wrappers) {
    if (wrapper.getText().equals(name)) {
      return wrapper;
    }
  }
  return null;
}
 
Example 17
Project: intellij-ce-playground   File: PyEduDebugRunner.java   View source code 6 votes vote down vote up
@Override
protected void initSession(XDebugSession session, RunProfileState state, Executor executor) {
  XDebugSessionTab tab = ((XDebugSessionImpl)session).getSessionTab();
  if (tab != null) {
    RunnerLayoutUi ui = tab.getUi();
    ContentManager contentManager = ui.getContentManager();
    Content content = findContent(contentManager, XDebuggerBundle.message("debugger.session.tab.watches.title"));
    if (content != null) {
      contentManager.removeContent(content, true);
    }
    content = findContent(contentManager, XDebuggerBundle.message("debugger.session.tab.console.content.name"));
    if (content != null) {
      contentManager.removeContent(content, true);
    }
    initEduConsole(session, ui);
  }
}
 
Example 18
Project: intellij-ce-playground   File: PyEduDebugRunner.java   View source code 6 votes vote down vote up
private static void patchLeftToolbar(@NotNull XDebugSession session, @NotNull RunnerLayoutUi ui) {
  DefaultActionGroup newLeftToolbar = new DefaultActionGroup();

  DefaultActionGroup firstGroup = new DefaultActionGroup();
  addActionToGroup(firstGroup, XDebuggerActions.RESUME);
  addActionToGroup(firstGroup, IdeActions.ACTION_STOP_PROGRAM);
  newLeftToolbar.addAll(firstGroup);

  newLeftToolbar.addSeparator();

  Executor executor = PyEduDebugExecutor.getInstance();
  newLeftToolbar.add(new CloseAction(executor, session.getRunContentDescriptor(), session.getProject()));
  //TODO: return proper helpID
  newLeftToolbar.add(new ContextHelpAction(executor.getHelpId()));

  ui.getOptions().setLeftToolbar(newLeftToolbar, ActionPlaces.DEBUGGER_TOOLBAR);
}
 
Example 19
Project: intellij-ce-playground   File: PyCharmEduInitialConfigurator.java   View source code 6 votes vote down vote up
private static void patchProjectAreaExtensions(@NotNull final Project project) {
  Executor debugExecutor = DefaultDebugExecutor.getDebugExecutorInstance();
  unregisterAction(debugExecutor.getId(), ExecutorRegistryImpl.RUNNERS_GROUP);
  unregisterAction(debugExecutor.getContextActionId(), ExecutorRegistryImpl.RUN_CONTEXT_GROUP);

  ExtensionsArea projectArea = Extensions.getArea(project);

  for (SelectInTarget target : Extensions.getExtensions(SelectInTarget.EP_NAME, project)) {
    if (ToolWindowId.FAVORITES_VIEW.equals(target.getToolWindowId()) ||
        ToolWindowId.STRUCTURE_VIEW.equals(target.getToolWindowId())) {
      projectArea.getExtensionPoint(SelectInTarget.EP_NAME).unregisterExtension(target);
    }
  }

  for (AbstractProjectViewPane pane : Extensions.getExtensions(AbstractProjectViewPane.EP_NAME, project)) {
    if (pane.getId().equals(ScopeViewPane.ID)) {
      Disposer.dispose(pane);
      projectArea.getExtensionPoint(AbstractProjectViewPane.EP_NAME).unregisterExtension(pane);
    }
  }
}
 
Example 20
Project: react-native-console   File: FreeRunConfiguration.java   View source code 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 21
Project: mybatis-log-plugin   File: TailContentExecutor.java   View source code 5 votes vote down vote up
@NotNull
private ActionGroup createActionToolbar(JComponent consolePanel, ConsoleView consoleView, @NotNull final RunnerLayoutUi myUi, RunContentDescriptor contentDescriptor, Executor runExecutorInstance) {
    final DefaultActionGroup actionGroup = new DefaultActionGroup();
    actionGroup.add(new FilterAction());
    actionGroup.add(new RerunAction(consolePanel, consoleView));
    actionGroup.add(new StopAction());
    actionGroup.add(new FormatAction());
    actionGroup.add(new MyCloseAction(runExecutorInstance, contentDescriptor, myProject));
    return actionGroup;
}
 
Example 22
Project: Goal-Intellij-Plugin   File: GoalDebugConfiguration.java   View source code 5 votes vote down vote up
@Nullable
@Override
public RunProfileState getState(@NotNull Executor executor, @NotNull ExecutionEnvironment environment) throws ExecutionException {


    final CommandLineState state = new CommandLineState(environment) {
        @NotNull
        @Override
        protected ProcessHandler startProcess() throws ExecutionException {
            GoalRuntime runtime = GoalRuntime.instance;
            System.out.println("runtime is created");

            final GeneralCommandLine line = new GeneralCommandLine();
            line.setRedirectErrorStream(true);
            line.setExePath("java");
            line.addParameters("-cp","-debug", runtime.getRuntimePath().toString(),
                    "goal.tools.Run",
                    GoalDebugConfiguration.this.runFilePath);

            System.out.println("command: " + line.getCommandLineString());


            final Process process = line.createProcess();
            return new OSProcessHandler(process, line.getCommandLineString());
        }


    };

    return state;
}
 
Example 23
Project: Goal-Intellij-Plugin   File: GoalRunConfiguration.java   View source code 5 votes vote down vote up
@Nullable
@Override
public RunProfileState getState(@NotNull Executor executor,
                                @NotNull ExecutionEnvironment environment)
        throws ExecutionException {
    final CommandLineState state = new CommandLineState(environment) {
        @NotNull
        @Override
        protected ProcessHandler startProcess() throws ExecutionException {
            final GoalRuntime runtime = GoalRuntime.getInstance();

            //TODO: MAke sure that the preferences are used when running goal.
            //final Path preferences = GoalRunConfiguration.this.writePreferences();

            final GeneralCommandLine line = new GeneralCommandLine();
            line.setRedirectErrorStream(true);
            line.setExePath("java");
            line.addParameters(
                    "-cp", runtime.getRuntimePath().toString(),
                    "goal.tools.Run",
                    //preferences.toString(),
                    GoalRunConfiguration.this.runFilePath
            );
            System.out.println("command: " + line.getCommandLineString());


            final Process process = line.createProcess();

            return new OSProcessHandler(process, line.getCommandLineString());
        }
    };

    return state;
}
 
Example 24
Project: lua-for-idea   File: LuaRunConfiguration.java   View source code 5 votes vote down vote up
public RunProfileState getState(@NotNull final Executor executor, @NotNull final ExecutionEnvironment env) throws ExecutionException {
    LuaCommandLineState state = null;

    Sdk sdk = getSdk();
    final boolean isDebugger = executor.getId().equals(DefaultDebugExecutor.EXECUTOR_ID);

    if(sdk != null && sdk.getSdkType() instanceof LuaSdkType) {
        if (sdk.getName().equals(KahluaSdk.NAME)) {
            state = new KahluaCommandLineState(this, env);
        }
        else if (sdk.getName().equals(LuaJSdk.NAME)) {
            state = new LuaJExternalCommandLineState(this, env);
        }

        if ((state != null) && isDebugger)
            throw new ExecutionException("Debugging not supported for SDK " + sdk.getName() + ". Please configure a real Lua SDK.");
    }

    if (state == null) {
        if (isDebugger)
            state = new LuaDebugCommandlineState(this, env);
        else
            state = new LuaCommandLineState(this, env);
    }

    TextConsoleBuilder textConsoleBuilder = new LuaTextConsoleBuilder(getProject());
    textConsoleBuilder.addFilter(new LuaLineErrorFilter(getProject()));

    state.setConsoleBuilder(textConsoleBuilder);
    return state;
}
 
Example 25
Project: intellij-ce-playground   File: AbstractTerminalRunner.java   View source code 5 votes vote down vote up
protected void showConsole(Executor defaultExecutor, @NotNull RunContentDescriptor myDescriptor, final Component toFocus) {
  // Show in run toolwindow
  ExecutionManager.getInstance(myProject).getContentManager().showRunContent(defaultExecutor, myDescriptor);

  // Request focus
  final ToolWindow window = ToolWindowManager.getInstance(myProject).getToolWindow(defaultExecutor.getId());
  window.activate(new Runnable() {
    public void run() {
      IdeFocusManager.getInstance(myProject).requestFocus(toFocus, true);
    }
  });
}
 
Example 26
Project: intellij-ce-playground   File: GradleTestsExecutionConsoleManager.java   View source code 5 votes vote down vote up
@NotNull
@Override
public ExecutionConsole attachExecutionConsole(@NotNull final ExternalSystemTask task,
                                               @NotNull final Project project,
                                               @NotNull final ExternalSystemRunConfiguration configuration,
                                               @NotNull final Executor executor,
                                               @NotNull final ExecutionEnvironment env,
                                               @NotNull final ProcessHandler processHandler) throws ExecutionException {
  final GradleConsoleProperties properties = new GradleConsoleProperties(configuration, executor);
  myExecutionConsole = (SMTRunnerConsoleView)SMTestRunnerConnectionUtil.createAndAttachConsole(
    configuration.getSettings().getExternalSystemId().getReadableName(), processHandler, properties);

  TestTreeRenderer originalRenderer =
    ObjectUtils.tryCast(myExecutionConsole.getResultsViewer().getTreeView().getCellRenderer(), TestTreeRenderer.class);
  if (originalRenderer != null) {
    originalRenderer.setAdditionalRootFormatter(new SMRootTestProxyFormatter() {
      @Override
      public void format(@NotNull SMTestProxy.SMRootTestProxy testProxy, @NotNull TestTreeRenderer renderer) {
        final TestStateInfo.Magnitude magnitude = testProxy.getMagnitudeInfo();
        if (magnitude == TestStateInfo.Magnitude.RUNNING_INDEX) {
          renderer.clear();
          renderer.append(GradleBundle.message(
                            "gradle.test.runner.ui.tests.tree.presentation.labels.waiting.tests"),
                          SimpleTextAttributes.REGULAR_ATTRIBUTES
          );
        }
        else if (!testProxy.isInProgress() && testProxy.isEmptySuite()) {
          renderer.clear();
          renderer.append(GradleBundle.message(
                            "gradle.test.runner.ui.tests.tree.presentation.labels.no.tests.were.found"),
                          SimpleTextAttributes.REGULAR_ATTRIBUTES
          );
        }
      }
    });
  }
  return myExecutionConsole;
}
 
Example 27
Project: intellij-ce-playground   File: DefaultDebugUIEnvironment.java   View source code 5 votes vote down vote up
@Override
public void initActions(RunContentDescriptor content, DefaultActionGroup actionGroup) {
  Executor executor = myExecutionEnvironment.getExecutor();
  actionGroup.add(ActionManager.getInstance().getAction(IdeActions.ACTION_RERUN), Constraints.FIRST);

  actionGroup.add(new CloseAction(executor, content, myExecutionEnvironment.getProject()));
  actionGroup.add(new ContextHelpAction(executor.getHelpId()));
}
 
Example 28
Project: intellij   File: AndroidTestConsoleProvider.java   View source code 5 votes vote down vote up
private ConsoleView createBlazeTestConsole(Executor executor) {
  if (testUiSession == null || isDebugging(executor)) {
    // SM runner console not yet supported when debugging, because we're calling this once per
    // test case (see ConnectBlazeTestDebuggerTask::setUpForReattachingDebugger)
    return TextConsoleBuilderFactory.getInstance().createBuilder(project).getConsole();
  }
  return SmRunnerUtils.getConsoleView(project, runConfiguration, executor, testUiSession);
}
 
Example 29
Project: intellij-ce-playground   File: DefaultGroovyScriptRunner.java   View source code 5 votes vote down vote up
@Override
public boolean ensureRunnerConfigured(@Nullable Module module, RunProfile profile, Executor executor, final Project project) throws ExecutionException {
  if (module == null) {
    throw new ExecutionException("Module is not specified");
  }

  if (LibrariesUtil.getGroovyHomePath(module) == null) {
    ExecutionUtil.handleExecutionError(project, executor.getToolWindowId(), profile, new ExecutionException("Groovy is not configured"));
    ModulesConfigurator.showDialog(module.getProject(), module.getName(), ClasspathEditor.NAME);
    return false;
  }
  return true;
}
 
Example 30
Project: intellij-ce-playground   File: JavaScratchConfiguration.java   View source code 5 votes vote down vote up
@Override
public RunProfileState getState(@NotNull Executor executor, @NotNull ExecutionEnvironment env) throws ExecutionException {
  final JavaCommandLineState state = new JavaApplicationCommandLineState<JavaScratchConfiguration>(this, env) {
    @Override
    protected void setupJavaParameters(JavaParameters params) throws ExecutionException {
      super.setupJavaParameters(params);
      final File scrachesOutput = JavaScratchCompilationSupport.getScratchOutputDirectory(getProject());
      if (scrachesOutput != null) {
        params.getClassPath().add(scrachesOutput);
      }
    }

    @NotNull
    @Override
    protected OSProcessHandler startProcess() throws ExecutionException {
      final OSProcessHandler handler = super.startProcess();
      if (getRunnerSettings() instanceof DebuggingRunnerData) {
        final VirtualFile vFile = getConfiguration().getScratchVirtualFile();
        if (vFile != null) {
          DebuggerManager.getInstance(getProject()).addDebugProcessListener(handler, new DebugProcessAdapter() {
            @Override
            public void processAttached(DebugProcess process) {
              if (vFile.isValid()) {
                process.appendPositionManager(new JavaScratchPositionManager((DebugProcessImpl)process, vFile));
              }
              process.removeDebugProcessListener(this);
            }
          });
        }
      }
      return handler;
    }
  };
  state.setConsoleBuilder(TextConsoleBuilderFactory.getInstance().createBuilder(getProject(), getConfigurationModule().getSearchScope()));
  return state;
}
 
Example 31
Project: intellij-ce-playground   File: RemoteConfiguration.java   View source code 5 votes vote down vote up
@Override
public RunProfileState getState(@NotNull final Executor executor, @NotNull final ExecutionEnvironment env) throws ExecutionException {
  final GenericDebuggerRunnerSettings debuggerSettings = (GenericDebuggerRunnerSettings)env.getRunnerSettings();
  if (debuggerSettings != null) {
    // sync self state with execution environment's state if available
    debuggerSettings.LOCAL = false;
    debuggerSettings.setDebugPort(USE_SOCKET_TRANSPORT ? PORT : SHMEM_ADDRESS);
    debuggerSettings.setTransport(USE_SOCKET_TRANSPORT ? DebuggerSettings.SOCKET_TRANSPORT : DebuggerSettings.SHMEM_TRANSPORT);
  }
  return new RemoteStateState(getProject(), createRemoteConnection());
}
 
Example 32
Project: intellij   File: BlazeRerunFailedTestsAction.java   View source code 5 votes vote down vote up
@Nullable
@Override
public RunProfileState getState(Executor executor, ExecutionEnvironment environment)
    throws ExecutionException {
  BlazeCommandRunConfigurationCommonState handlerState =
      configuration.getHandlerStateIfType(BlazeCommandRunConfigurationCommonState.class);
  if (handlerState == null
      || !BlazeCommandName.TEST.equals(handlerState.getCommandState().getCommand())) {
    return null;
  }
  Project project = getProject();
  List<Location<?>> locations =
      getFailedTests(project)
          .stream()
          .filter(AbstractTestProxy::isLeaf)
          .map((test) -> toLocation(project, test))
          .filter(Objects::nonNull)
          .collect(Collectors.toList());
  String testFilter = eventsHandler.getTestFilter(getProject(), locations);
  if (testFilter == null) {
    return null;
  }
  List<String> blazeFlags =
      setTestFilter(handlerState.getBlazeFlagsState().getRawFlags(), testFilter);
  handlerState.getBlazeFlagsState().setRawFlags(blazeFlags);
  return configuration.getState(executor, environment);
}
 
Example 33
Project: intellij-ce-playground   File: PyTestCommandLineState.java   View source code 5 votes vote down vote up
@NotNull
protected ConsoleView createAndAttachConsole(Project project, ProcessHandler processHandler, Executor executor)
  throws ExecutionException {
  final ConsoleView consoleView = super.createAndAttachConsole(project, processHandler, executor);
  addTracebackFilter(project, consoleView, processHandler);
  return consoleView;
}
 
Example 34
Project: intellij-ce-playground   File: SMTestRunnerConnectionUtil.java   View source code 5 votes vote down vote up
/** @deprecated use {@link #createAndAttachConsole(String, ProcessHandler, TestConsoleProperties)} (to be removed in IDEA 16) */
@SuppressWarnings({"unused", "deprecation"})
public static ConsoleView createAndAttachConsole(@NotNull String testFrameworkName,
                                                 @NotNull ProcessHandler processHandler,
                                                 @NotNull CommandLineState commandLineState,
                                                 @NotNull ModuleRunConfiguration config,
                                                 @NotNull Executor executor) throws ExecutionException {
  TestConsoleProperties consoleProperties = new SMTRunnerConsoleProperties(config, testFrameworkName, executor);
  return createAndAttachConsole(testFrameworkName, processHandler, consoleProperties, commandLineState.getEnvironment());
}
 
Example 35
Project: intellij-ce-playground   File: SMTestRunnerConnectionUtil.java   View source code 5 votes vote down vote up
/** @deprecated use {@link #createConsole(String, TestConsoleProperties)} (to be removed in IDEA 16) */
@SuppressWarnings({"unused", "deprecation"})
public static ConsoleView createConsole(@NotNull String testFrameworkName,
                                        @NotNull CommandLineState commandLineState,
                                        @NotNull ModuleRunConfiguration config,
                                        @NotNull Executor executor) throws ExecutionException {
  TestConsoleProperties consoleProperties = new SMTRunnerConsoleProperties(config, testFrameworkName, executor);
  return createConsole(testFrameworkName, consoleProperties, commandLineState.getEnvironment());
}
 
Example 36
Project: intellij-ce-playground   File: SMTRunnerConsoleProperties.java   View source code 5 votes vote down vote up
public SMTRunnerConsoleProperties(@NotNull Project project, 
                                  @NotNull RunProfile config,
                                  @NotNull String testFrameworkName, 
                                  @NotNull Executor executor) {
  super(getStorage(testFrameworkName), project, executor);
  myConfiguration = config;
  myTestFrameworkName = testFrameworkName;
  myCustomFilter = new CompositeFilter(project);
}
 
Example 37
Project: intellij-ce-playground   File: PythonCommandLineState.java   View source code 5 votes vote down vote up
public ExecutionResult execute(Executor executor, CommandLinePatcher... patchers) throws ExecutionException {
  final ProcessHandler processHandler = startProcess(patchers);
  final ConsoleView console = createAndAttachConsole(myConfig.getProject(), processHandler, executor);

  List<AnAction> actions = Lists.newArrayList(createActions(console, processHandler));

  return new DefaultExecutionResult(console, processHandler, actions.toArray(new AnAction[actions.size()]));
}
 
Example 38
Project: intellij   File: BlazeAndroidRunConfigurationDeployTargetManager.java   View source code 5 votes vote down vote up
@Nullable
DeployTarget getDeployTarget(
    Executor executor, ExecutionEnvironment env, AndroidFacet facet, int runConfigId)
    throws ExecutionException {
  DeployTargetProvider currentTargetProvider = getCurrentDeployTargetProvider();

  DeployTarget deployTarget;
  if (currentTargetProvider.requiresRuntimePrompt()) {
    deployTarget =
        currentTargetProvider.showPrompt(
            executor,
            env,
            facet,
            getDeviceCount(),
            isAndroidTest,
            deployTargetStates,
            runConfigId,
            (device) -> LaunchCompatibility.YES);
    if (deployTarget == null) {
      return null;
    }
  } else {
    deployTarget = currentTargetProvider.getDeployTarget();
  }

  return deployTarget;
}
 
Example 39
Project: intellij   File: BlazeTestConsoleProperties.java   View source code 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 40
Project: intellij-ce-playground   File: DefaultExternalSystemExecutionConsoleManager.java   View source code 5 votes vote down vote up
@NotNull
@Override
public ExecutionConsole attachExecutionConsole(@NotNull ExternalSystemTask task,
                                               @NotNull Project project,
                                               @NotNull ExternalSystemRunConfiguration configuration,
                                               @NotNull Executor executor,
                                               @NotNull ExecutionEnvironment env,
                                               @NotNull ProcessHandler processHandler) throws ExecutionException {
  myProcessHandler = processHandler;
  ConsoleView executionConsole = new TextConsoleBuilderImpl(project).getConsole();
  executionConsole.attachToProcess(processHandler);
  return executionConsole;
}