Java Code Examples for com.intellij.execution.configurations.RunProfile

The following examples show how to use com.intellij.execution.configurations.RunProfile. These examples are extracted from open source projects. 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 Project: CppTools   Source File: CppBaseDebugRunner.java    License: Apache License 2.0 6 votes vote down vote up
@Nullable
@Override
protected RunContentDescriptor doExecute(Project project, RunProfileState runProfileState, RunContentDescriptor runContentDescriptor, ExecutionEnvironment env) throws ExecutionException {
  FileDocumentManager.getInstance().saveAllDocuments();

  final RunProfile runProfile = env.getRunProfile();

  final XDebugSession debugSession =
      XDebuggerManager.getInstance(project).startSession(this, env, runContentDescriptor, new XDebugProcessStarter() {
        @NotNull
        public XDebugProcess start(@NotNull final XDebugSession session) {
          return new CppDebugProcess(session, CppBaseDebugRunner.this, (BaseCppConfiguration)runProfile);
        }
      });

  return debugSession.getRunContentDescriptor();
}
 
Example 2
Source Project: intellij   Source File: BlazeHotSwapManager.java    License: Apache License 2.0 6 votes vote down vote up
@Nullable
static HotSwappableDebugSession findHotSwappableBlazeDebuggerSession(Project project) {
  DebuggerManagerEx debuggerManager = DebuggerManagerEx.getInstanceEx(project);
  DebuggerSession session = debuggerManager.getContext().getDebuggerSession();
  if (session == null || !session.isAttached()) {
    return null;
  }
  JavaDebugProcess process = session.getProcess().getXdebugProcess();
  if (process == null) {
    return null;
  }
  ExecutionEnvironment env = ((XDebugSessionImpl) process.getSession()).getExecutionEnvironment();
  if (env == null || ClassFileManifestBuilder.getManifest(env) == null) {
    return null;
  }
  RunProfile runProfile = env.getRunProfile();
  if (!(runProfile instanceof BlazeCommandRunConfiguration)) {
    return null;
  }
  return new HotSwappableDebugSession(session, env, (BlazeCommandRunConfiguration) runProfile);
}
 
Example 3
Source Project: intellij   Source File: BlazeGoDebugRunner.java    License: 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 4
Source Project: intellij   Source File: SkylarkDebugRunner.java    License: 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 5
Source Project: consulo   Source File: SMTestRunnerResultsForm.java    License: Apache License 2.0 6 votes vote down vote up
private void addToHistory(final SMTestProxy.SMRootTestProxy root, TestConsoleProperties consoleProperties, Disposable parentDisposable) {
  final RunProfile configuration = consoleProperties.getConfiguration();
  if (configuration instanceof RunConfiguration &&
      !(consoleProperties instanceof ImportedTestConsoleProperties) &&
      !ApplicationManager.getApplication().isUnitTestMode() &&
      !myDisposed) {
    final MySaveHistoryTask backgroundable = new MySaveHistoryTask(consoleProperties, root, (RunConfiguration)configuration);
    final BackgroundableProcessIndicator processIndicator = new BackgroundableProcessIndicator(backgroundable);
    Disposer.register(parentDisposable, new Disposable() {
      @Override
      public void dispose() {
        processIndicator.cancel();
        backgroundable.dispose();
      }
    });
    Disposer.register(parentDisposable, processIndicator);
    ProgressManager.getInstance().runProcessWithProgressAsynchronously(backgroundable, processIndicator);
  }
}
 
Example 6
Source Project: consulo   Source File: TestConsoleProperties.java    License: Apache License 2.0 6 votes vote down vote up
@Nonnull
protected GlobalSearchScope initScope() {
  RunProfile configuration = getConfiguration();
  if (!(configuration instanceof ModuleRunProfile)) {
    return GlobalSearchScope.allScope(myProject);
  }

  Module[] modules = ((ModuleRunProfile)configuration).getModules();
  if (modules.length == 0) {
    return GlobalSearchScope.allScope(myProject);
  }

  GlobalSearchScope scope = GlobalSearchScope.EMPTY_SCOPE;
  for (Module each : modules) {
    scope = scope.uniteWith(GlobalSearchScope.moduleRuntimeScope(each, true));
  }
  return scope;
}
 
