Search in sources :

Example 11 with Executor

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

the class XDebugSessionTab method attachToSession.

private void attachToSession(@NotNull XDebugSessionImpl session) {
    for (XDebugView view : myViews.values()) {
        attachViewToSession(session, view);
    }
    XDebugTabLayouter layouter = session.getDebugProcess().createTabLayouter();
    Content consoleContent = layouter.registerConsoleContent(myUi, myConsole);
    attachNotificationTo(consoleContent);
    layouter.registerAdditionalContent(myUi);
    RunContentBuilder.addAdditionalConsoleEditorActions(myConsole, consoleContent);
    if (ApplicationManager.getApplication().isUnitTestMode()) {
        return;
    }
    DefaultActionGroup leftToolbar = new DefaultActionGroup();
    final Executor debugExecutor = DefaultDebugExecutor.getDebugExecutorInstance();
    if (myEnvironment != null) {
        leftToolbar.add(ActionManager.getInstance().getAction(IdeActions.ACTION_RERUN));
        List<AnAction> additionalRestartActions = session.getRestartActions();
        if (!additionalRestartActions.isEmpty()) {
            leftToolbar.addAll(additionalRestartActions);
            leftToolbar.addSeparator();
        }
        leftToolbar.addAll(session.getExtraActions());
    }
    leftToolbar.addAll(getCustomizedActionGroup(XDebuggerActions.TOOL_WINDOW_LEFT_TOOLBAR_GROUP));
    for (AnAction action : session.getExtraStopActions()) {
        leftToolbar.add(action, new Constraints(Anchor.AFTER, IdeActions.ACTION_STOP_PROGRAM));
    }
    //group.addSeparator();
    //addAction(group, DebuggerActions.EXPORT_THREADS);
    leftToolbar.addSeparator();
    leftToolbar.add(myUi.getOptions().getLayoutActions());
    final AnAction[] commonSettings = myUi.getOptions().getSettingsActionsList();
    DefaultActionGroup settings = new DefaultActionGroup(ActionsBundle.message("group.XDebugger.settings.text"), true);
    settings.getTemplatePresentation().setIcon(myUi.getOptions().getSettingsActions().getTemplatePresentation().getIcon());
    settings.addAll(commonSettings);
    leftToolbar.add(settings);
    leftToolbar.addSeparator();
    leftToolbar.add(PinToolwindowTabAction.getPinAction());
    leftToolbar.add(new CloseAction(myEnvironment != null ? myEnvironment.getExecutor() : debugExecutor, myRunContentDescriptor, myProject));
    leftToolbar.add(new ContextHelpAction(debugExecutor.getHelpId()));
    DefaultActionGroup topToolbar = new DefaultActionGroup();
    topToolbar.addAll(getCustomizedActionGroup(XDebuggerActions.TOOL_WINDOW_TOP_TOOLBAR_GROUP));
    session.getDebugProcess().registerAdditionalActions(leftToolbar, topToolbar, settings);
    myUi.getOptions().setLeftToolbar(leftToolbar, ActionPlaces.DEBUGGER_TOOLBAR);
    myUi.getOptions().setTopToolbar(topToolbar, ActionPlaces.DEBUGGER_TOOLBAR);
    if (myEnvironment != null) {
        initLogConsoles(myEnvironment.getRunProfile(), myRunContentDescriptor, myConsole);
    }
}
Also used : DefaultDebugExecutor(com.intellij.execution.executors.DefaultDebugExecutor) Executor(com.intellij.execution.Executor) Content(com.intellij.ui.content.Content) XDebugTabLayouter(com.intellij.xdebugger.ui.XDebugTabLayouter) CloseAction(com.intellij.execution.ui.actions.CloseAction) ContextHelpAction(com.intellij.ide.actions.ContextHelpAction)

Example 12 with Executor

use of com.intellij.execution.Executor in project android by JetBrains.

the class HotswapAction method doPerform.

