try {
ILaunchConfiguration[] configs = DebugPlugin.getDefault().getLaunchManager().
getLaunchConfigurations(configType);
candidateConfigs = new ArrayList<ILaunchConfiguration>(configs.length);
for (int i = 0; i < configs.length; i++) {
ILaunchConfiguration config = configs[i];
String attrProgramPath = config.getAttribute(LaunchConstants.ATTR_PROGRAM_PATH, "");
String attrProjectName = config.getAttribute(LaunchConstants.ATTR_PROJECT_NAME, "");
if (attrProgramPath.equals(launchable.getProjectRelativePath().toString())
&& attrProjectName.equals(launchable.getProject().getName())) {
candidateConfigs.add(config);
}
}
} catch (CoreException ce) {
LangUIPlugin.logStatus(ce);
}
int candidateCount = candidateConfigs.size();
if (candidateCount == 0) {
return createConfiguration(launchable);
} else if (candidateCount == 1) {
return (ILaunchConfiguration) candidateConfigs.get(0);
} else {
ILaunchConfiguration config = chooseConfiguration(candidateConfigs);
if (config != null) {
return config;
}
}