com.intellij.execution.executors.DefaultDebugExecutor Java Examples

The following examples show how to use com.intellij.execution.executors.DefaultDebugExecutor. 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: SkylarkDebugRunner.java    From intellij with Apache License 2.0 6 votes vote down vote up
@Override
public boolean canRun(String executorId, RunProfile profile) {
  if (!DefaultDebugExecutor.EXECUTOR_ID.equals(executorId)) {
    return false;
  }
  BlazeCommandRunConfiguration config =
      BlazeCommandRunConfigurationRunner.getBlazeConfig(profile);
  if (config == null || !SkylarkDebuggingUtils.debuggingEnabled(config.getProject())) {
    return false;
  }
  BlazeCommandRunConfigurationCommonState handlerState =
      config.getHandlerStateIfType(BlazeCommandRunConfigurationCommonState.class);
  BlazeCommandName command =
      handlerState != null ? handlerState.getCommandState().getCommand() : null;
  return BlazeCommandName.BUILD.equals(command);
}
 
Example #2
Source File: BlazeGoDebugRunner.java    From intellij with Apache License 2.0 6 votes vote down vote up
@Override
public boolean canRun(String executorId, RunProfile profile) {
  if (!DefaultDebugExecutor.EXECUTOR_ID.equals(executorId)
      || !(profile instanceof BlazeCommandRunConfiguration)) {
    return false;
  }
  BlazeCommandRunConfiguration config = (BlazeCommandRunConfiguration) profile;
  BlazeCommandRunConfigurationCommonState handlerState =
      config.getHandlerStateIfType(BlazeCommandRunConfigurationCommonState.class);
  BlazeCommandName command =
      handlerState != null ? handlerState.getCommandState().getCommand() : null;
  Kind kind = config.getTargetKind();
  return kind != null
      && kind.getLanguageClass().equals(LanguageClass.GO)
      && (kind.getRuleType().equals(RuleType.BINARY) || kind.getRuleType().equals(RuleType.TEST))
      && (BlazeCommandName.TEST.equals(command) || BlazeCommandName.RUN.equals(command));
}
 
Example #3
Source File: DebuggerSessionTabBase.java    From consulo with Apache License 2.0 6 votes vote down vote up
protected void attachNotificationTo(final Content content) {
  if (myConsole instanceof ObservableConsoleView) {
    ObservableConsoleView observable = (ObservableConsoleView)myConsole;
    observable.addChangeListener(types -> {
      if (types.contains(ConsoleViewContentType.ERROR_OUTPUT) || types.contains(ConsoleViewContentType.NORMAL_OUTPUT)) {
        content.fireAlert();
      }
    }, content);
    RunProfile profile = getRunProfile();
    if (profile instanceof RunConfigurationBase && !ApplicationManager.getApplication().isUnitTestMode()) {
      observable.addChangeListener(
              new RunContentBuilder.ConsoleToFrontListener((RunConfigurationBase)profile, myProject, DefaultDebugExecutor.getDebugExecutorInstance(),
                                                           myRunContentDescriptor, myUi), content);
    }
  }
}
 
Example #4
Source File: AppCommandLineState.java    From embeddedlinux-jvmdebugger-intellij with Apache License 2.0 6 votes vote down vote up
/**
 * Closes old session only for debug mode
 *
 * @param project
 * @param parameters
 */
private void closeOldSession(final Project project, EmbeddedLinuxJVMRunConfigurationRunnerParameters parameters) {
    final String configurationName = AppCommandLineState.getRunConfigurationName(parameters.getPort());
    final Collection<RunContentDescriptor> descriptors =
            ExecutionHelper.findRunningConsoleByTitle(project, configurationName::equals);

    if (descriptors.size() > 0) {
        final RunContentDescriptor descriptor = descriptors.iterator().next();
        final ProcessHandler processHandler = descriptor.getProcessHandler();
        final Content content = descriptor.getAttachedContent();

        if (processHandler != null && content != null) {
            final Executor executor = DefaultDebugExecutor.getDebugExecutorInstance();

            if (processHandler.isProcessTerminated()) {
                ExecutionManager.getInstance(project).getContentManager()
                        .removeRunContent(executor, descriptor);
            } else {
                content.getManager().setSelectedContent(content);
                ToolWindow window = ToolWindowManager.getInstance(project).getToolWindow(executor.getToolWindowId());
                window.activate(null, false, true);
            }
        }
    }
}
 