@Override
protected void doPerform(@NotNull AnActionEvent e, @NotNull Project project) {
    RunnerAndConfigurationSettings settings = RunManager.getInstance(project).getSelectedConfiguration();
    if (settings == null) {
        InstantRunManager.LOG.warn("Hotswap Action could not locate current run config settings");
        return;
    }
    AndroidSessionInfo session = getAndroidSessionInfo(project, settings);
    if (session == null) {
        InstantRunManager.LOG.warn("Hotswap Action could not locate an existing session for selected run config.");
        return;
    }
    Executor executor = getExecutor(session.getExecutorId());
    if (executor == null) {
        InstantRunManager.LOG.warn("Hotswap Action could not identify executor");
        return;
    }
    ExecutionEnvironmentBuilder builder = ExecutionEnvironmentBuilder.createOrNull(executor, settings);
    if (builder == null) {
        InstantRunManager.LOG.warn("Hotswap Action could not construct an env");
        return;
    }
    ExecutionEnvironment env = builder.activeTarget().dataContext(e.getDataContext()).build();
    InstantRunUtils.setInvokedViaHotswapAction(env, true);
    InstantRunManager.LOG.info("Invoking hotswap launch");
    ProgramRunnerUtil.executeConfiguration(env, false, true);
}
Also used : ExecutionEnvironment(com.intellij.execution.runners.ExecutionEnvironment) Executor(com.intellij.execution.Executor) AndroidSessionInfo(com.android.tools.idea.run.AndroidSessionInfo) RunnerAndConfigurationSettings(com.intellij.execution.RunnerAndConfigurationSettings) ExecutionEnvironmentBuilder(com.intellij.execution.runners.ExecutionEnvironmentBuilder)

Example 13 with Executor

use of com.intellij.execution.Executor in project android by JetBrains.

the class AndroidDebuggerImplBase method activateDebugSessionWindow.

protected static boolean activateDebugSessionWindow(@NotNull Project project, @NotNull RunContentDescriptor descriptor) {
    final ProcessHandler processHandler = descriptor.getProcessHandler();
    final Content content = descriptor.getAttachedContent();
    if (processHandler == null || content == null) {
        return false;
    }
    final Executor executor = DefaultDebugExecutor.getDebugExecutorInstance();
    if (processHandler.isProcessTerminated()) {
        ExecutionManager.getInstance(project).getContentManager().removeRunContent(executor, descriptor);
        return false;
    }
    content.getManager().setSelectedContent(content);
    ToolWindow window = ToolWindowManager.getInstance(project).getToolWindow(executor.getToolWindowId());
    window.activate(null, false, true);
    return true;
}
Also used : ToolWindow(com.intellij.openapi.wm.ToolWindow) DefaultDebugExecutor(com.intellij.execution.executors.DefaultDebugExecutor) Executor(com.intellij.execution.Executor) Content(com.intellij.ui.content.Content) ProcessHandler(com.intellij.execution.process.ProcessHandler)

Example 14 with Executor

use of com.intellij.execution.Executor in project buck by facebook.

the class TestExecutionState method attachDebugger.

private void attachDebugger(String title, String port) {
    final RemoteConnection remoteConnection = new RemoteConnection(/* useSockets */
    true, "localhost", port, /* serverMode */
    false);
    final RemoteStateState state = new RemoteStateState(mProject, remoteConnection);
    final String name = title + " debugger (" + port + ")";
    final ConfigurationFactory cfgFactory = ConfigurationTypeUtil.findConfigurationType("Remote").getConfigurationFactories()[0];
    RunnerAndConfigurationSettings runSettings = RunManager.getInstance(mProject).createRunConfiguration(name, cfgFactory);
    final Executor debugExecutor = DefaultDebugExecutor.getDebugExecutorInstance();
    final ExecutionEnvironment env = new ExecutionEnvironmentBuilder(mProject, debugExecutor).runProfile(runSettings.getConfiguration()).build();
    final int pollTimeout = 3000;
    final DebugEnvironment environment = new DefaultDebugEnvironment(env, state, remoteConnection, pollTimeout);
    ApplicationManager.getApplication().invokeLater(() -> {
        try {
            final DebuggerSession debuggerSession = DebuggerManagerEx.getInstanceEx(mProject).attachVirtualMachine(environment);
            if (debuggerSession == null) {
                return;
            }
            XDebuggerManager.getInstance(mProject).startSessionAndShowTab(name, null, new XDebugProcessStarter() {

                @Override
                @NotNull
                public XDebugProcess start(@NotNull XDebugSession session) {
                    return JavaDebugProcess.create(session, debuggerSession);
                }
            });
        } catch (ExecutionException e) {
            LOG.error("failed to attach to debugger on port " + port + " with polling timeout " + pollTimeout);
        }
    });
}
Also used : XDebugSession(com.intellij.xdebugger.XDebugSession) ExecutionEnvironment(com.intellij.execution.runners.ExecutionEnvironment) XDebugProcess(com.intellij.xdebugger.XDebugProcess) NotNull(org.jetbrains.annotations.NotNull) DefaultDebugEnvironment(com.intellij.debugger.DefaultDebugEnvironment) DefaultDebugExecutor(com.intellij.execution.executors.DefaultDebugExecutor) Executor(com.intellij.execution.Executor) DebuggerSession(com.intellij.debugger.impl.DebuggerSession) XDebugProcessStarter(com.intellij.xdebugger.XDebugProcessStarter) ConfigurationFactory(com.intellij.execution.configurations.ConfigurationFactory) RunnerAndConfigurationSettings(com.intellij.execution.RunnerAndConfigurationSettings) RemoteConnection(com.intellij.execution.configurations.RemoteConnection) RemoteStateState(com.intellij.debugger.engine.RemoteStateState) ExecutionEnvironmentBuilder(com.intellij.execution.runners.ExecutionEnvironmentBuilder) ExecutionException(com.intellij.execution.ExecutionException) DefaultDebugEnvironment(com.intellij.debugger.DefaultDebugEnvironment) DebugEnvironment(com.intellij.debugger.DebugEnvironment)

