Java Code Examples for com.intellij.execution.actions.ConfigurationContext#getOriginalConfiguration()

The following examples show how to use com.intellij.execution.actions.ConfigurationContext#getOriginalConfiguration() . 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: BlazeFilterExistingRunConfigurationProducer.java    From intellij with Apache License 2.0 6 votes vote down vote up
private static Optional<String> getTestFilter(ConfigurationContext context) {
  RunConfiguration base = context.getOriginalConfiguration(null);
  if (!(base instanceof BlazeCommandRunConfiguration)) {
    return Optional.empty();
  }
  ImmutableList<? extends TargetExpression> targets =
      ((BlazeCommandRunConfiguration) base).getTargets();
  if (targets.isEmpty()) {
    return Optional.empty();
  }
  List<Location<?>> selectedElements = SmRunnerUtils.getSelectedSmRunnerTreeElements(context);
  if (selectedElements.isEmpty()) {
    return Optional.empty();
  }
  Optional<BlazeTestEventsHandler> testEventsHandler =
      BlazeTestEventsHandler.getHandlerForTargets(context.getProject(), targets);
  return testEventsHandler.map(
      handler -> handler.getTestFilter(context.getProject(), selectedElements));
}
 
Example 2
Source File: RuntimeConfigurationProducer.java    From consulo with Apache License 2.0 5 votes vote down vote up
protected RunnerAndConfigurationSettings cloneTemplateConfiguration(final Project project, @Nullable final ConfigurationContext context) {
  if (context != null) {
    final RunConfiguration original = context.getOriginalConfiguration(myConfigurationFactory.getType());
    if (original != null) {
      final RunConfiguration c = original instanceof DelegatingRuntimeConfiguration? ((DelegatingRuntimeConfiguration)original).getPeer() : original;
      return RunManager.getInstance(project).createConfiguration(c.clone(), myConfigurationFactory);
    }
  }
  return RunManager.getInstance(project).createRunConfiguration("", myConfigurationFactory);
}