Example #5
Source File: MavenDebugConfigurationType.java    From MavenHelper with Apache License 2.0 5 votes vote down vote up
public static void debugConfiguration(Project project, @NotNull MavenRunnerParameters params,
		@Nullable MavenGeneralSettings settings, @Nullable MavenRunnerSettings runnerSettings,
		@Nullable ProgramRunner.Callback callback) {

	RunnerAndConfigurationSettings configSettings = MavenRunConfigurationType.createRunnerAndConfigurationSettings(
			settings, runnerSettings, params, project);
	final Executor executor = DefaultDebugExecutor.getDebugExecutorInstance();

	debugConfiguration(project, callback, configSettings, executor);
}
 
Example #6
Source File: BlazePyDebugRunner.java    From intellij with Apache License 2.0 5 votes vote down vote up
@Override
public boolean canRun(String executorId, RunProfile profile) {
  if (!DefaultDebugExecutor.EXECUTOR_ID.equals(executorId)
      || !(profile instanceof BlazeCommandRunConfiguration)) {
    return false;
  }
  BlazeCommandRunConfiguration config = (BlazeCommandRunConfiguration) profile;
  BlazeCommandRunConfigurationCommonState handlerState =
      config.getHandlerStateIfType(BlazeCommandRunConfigurationCommonState.class);
  BlazeCommandName command =
      handlerState != null ? handlerState.getCommandState().getCommand() : null;
  return PyDebugUtils.canUsePyDebugger(config.getTargetKind())
      && (BlazeCommandName.TEST.equals(command) || BlazeCommandName.RUN.equals(command));
}
 
Example #7
Source File: QuickRunMavenGoalAction.java    From MavenHelper with Apache License 2.0 5 votes vote down vote up
protected AnAction getRunConfigurationAction(Project project, RunnerAndConfigurationSettings cfg) {
	RunConfigurationAction action = new RunConfigurationAction(DefaultRunExecutor.getRunExecutorInstance(), true, project, cfg);

	return new ActionGroup(action.getTemplatePresentation().getText(), action.getTemplatePresentation().getDescription(), action.getTemplatePresentation().getIcon()) {
		@NotNull
		@Override
		public AnAction[] getChildren(@Nullable AnActionEvent anActionEvent) {
			DebugConfigurationAction debugConfigurationAction = new DebugConfigurationAction(DefaultDebugExecutor.getDebugExecutorInstance(), true, project, cfg);
			debugConfigurationAction.getTemplatePresentation().setText("Debug");
			return new AnAction[]{debugConfigurationAction};
		}

		@Override
		public void actionPerformed(@NotNull AnActionEvent e) {
			action.actionPerformed(e);
		}

		@Override
		public boolean canBePerformed(@NotNull DataContext context) {
			return true;
		}

		@Override
		public boolean isPopup() {
			return true;
		}

	};
}
 
Example #8
Source File: BlazeJavaDebuggerRunner.java    From intellij with Apache License 2.0 5 votes vote down vote up
@Override
public boolean canRun(final String executorId, final RunProfile profile) {
  if (!executorId.equals(DefaultDebugExecutor.EXECUTOR_ID)
      || !(profile instanceof BlazeCommandRunConfiguration)) {
    return false;
  }
  BlazeCommandRunConfiguration configuration = (BlazeCommandRunConfiguration) profile;
  Kind kind = configuration.getTargetKind();
  if (kind == null || !BlazeJavaRunConfigurationHandlerProvider.supportsKind(kind)) {
    return false;
  }
  return canDebug(configuration.getHandler().getCommandName());
}
 