Example 7
Source Project: consulo   Source File: TrackCoverageAction.java    License: 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 8
Source Project: consulo   Source File: ExecutionEnvironment.java    License: Apache License 2.0 6 votes vote down vote up
ExecutionEnvironment(@Nonnull RunProfile runProfile,
                     @Nonnull Executor executor,
                     @Nonnull ExecutionTarget target,
                     @Nonnull Project project,
                     @Nullable RunnerSettings runnerSettings,
                     @Nullable ConfigurationPerRunnerSettings configurationSettings,
                     @javax.annotation.Nullable RunContentDescriptor contentToReuse,
                     @Nullable RunnerAndConfigurationSettings settings,
                     @Nonnull ProgramRunner<?> runner) {
  myExecutor = executor;
  myTarget = target;
  myRunProfile = runProfile;
  myRunnerSettings = runnerSettings;
  myConfigurationSettings = configurationSettings;
  myProject = project;
  setContentToReuse(contentToReuse);
  myRunnerAndConfigurationSettings = settings;

  myRunner = runner;
}
 
Example 9
Source Project: consulo   Source File: LogConsoleManagerBase.java    License: Apache License 2.0 5 votes vote down vote up
private void doAddLogConsole(@Nonnull final LogConsoleBase log, String id, Image icon, @Nullable RunProfile runProfile) {
  if (runProfile instanceof RunConfigurationBase) {
    ((RunConfigurationBase)runProfile).customizeLogConsole(log);
  }
  log.attachStopLogConsoleTrackingListener(getProcessHandler());
  addAdditionalTabComponent(log, id, icon);

  getUi().addListener(new ContentManagerAdapter() {
    @Override
    public void selectionChanged(final ContentManagerEvent event) {
      log.activate();
    }
  }, log);
}
 
Example 10
@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 11
@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 12
@Override
public XDebuggerEditorsProvider createEditor(RunProfile profile) {
  if (profile == null) {
    return new DebuggerEditorsProvider();
  }
  BlazeAndroidRunConfigurationHandler handler =
      BlazeAndroidRunConfigurationHandler.getHandlerFrom(profile);
  if (handler != null && handler.getCommonState().isNativeDebuggingEnabled()) {
    return new DebuggerEditorsProvider();
  }
  return null;
}
 
Example 13
Source Project: intellij   Source File: BlazeAndroidBinaryProgramRunner.java    License: 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
/**
 * A convenience method for getting a {@link BlazeAndroidRunConfigurationHandler} from a {@link
 * RunProfile}, without having to do repetitive casts. Returns null if the given profile is not a
 * {@link BlazeCommandRunConfiguration} with a {@link BlazeAndroidRunConfigurationHandler} for its
 * handler.
 */
@Nullable
static BlazeAndroidRunConfigurationHandler getHandlerFrom(RunProfile profile) {
  if (!(profile instanceof BlazeCommandRunConfiguration)) {
    return null;
  }
  BlazeCommandRunConfigurationHandler handler =
      ((BlazeCommandRunConfiguration) profile).getHandler();
  if (!(handler instanceof BlazeAndroidRunConfigurationHandler)) {
    return null;
  }
  return (BlazeAndroidRunConfigurationHandler) handler;
}
 
Example 15
Source Project: intellij   Source File: BlazeAndroidTestProgramRunner.java    License: 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 16
@Nullable
static BlazeCommandRunConfiguration getBlazeConfig(RunProfile runProfile) {
  if (runProfile instanceof WrappingRunConfiguration) {
    runProfile = ((WrappingRunConfiguration) runProfile).getPeer();
  }
  return runProfile instanceof BlazeCommandRunConfiguration
      ? (BlazeCommandRunConfiguration) runProfile
      : null;
}
 