Example 15 with Executor

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

the class GoEventsConverterTestCase method doTest.

protected void doTest() {
    Executor executor = new DefaultRunExecutor();
    GoTestRunConfiguration runConfig = new GoTestRunConfiguration(myFixture.getProject(), "", GoTestRunConfigurationType.getInstance());
    runConfig.setTestFramework(getTestFramework());
    GoTestConsoleProperties consoleProperties = new GoTestConsoleProperties(runConfig, executor);
    GoTestEventsConverterBase converter = (GoTestEventsConverterBase) consoleProperties.createTestEventsConverter("gotest", consoleProperties);
    LoggingServiceMessageVisitor serviceMessageVisitor = new LoggingServiceMessageVisitor();
    try {
        for (String line : FileUtil.loadLines(new File(getTestDataPath(), getTestName(true) + ".txt"), CharsetToolkit.UTF8)) {
            converter.processServiceMessages(line + "\n", ProcessOutputTypes.STDOUT, serviceMessageVisitor);
        }
    } catch (IOException | ParseException e) {
        throw new RuntimeException(e);
    }
    ((OutputToGeneralTestEventsConverter) converter).flushBufferBeforeTerminating();
    Disposer.dispose((OutputToGeneralTestEventsConverter) converter);
    assertSameLinesWithFile(getTestDataPath() + "/" + getTestName(true) + "-expected.txt", serviceMessageVisitor.getLog());
}
Also used : OutputToGeneralTestEventsConverter(com.intellij.execution.testframework.sm.runner.OutputToGeneralTestEventsConverter) IOException(java.io.IOException) Executor(com.intellij.execution.Executor) DefaultRunExecutor(com.intellij.execution.executors.DefaultRunExecutor) ParseException(java.text.ParseException) File(java.io.File) DefaultRunExecutor(com.intellij.execution.executors.DefaultRunExecutor)

Aggregations

Executor (com.intellij.execution.Executor)34 DefaultRunExecutor (com.intellij.execution.executors.DefaultRunExecutor)15 NotNull (org.jetbrains.annotations.NotNull)14 DefaultDebugExecutor (com.intellij.execution.executors.DefaultDebugExecutor)9 ProcessHandler (com.intellij.execution.process.ProcessHandler)9 RunContentDescriptor (com.intellij.execution.ui.RunContentDescriptor)9 Project (com.intellij.openapi.project.Project)9 ProgramRunner (com.intellij.execution.runners.ProgramRunner)8 ExecutionEnvironment (com.intellij.execution.runners.ExecutionEnvironment)7 RunnerAndConfigurationSettings (com.intellij.execution.RunnerAndConfigurationSettings)4 ConsoleView (com.intellij.execution.ui.ConsoleView)4 CloseAction (com.intellij.execution.ui.actions.CloseAction)4 Module (com.intellij.openapi.module.Module)4 File (java.io.File)4 DefaultExecutionResult (com.intellij.execution.DefaultExecutionResult)3 ExecutionException (com.intellij.execution.ExecutionException)3 GeneralCommandLine (com.intellij.execution.configurations.GeneralCommandLine)3 OSProcessHandler (com.intellij.execution.process.OSProcessHandler)3 ExecutionEnvironmentBuilder (com.intellij.execution.runners.ExecutionEnvironmentBuilder)3 AbstractTestProxy (com.intellij.execution.testframework.AbstractTestProxy)3