Example #9
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 #10
Source File: BaseSMTRunnerTestCase.java    From consulo with Apache License 2.0 5 votes vote down vote up
protected TestConsoleProperties createConsoleProperties() {
  final RuntimeConfiguration runConfiguration = createRunConfiguration();

  final TestConsoleProperties consoleProperties = new SMTRunnerConsoleProperties(runConfiguration, "SMRunnerTests", DefaultDebugExecutor.getDebugExecutorInstance());
  TestConsoleProperties.HIDE_PASSED_TESTS.set(consoleProperties, false);
  
  return consoleProperties;
}
 
Example #11
Source File: TestsPresentationUtilTest.java    From consulo with Apache License 2.0 5 votes vote down vote up
public MyRenderer(final boolean isPaused,
                  final UITestUtil.FragmentsContainer fragmentsContainer) {
  super(new SMTRunnerConsoleProperties(createRunConfiguration(), "SMRunnerTests", DefaultDebugExecutor.getDebugExecutorInstance()) {
    @Override
    public boolean isPaused() {
      return isPaused;
    }
  });
  myFragmentsContainer = fragmentsContainer;
}
 
Example #12
Source File: BlazeAndroidTestProgramRunner.java    From intellij with Apache License 2.0 5 votes vote down vote up
@Override
public boolean canRun(String executorId, RunProfile profile) {
  BlazeAndroidRunConfigurationHandler handler =
      BlazeAndroidRunConfigurationHandler.getHandlerFrom(profile);
  if (!(handler instanceof BlazeAndroidTestRunConfigurationHandler)) {
    return false;
  }
  if (!(profile instanceof BlazeCommandRunConfiguration)) {
    return false;
  }
  return DefaultRunExecutor.EXECUTOR_ID.equals(executorId)
      || DefaultDebugExecutor.EXECUTOR_ID.equals(executorId);
}
 
Example #13
Source File: BlazeAndroidBinaryProgramRunner.java    From intellij with Apache License 2.0 5 votes vote down vote up
@Override
public boolean canRun(String executorId, RunProfile profile) {
  BlazeAndroidRunConfigurationHandler handler =
      BlazeAndroidRunConfigurationHandler.getHandlerFrom(profile);
  if (!(handler instanceof BlazeAndroidBinaryRunConfigurationHandler)) {
    return false;
  }
  return (DefaultDebugExecutor.EXECUTOR_ID.equals(executorId)
      || DefaultRunExecutor.EXECUTOR_ID.equals(executorId)
      || ProfileRunExecutor.EXECUTOR_ID.equals(executorId));
}
 
Example #14
Source File: FlutterTestRunner.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public boolean canRun(@NotNull String executorId, @NotNull RunProfile profile) {
  if (!DefaultDebugExecutor.EXECUTOR_ID.equals(executorId) || !(profile instanceof TestConfig)) {
    return false;
  }

  final FlutterSdk sdk = FlutterSdk.getFlutterSdk(((TestConfig)profile).getProject());
  if (sdk == null || !sdk.getVersion().flutterTestSupportsMachineMode()) {
    return false;
  }

  final TestConfig config = (TestConfig)profile;
  return config.getFields().getScope() != TestFields.Scope.DIRECTORY;
}
 
