use of com.intellij.execution.junit.RuntimeConfigurationProducer 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;
}
use of com.intellij.execution.junit.RuntimeConfigurationProducer in project intellij-community by JetBrains.
the class ConfigurationContext method findExisting.
/**
* Finds an existing run configuration matching the context.
*
* @return an existing configuration, or null if none was found.
*/
@Nullable
public RunnerAndConfigurationSettings findExisting() {
if (myExistingConfiguration != null)
return myExistingConfiguration.get();
myExistingConfiguration = new Ref<>();
if (myLocation == null) {
return null;
}
final PsiElement psiElement = myLocation.getPsiElement();
if (!psiElement.isValid()) {
return null;
}
final List<RuntimeConfigurationProducer> producers = findPreferredProducers();
if (myRuntimeConfiguration != null) {
if (producers != null) {
for (RuntimeConfigurationProducer producer : producers) {
final RunnerAndConfigurationSettings configuration = producer.findExistingConfiguration(myLocation, this);
if (configuration != null && configuration.getConfiguration() == myRuntimeConfiguration) {
myExistingConfiguration.set(configuration);
}
}
}
for (RunConfigurationProducer producer : RunConfigurationProducer.getProducers(getProject())) {
RunnerAndConfigurationSettings configuration = producer.findExistingConfiguration(this);
if (configuration != null && configuration.getConfiguration() == myRuntimeConfiguration) {
myExistingConfiguration.set(configuration);
}
}
}
if (producers != null) {
for (RuntimeConfigurationProducer producer : producers) {
final RunnerAndConfigurationSettings configuration = producer.findExistingConfiguration(myLocation, this);
if (configuration != null) {
myExistingConfiguration.set(configuration);
}
}
}
for (RunConfigurationProducer producer : RunConfigurationProducer.getProducers(getProject())) {
RunnerAndConfigurationSettings configuration = producer.findExistingConfiguration(this);
if (configuration != null) {
myExistingConfiguration.set(configuration);
}
}
return myExistingConfiguration.get();
}
use of com.intellij.execution.junit.RuntimeConfigurationProducer in project intellij-community by JetBrains.
the class PreferredProducerFind method findAllProducers.
private static List<RuntimeConfigurationProducer> findAllProducers(Location location, ConfigurationContext context) {
//todo load configuration types if not already loaded
Extensions.getExtensions(ConfigurationType.CONFIGURATION_TYPE_EP);
final RuntimeConfigurationProducer[] configurationProducers = ApplicationManager.getApplication().getExtensions(RuntimeConfigurationProducer.RUNTIME_CONFIGURATION_PRODUCER);
final ArrayList<RuntimeConfigurationProducer> producers = new ArrayList<>();
for (final RuntimeConfigurationProducer prototype : configurationProducers) {
final RuntimeConfigurationProducer producer;
try {
producer = prototype.createProducer(location, context);
} catch (AbstractMethodError e) {
LOG.error(new ExtensionException(prototype.getClass()));
continue;
}
if (producer.getConfiguration() != null) {
LOG.assertTrue(producer.getSourceElement() != null, producer);
producers.add(producer);
}
}
return producers;
}
use of com.intellij.execution.junit.RuntimeConfigurationProducer in project intellij-community by JetBrains.
the class PreferredProducerFind method findPreferredProducers.
@Nullable
@Deprecated
public static List<RuntimeConfigurationProducer> findPreferredProducers(final Location location, final ConfigurationContext context, final boolean strict) {
if (location == null) {
return null;
}
final List<RuntimeConfigurationProducer> producers = findAllProducers(location, context);
if (producers.isEmpty())
return null;
Collections.sort(producers, RuntimeConfigurationProducer.COMPARATOR);
if (strict) {
final RuntimeConfigurationProducer first = producers.get(0);
for (Iterator<RuntimeConfigurationProducer> it = producers.iterator(); it.hasNext(); ) {
RuntimeConfigurationProducer producer = it.next();
if (producer != first && RuntimeConfigurationProducer.COMPARATOR.compare(producer, first) >= 0) {
it.remove();
}
}
}
return producers;
}
Aggregations