private void registerValidator(IConfigurationElement el) {
if (!el.getName().equals(ELEMENT_VALIDATOR)) {
return;
}
final Validator validator = ValidatorsFactory.eINSTANCE.createValidator();
String categoryId = el.getAttribute(ATTR_CATEGORY);
validator.setId(el.getAttribute(ATTR_ID));
if (!categories.containsKey(categoryId)) {
if (categoryId != null)
PEXAnalysisPlugin.error(String.format("Validator %s has reference to a non-existent category %s", validator.getId(), categoryId)); //$NON-NLS-1$
categoryId = DEFAULT_CATEGORY_ID;
}
validator.setCategory(categories.get(categoryId));
validator.getCategory().getValidators().add(validator);
for (IConfigurationElement typeCfg : el.getChildren(ELEMENT_TYPE)) {
Type type = ValidatorsFactory.eINSTANCE.createType();
type.setId(typeCfg.getAttribute(ATTR_ID));
type.setDefaultSeverity(ProblemSeverity.valueOf(preferences.node(validator.getId()).get(type.getId(), typeCfg.getAttribute(ATTR_DEFAULT_SEVERITY) == null ? DEFAULT_SEVERITY: typeCfg.getAttribute(ATTR_DEFAULT_SEVERITY)).toUpperCase()));
type.setLabel(typeCfg.getAttribute(ATTR_LABEL));
type.setDescription(typeCfg.getAttribute(ATTR_DESCRIPTION));
type.setValidator(validator);
validator.getTypes().add(type);
}
validators.put(validator.getId(), validator);
}