Search in sources :

Example 1 with ConfigurationFromContextWrapper

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

the class PreferredProducerFind method getConfigurationsFromContext.

@Nullable
public static List<ConfigurationFromContext> getConfigurationsFromContext(final Location location, final ConfigurationContext context, final boolean strict) {
    if (location == null) {
        return null;
    }
    final ArrayList<ConfigurationFromContext> configurationsFromContext = new ArrayList<>();
    for (RuntimeConfigurationProducer producer : findAllProducers(location, context)) {
        configurationsFromContext.add(new ConfigurationFromContextWrapper(producer));
    }
    for (RunConfigurationProducer producer : RunConfigurationProducer.getProducers(context.getProject())) {
        ConfigurationFromContext fromContext = producer.findOrCreateConfigurationFromContext(context);
        if (fromContext != null) {
            configurationsFromContext.add(fromContext);
        }
    }
    if (configurationsFromContext.isEmpty())
        return null;
    Collections.sort(configurationsFromContext, ConfigurationFromContext.COMPARATOR);
    if (strict) {
        final ConfigurationFromContext first = configurationsFromContext.get(0);
        for (Iterator<ConfigurationFromContext> it = configurationsFromContext.iterator(); it.hasNext(); ) {
            ConfigurationFromContext producer = it.next();
            if (producer != first && ConfigurationFromContext.COMPARATOR.compare(producer, first) > 0) {
                it.remove();
            }
        }
    }
    return configurationsFromContext;
}
Also used : RuntimeConfigurationProducer(com.intellij.execution.junit.RuntimeConfigurationProducer) ArrayList(java.util.ArrayList) ConfigurationFromContextWrapper(com.intellij.execution.impl.ConfigurationFromContextWrapper) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

ConfigurationFromContextWrapper (com.intellij.execution.impl.ConfigurationFromContextWrapper)1 RuntimeConfigurationProducer (com.intellij.execution.junit.RuntimeConfigurationProducer)1 ArrayList (java.util.ArrayList)1 Nullable (org.jetbrains.annotations.Nullable)1