com.intellij.execution.configurations.RunProfile Java Examples

The following examples show how to use com.intellij.execution.configurations.RunProfile. 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: TestConsoleProperties.java    From consulo with 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 #2
Source File: CppBaseDebugRunner.java    From CppTools with 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 #3
Source File: SMTestRunnerResultsForm.java    From consulo with 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 #4
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 #5
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 #6
Source File: ExecutionEnvironment.java    From consulo with 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 #7
Source File: TrackCoverageAction.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Nullable
private CoverageSuitesBundle getCurrentCoverageSuite() {
  if (myModel == null) {
    return null;
  }

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

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

      // Get coverage settings
      Executor executor = myProperties.getExecutor();
      if (executor != null && executor.getId().equals(CoverageExecutor.EXECUTOR_ID)) {
        return CoverageDataManager.getInstance(myProperties.getProject()).getCurrentSuitesBundle();
      }
    }
  }
  return null;
}
 
Example #8
Source File: BlazeHotSwapManager.java    From intellij with 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 #9
Source File: BlazeJavaDebuggerRunner.java    From intellij with 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 #10
Source File: BlazeCidrDebuggerSupportFactory.java    From intellij with 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 #11
Source File: RemoteProcessSupport.java    From consulo with Apache License 2.0 5 votes vote down vote up
private void startProcess(Target target, Parameters configuration, Pair<Target, Parameters> key) {
  ProgramRunner runner = new DefaultProgramRunner() {
    @Override
    @Nonnull
    public String getRunnerId() {
      return "MyRunner";
    }

    @Override
    public boolean canRun(@Nonnull String executorId, @Nonnull RunProfile profile) {
      return true;
    }
  };
  Executor executor = DefaultRunExecutor.getRunExecutorInstance();
  ProcessHandler processHandler = null;
  try {
    RunProfileState state = getRunProfileState(target, configuration, executor);
    ExecutionResult result = state.execute(executor, runner);
    //noinspection ConstantConditions
    processHandler = result.getProcessHandler();
  }
  catch (Exception e) {
    dropProcessInfo(key, e instanceof ExecutionException? e.getMessage() : ExceptionUtil.getUserStackTrace(e, LOG), processHandler);
    return;
  }
  processHandler.addProcessListener(getProcessListener(key));
  processHandler.startNotify();
}
 
Example #12
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 #13
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 #14
Source File: TestsUIUtil.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nullable
@SuppressWarnings("unchecked")
public static <T> T getData(final AbstractTestProxy testProxy, final Key<T> dataId, final TestFrameworkRunningModel model) {
  final TestConsoleProperties properties = model.getProperties();
  final Project project = properties.getProject();
  if (testProxy == null) return null;
  if (AbstractTestProxy.DATA_KEY == dataId) return (T)testProxy;
  if (CommonDataKeys.NAVIGATABLE == dataId) return (T)getOpenFileDescriptor(testProxy, model);
  if (CommonDataKeys.PSI_ELEMENT == dataId) {
    final Location location = testProxy.getLocation(project, properties.getScope());
    if (location != null) {
      final PsiElement element = location.getPsiElement();
      return element.isValid() ? (T)element : null;
    }
    else {
      return null;
    }
  }
  if (Location.DATA_KEY == dataId) return (T)testProxy.getLocation(project, properties.getScope());
  if (RunConfiguration.DATA_KEY == dataId) {
    final RunProfile configuration = properties.getConfiguration();
    if (configuration instanceof RunConfiguration) {
      return (T)configuration;
    }
  }
  return null;
}
 
Example #15
Source File: BlazeAndroidNativeDebuggerLanguageSupport.java    From intellij with Apache License 2.0 5 votes vote down vote up
@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 #16
Source File: ExecutionEnvironmentBuilder.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
public static ExecutionEnvironmentBuilder create(@Nonnull Project project, @Nonnull Executor executor, @Nonnull RunProfile runProfile) throws ExecutionException {
  ExecutionEnvironmentBuilder builder = createOrNull(project, executor, runProfile);
  if (builder == null) {
    throw new ExecutionException("Cannot find runner for " + runProfile.getName());
  }
  return builder;
}
 