Example #15
Source File: DeployToServerState.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 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.computeDeployments(new Runnable() {
    @Override
    public void run() {
      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 #16
Source File: FlutterTestRunner.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public boolean canRun(@NotNull String executorId, @NotNull RunProfile profile) {
  if (!DefaultDebugExecutor.EXECUTOR_ID.equals(executorId) || !(profile instanceof TestConfig)) {
    return false;
  }

  final FlutterSdk sdk = FlutterSdk.getFlutterSdk(((TestConfig)profile).getProject());
  if (sdk == null || !sdk.getVersion().flutterTestSupportsMachineMode()) {
    return false;
  }

  final TestConfig config = (TestConfig)profile;
  return config.getFields().getScope() != TestFields.Scope.DIRECTORY;
}
 
Example #17
Source File: DeployToServerRunner.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public boolean canRun(@Nonnull String executorId, @Nonnull RunProfile profile) {
  if (!(profile instanceof DeployToServerRunConfiguration)) {
    return false;
  }
  if (executorId.equals(DefaultRunExecutor.EXECUTOR_ID)) {
    return true;
  }
  if (executorId.equals(DefaultDebugExecutor.EXECUTOR_ID)) {
    return ((DeployToServerRunConfiguration<?, ?>)profile).getServerType().createDebugConnector() != null;
  }
  return false;
}
 
Example #18
Source File: Unity3dTestDebuggerRunner.java    From consulo-unity3d with Apache License 2.0 5 votes vote down vote up
@Override
public boolean canRun(@Nonnull String executorId, @Nonnull RunProfile profile)
{
	if(!DefaultDebugExecutor.EXECUTOR_ID.equals(executorId))
	{
		return false;
	}
	return profile instanceof Unity3dTestConfiguration;
}
 
Example #19
Source File: GaugeRunProcessHandler.java    From Intellij-Plugin with Apache License 2.0 5 votes vote down vote up
private static void launchDebugger(final Project project, final GaugeDebugInfo debugInfo) {
    Runnable runnable = () -> {
        final long startTime = System.currentTimeMillis();
        GenericDebuggerRunner basicProgramRunner = new GenericDebuggerRunner();
        RunManagerImpl manager = new RunManagerImpl(project);
        ConfigurationFactory configFactory = RemoteConfigurationType.getInstance().getConfigurationFactories()[0];
        RemoteConfiguration remoteConfig = new RemoteConfiguration(project, configFactory);
        remoteConfig.PORT = debugInfo.getPort();
        remoteConfig.HOST = debugInfo.getHost();
        remoteConfig.USE_SOCKET_TRANSPORT = true;
        remoteConfig.SERVER_MODE = false;
        RunnerAndConfigurationSettingsImpl configuration = new RunnerAndConfigurationSettingsImpl(manager, remoteConfig, false);
        ExecutionEnvironment environment = new ExecutionEnvironment(new DefaultDebugExecutor(), basicProgramRunner, configuration, project);

        boolean debuggerConnected = false;
        // Trying to connect to gauge java for 25 secs. The sleep is because it may take a few seconds for gauge to launch the java process and the jvm to load after that
        while (!debuggerConnected && ((System.currentTimeMillis() - startTime) < 25000)) {
            try {
                Thread.sleep(5000);
                basicProgramRunner.execute(environment);
                debuggerConnected = true;
            } catch (Exception e) {
                System.err.println("Failed to connect debugger. Retrying... : " + e.getMessage());
                LOG.debug(e);
            }
        }
    };

    ApplicationManager.getApplication().invokeAndWait(runnable, ModalityState.any());
}
 
Example #20
Source File: XQueryRunProfileState.java    From intellij-xquery with Apache License 2.0 5 votes vote down vote up
private SimpleJavaParameters prepareRunnerParameters() throws CantRunException {
    final SimpleJavaParameters parameters = new SimpleJavaParameters();
    parameters.setMainClass(configuration.getRunClass());
    boolean isDebugging = getEnvironment().getExecutor().getId().equals(DefaultDebugExecutor.EXECUTOR_ID);
    parameters.getProgramParametersList().prepend(getSerializedConfig(configuration, isDebugging, port).getAbsolutePath());
    parameters.getClassPath().addFirst(new XQueryRunnerClasspathEntryGenerator().generateRunnerClasspathEntries(configuration));
    return parameters;
}
 
Example #21
Source File: XDebuggerManagerImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
public void removeSession(@Nonnull final XDebugSessionImpl session) {
  XDebugSessionTab sessionTab = session.getSessionTab();
  mySessions.remove(session.getDebugProcess().getProcessHandler());
  if (sessionTab != null &&
      !myProject.isDisposed() &&
      !ApplicationManager.getApplication().isUnitTestMode() &&
      XDebuggerSettingManagerImpl.getInstanceImpl().getGeneralSettings().isHideDebuggerOnProcessTermination()) {
    ExecutionManager.getInstance(myProject).getContentManager().hideRunContent(DefaultDebugExecutor.getDebugExecutorInstance(), sessionTab.getRunContentDescriptor());
  }
  if (myActiveSession.compareAndSet(session, null)) {
    onActiveSessionChanged();
  }
}
 
Example #22
Source File: XQueryDebuggerRunner.java    From intellij-xquery with Apache License 2.0 4 votes vote down vote up
@Override
public boolean canRun(@NotNull String executorId, @NotNull RunProfile profile) {
    return DefaultDebugExecutor.EXECUTOR_ID.equals(executorId) && profile instanceof XQueryRunConfiguration && isDebugSupportedFor((XQueryRunConfiguration) profile);
}
 
Example #23
Source File: MainMavenDebugActionGroup.java    From MavenHelper with Apache License 2.0 4 votes vote down vote up
@Override
protected RunConfigurationAction getRunConfigurationAction(Project project, RunnerAndConfigurationSettings cfg) {
	return new DebugConfigurationAction(DefaultDebugExecutor.getDebugExecutorInstance(), true, project, cfg);
}
 
Example #24
Source File: TomcatDebugger.java    From SmartTomcat with Apache License 2.0 4 votes vote down vote up
@Override
public boolean canRun(@NotNull String executorId, @NotNull RunProfile profile) {
    return (DefaultDebugExecutor.EXECUTOR_ID.equals(executorId) && profile instanceof TomcatRunConfiguration);
}
 
Example #25
Source File: TestExecutionState.java    From buck with Apache License 2.0 4 votes vote down vote up
private ProcessHandler runBuildCommand(Executor executor) {
  final BuckModule buckModule = mProject.getComponent(BuckModule.class);
  final String targets = mConfiguration.data.targets;
  final String additionalParams = mConfiguration.data.additionalParams;
  final String testSelectors = mConfiguration.data.testSelectors;
  final String title = "Buck Test " + targets;

  buckModule.attach(targets);

  final BuckBuildCommandHandler handler =
      new BuckBuildCommandHandler(mProject, BuckCommand.TEST, /* doStartNotify */ false) {
        @Override
        protected void notifyLines(Key outputType, Iterable<String> lines) {
          super.notifyLines(outputType, lines);
          if (outputType != ProcessOutputTypes.STDERR) {
            return;
          }
          for (String line : lines) {
            final Matcher matcher = DEBUG_SUSPEND_PATTERN.matcher(line);
            if (matcher.find()) {
              final String port = matcher.group(1);
              attachDebugger(title, port);
            }
          }
        }
      };
  if (!targets.isEmpty()) {
    List<String> params =
        Splitter.on(CharMatcher.whitespace())
            .trimResults()
            .omitEmptyStrings()
            .splitToList(targets);
    handler.command().addParameters(params);
  }
  if (!testSelectors.isEmpty()) {
    handler.command().addParameter("--test-selectors");
    handler.command().addParameter(testSelectors);
  }
  if (!additionalParams.isEmpty()) {
    for (String param : additionalParams.split("\\s")) {
      handler.command().addParameter(param);
    }
  }
  if (executor.getId().equals(DefaultDebugExecutor.EXECUTOR_ID)) {
    handler.command().addParameter("--debug");
  }
  handler.start();
  final OSProcessHandler result = handler.getHandler();
  schedulePostExecutionActions(result, title);
  return result;
}
 
Example #26
Source File: TestExecutionState.java    From buck with Apache License 2.0 4 votes vote down vote up
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);
            }
          });
}
 
Example #27
Source File: TestConsoleProperties.java    From consulo with Apache License 2.0 4 votes vote down vote up
public boolean isDebug() {
  return myExecutor.getId() == DefaultDebugExecutor.EXECUTOR_ID;
}
 
Example #28
Source File: DebugServerAction.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
protected Executor getExecutor() {
  return DefaultDebugExecutor.getDebugExecutorInstance();
}
 
Example #29
Source File: ExternalSystemRunConfiguration.java    From consulo 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 new MyRunnableState(mySettings, getProject(), DefaultDebugExecutor.EXECUTOR_ID.equals(executor.getId()));
}
 
Example #30
Source File: XDebugSessionImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
public void showSessionTab() {
  RunContentDescriptor descriptor = getRunContentDescriptor();
  ExecutionManager.getInstance(getProject()).getContentManager()
          .showRunContent(DefaultDebugExecutor.getDebugExecutorInstance(), descriptor);
}