/** * 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(); }
@Deprecated @Nullable public RunnerAndConfigurationSettings updateConfiguration( final RuntimeConfigurationProducer producer) { myConfiguration = producer.getConfiguration(); return myConfiguration; }