Example 17
@Override
public boolean canRun(String executorId, RunProfile profile) {
  BlazeCommandRunConfiguration config =
      BlazeCommandRunConfigurationRunner.getBlazeConfig(profile);
  if (config == null) {
    return false;
  }
  ExecutorType type = ExecutorType.fromExecutorId(executorId);
  PendingRunConfigurationContext pendingContext = config.getPendingContext();
  return pendingContext != null
      && !pendingContext.isDone()
      && pendingContext.supportedExecutors().contains(type);
}
 
Example 18
Source Project: consulo   Source File: RunTab.java    License: Apache License 2.0 5 votes vote down vote up
protected final void initLogConsoles(@Nonnull RunProfile runConfiguration, @Nonnull RunContentDescriptor contentDescriptor, @Nullable ExecutionConsole console) {
  ProcessHandler processHandler = contentDescriptor.getProcessHandler();
  if (runConfiguration instanceof RunConfigurationBase) {
    RunConfigurationBase configuration = (RunConfigurationBase)runConfiguration;
    if (myManager == null) {
      myManager = new LogFilesManager(getLogConsoleManager());
    }
    myManager.addLogConsoles(configuration, processHandler);
    if (processHandler != null) {
      OutputFileUtil.attachDumpListener(configuration, processHandler, console);
    }
  }
}
 
Example 19
Source Project: intellij   Source File: FastBuildConfigurationRunner.java    License: Apache License 2.0 5 votes vote down vote up
/** Returns false if this isn't a 'blaze test' invocation. */
static boolean canRun(RunProfile runProfile) {
  BlazeCommandRunConfiguration blazeCfg =
      BlazeCommandRunConfigurationRunner.getBlazeConfig(runProfile);
  if (blazeCfg == null) {
    return false;
  }
  return Objects.equals(blazeCfg.getHandler().getCommandName(), BlazeCommandName.TEST)
      && FastBuildService.getInstance(blazeCfg.getProject())
          .supportsFastBuilds(
              Blaze.getBuildSystem(blazeCfg.getProject()), blazeCfg.getTargetKind());
}
 
Example 20
Source Project: intellij   Source File: FastBuildSuggestion.java    License: Apache License 2.0 5 votes vote down vote up
private static boolean isGoodCandidateForFastRun(RunProfile runProfile) {
  if (!(runProfile instanceof BlazeCommandRunConfiguration)) {
    return false;
  }
  BlazeCommandRunConfiguration blazeCfg = (BlazeCommandRunConfiguration) runProfile;

  if (!(blazeCfg.getSingleTarget() instanceof Label)) {
    return false;
  }
  Label label = (Label) blazeCfg.getSingleTarget();

  return countJavaDeps(label, blazeCfg.getProject()) > MIN_JARS_TO_NOTIFY;
}
 
Example 21
Source Project: intellij   Source File: FastBuildDebuggerRunner.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public boolean canRun(@NotNull String executorId, @NotNull RunProfile profile) {
  ExecutorType executorType = ExecutorType.fromExecutorId(executorId);
  if (!executorType.equals(ExecutorType.FAST_BUILD_DEBUG)) {
    return false;
  }
  return FastBuildConfigurationRunner.canRun(profile);
}
 
Example 22
Source Project: intellij   Source File: BlazeJavaDebuggerRunner.java    License: 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 23
Source Project: intellij   Source File: BlazeJavaDebuggerRunner.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void patch(
    JavaParameters javaParameters,
    RunnerSettings runnerSettings,
    RunProfile runProfile,
    final boolean beforeExecution) {
  // We don't want to support Java run configuration patching.
}
 
Example 24
Source Project: intellij   Source File: BlazeCidrDebuggerSupportFactory.java    License: Apache License 2.0 5 votes vote down vote up
@Nullable
@Override
public XDebuggerEditorsProvider createEditor(RunProfile profile) {
  if (profile instanceof BlazeCommandRunConfiguration
      && RunConfigurationUtils.canUseClionRunner((BlazeCommandRunConfiguration) profile)) {
    return createEditorProvider();
  }
  return null;
}
 
Example 25
Source Project: intellij   Source File: BlazePyDebugRunner.java    License: 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 26
/**
 * Executes the Runner, This only gets called in run mode.
 * It returns null because you want to show only the PI Console
 *
 * @param profileState
 * @param environment
 * @return
 * @throws ExecutionException
 */