Example #17
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 #18
Source File: FastBuildConfigurationRunner.java    From intellij with 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 #19
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 #20
Source File: EmbeddedLinuxJVMRunner.java    From embeddedlinux-jvmdebugger-intellij with Apache License 2.0 5 votes vote down vote up
/**
 * 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 #21
Source File: AbstractAutoTestManager.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nullable
@Override
public State getState() {
  State state = new State();
  for (RunProfile profile : myEnabledRunProfiles) {
    saveConfigurationState(state, profile);
  }
  return state;
}
 
Example #22
Source File: AbstractAutoTestManager.java    From consulo with Apache License 2.0 5 votes vote down vote up
public static void saveConfigurationState(State state, RunProfile profile) {
  RunConfiguration runConfiguration = ObjectUtils.tryCast(profile, RunConfiguration.class);
  if (runConfiguration != null) {
    RunConfigurationDescriptor descriptor = new RunConfigurationDescriptor();
    descriptor.myType = runConfiguration.getType().getId();
    descriptor.myName = runConfiguration.getName();
    state.myEnabledRunConfigurations.add(descriptor);
  }
}
 
Example #23
Source File: EmbeddedLinuxJVMDebugger.java    From embeddedlinux-jvmdebugger-intellij with Apache License 2.0 5 votes vote down vote up
/**
 * 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 #24
Source File: EmbeddedLinuxJVMDebuggerTest.java    From embeddedlinux-jvmdebugger-intellij with Apache License 2.0 5 votes vote down vote up
@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 #25
Source File: EmbeddedLinuxJVMRunnerTest.java    From embeddedlinux-jvmdebugger-intellij with Apache License 2.0 5 votes vote down vote up
@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 #26
Source File: RunContentBuilder.java    From consulo with 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;
}
 
Example #27
Source File: ImportedTestConsoleProperties.java    From consulo with Apache License 2.0 5 votes vote down vote up
public ImportedTestConsoleProperties(@Nullable SMTRunnerConsoleProperties properties,
                                     File file,
                                     ProcessHandler handler,
                                     Project project, RunProfile runConfiguration,
                                     String frameworkName,
                                     Executor executor) {
  super(project, runConfiguration, frameworkName, executor);
  myProperties = properties;
  myFile = file;
  myHandler = handler;
}
 
Example #28
Source File: ImportedTestRunnableState.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 MyEmptyProcessHandler handler = new MyEmptyProcessHandler();
  final SMTRunnerConsoleProperties properties = myRunProfile.getProperties();
  RunProfile configuration;
  final String frameworkName;
  if (properties != null) {
    configuration = properties.getConfiguration();
    frameworkName = properties.getTestFrameworkName();
  }
  else {
    configuration = myRunProfile;
    frameworkName = "Import Test Results";
  }
  final ImportedTestConsoleProperties consoleProperties = new ImportedTestConsoleProperties(properties, myFile, handler, myRunProfile.getProject(),
                                                                                            configuration, frameworkName, executor);
  final BaseTestsOutputConsoleView console = SMTestRunnerConnectionUtil.createConsole(consoleProperties.getTestFrameworkName(),
                                                                                      consoleProperties);
  final JComponent component = console.getComponent();
  AbstractRerunFailedTestsAction rerunFailedTestsAction = null;
  if (component instanceof TestFrameworkRunningModel) {
    rerunFailedTestsAction = consoleProperties.createRerunFailedTestsAction(console);
    if (rerunFailedTestsAction != null) {
      rerunFailedTestsAction.setModelProvider(new Getter<TestFrameworkRunningModel>() {
        @Override
        public TestFrameworkRunningModel get() {
          return (TestFrameworkRunningModel)component;
        }
      });
    }
  }

  console.attachToProcess(handler);
  final DefaultExecutionResult result = new DefaultExecutionResult(console, handler);
  if (rerunFailedTestsAction != null) {
    result.setRestartActions(rerunFailedTestsAction);
  }
  return result;
}
 
Example #29
Source File: SMTRunnerConsoleProperties.java    From consulo with Apache License 2.0 5 votes vote down vote up
public SMTRunnerConsoleProperties(@Nonnull Project project,
                                  @Nonnull RunProfile config,
                                  @Nonnull String testFrameworkName,
                                  @Nonnull Executor executor) {
  super(getStorage(testFrameworkName), project, executor);
  myConfiguration = config;
  myTestFrameworkName = testFrameworkName;
  myCustomFilter = new CompositeFilter(project);
}
 
Example #30
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;
}