RuntimeConfigurationProducer (final Location location, final ConfigurationContext context) { final RuntimeConfigurationProducer result = clone(); result.myConfiguration = location != null ? result.createConfigurationByElement(location, context) : null; if (result.myConfiguration != null) { final PsiElement psiElement = result.getSourceElement(); final Location<PsiElement> _location = PsiLocation.fromPsiElement(psiElement, location.getModule()); if (_location != null) { // replace with existing configuration if any final RunManager runManager = RunManager.getInstance(context.getProject()); final ConfigurationType type = result.myConfiguration.getType(); RunnerAndConfigurationSettings configuration = result.findExistingByElement(_location, runManager.getConfigurationSettingsList(type), context); if (configuration != null) { result.myConfiguration = configuration; } else { runManager.setUniqueNameIfNeeded(result.myConfiguration); } } } return result; }