@Override
protected RunContentDescriptor doExecute(@NotNull RunProfileState profileState, @NotNull ExecutionEnvironment environment) throws ExecutionException {
    final RunProfile runProfileRaw = environment.getRunProfile();
    if (runProfileRaw instanceof EmbeddedLinuxJVMRunConfiguration) {
        FileDocumentManager.getInstance().saveAllDocuments();
        setupConsole(environment.getProject());
        return super.doExecute(profileState, environment);
    }
    return super.doExecute(profileState, environment);
}
 
Example 27
/**
 * Executes the runner
 *
 * @param project
 * @param state
 * @param contentToReuse
 * @param environment
 * @return
 * @throws ExecutionException
 */
@Override
protected RunContentDescriptor doExecute(@NotNull Project project, @NotNull RunProfileState state, RunContentDescriptor contentToReuse, @NotNull ExecutionEnvironment environment) throws ExecutionException {
    final RunProfile runProfileRaw = environment.getRunProfile();
    if (runProfileRaw instanceof EmbeddedLinuxJVMRunConfiguration) {
        FileDocumentManager.getInstance().saveAllDocuments();
        setupConsole(environment.getProject());
        super.doExecute(project, state, contentToReuse, environment);
    }
    return super.doExecute(project, state, contentToReuse, environment);
}
 
Example 28
@Test
public void testCanRun() {
    RunProfile profile = Mockito.mock(EmbeddedLinuxJVMRunConfiguration.class);

    EmbeddedLinuxJVMDebugger debugger = Whitebox.newInstance(EmbeddedLinuxJVMDebugger.class);
    boolean canRun = debugger.canRun("Debug", profile);
    assertTrue(canRun);

    RunProfile wrongProfile = Mockito.mock(RunProfile.class);
    boolean cannotRun = debugger.canRun("Debug", wrongProfile);
    assertFalse(cannotRun);
}
 
Example 29
@Test
public void testCanRun() {
    RunProfile profile = Mockito.mock(EmbeddedLinuxJVMRunConfiguration.class);

    EmbeddedLinuxJVMRunner runner = Whitebox.newInstance(EmbeddedLinuxJVMRunner.class);
    boolean canRun = runner.canRun("Run", profile);
    assertTrue(canRun);

    boolean cannotRun = runner.canRun("Debug", profile);
    assertFalse(cannotRun);

    RunProfile wrongProfile = Mockito.mock(RunProfile.class);
    boolean cannotRun2 = runner.canRun("Run", wrongProfile);
    assertFalse(cannotRun2);
}
 
Example 30
Source Project: consulo   Source File: RunContentBuilder.java    License: Apache License 2.0 5 votes vote down vote up
@Nonnull
private RunContentDescriptor createDescriptor() {
  final RunProfile profile = myEnvironment.getRunProfile();
  if (ApplicationManager.getApplication().isUnitTestMode()) {
    return new RunContentDescriptor(profile, myExecutionResult, myUi);
  }

  final ExecutionConsole console = myExecutionResult.getExecutionConsole();
  RunContentDescriptor contentDescriptor = new RunContentDescriptor(profile, myExecutionResult, myUi);
  if (console != null) {
    if (console instanceof ExecutionConsoleEx) {
      ((ExecutionConsoleEx)console).buildUi(myUi);
    }
    else {
      buildConsoleUiDefault(myUi, console);
    }
    initLogConsoles(profile, contentDescriptor, console);
  }
  myUi.getOptions().setLeftToolbar(createActionToolbar(contentDescriptor), ActionPlaces.UNKNOWN);

  if (profile instanceof RunConfigurationBase) {
    if (console instanceof ObservableConsoleView && !ApplicationManager.getApplication().isUnitTestMode()) {
      ((ObservableConsoleView)console).addChangeListener(new ConsoleToFrontListener((RunConfigurationBase)profile,
                                                                                    myProject,
                                                                                    myEnvironment.getExecutor(),
                                                                                    contentDescriptor,
                                                                                    myUi),
                                                         this);
    }
  }

  return contentDescriptor;
}