use of org.eclipse.wst.html.core.validate.extension.IHTMLCustomAttributeValidator in project webtools.sourceediting by eclipse.
the class HTMLAttributeValidator method validateWithExtension.
private void validateWithExtension(Element target, Attr a, String attrName) {
boolean validated = false;
if (externalValidators == null) {
initValidators(((IDOMElement) target).getStructuredDocument());
}
for (IHTMLCustomAttributeValidator v : externalValidators) {
try {
if (v.canValidate((IDOMElement) target, attrName)) {
validated = true;
ValidationMessage result = v.validateAttribute((IDOMElement) target, attrName);
if (result != null) {
// report only one validation result or nothing if all reports are null
reporter.report(result);
break;
}
}
} catch (Throwable t) {
Logger.logException(t);
}
}
if (!validated) {
if (!hasNestedRegion(((IDOMNode) a).getNameRegion())) {
Segment seg = getErrorSegment((IDOMNode) a, REGION_NAME);
if (seg != null)
reporter.report(new ErrorInfoImpl(ErrorState.UNDEFINED_NAME_ERROR, seg, a));
}
}
}
use of org.eclipse.wst.html.core.validate.extension.IHTMLCustomAttributeValidator in project webtools.sourceediting by eclipse.
the class HTMLAttributeValidator method initValidators.
private void initValidators(IStructuredDocument doc) {
externalValidators = new ArrayList<IHTMLCustomAttributeValidator>();
for (IConfigurationElement e : CustomHTMLAttributeValidatorExtensionLoader.getInstance().getValidators()) {
IHTMLCustomAttributeValidator validator;
try {
validator = (IHTMLCustomAttributeValidator) e.createExecutableExtension("class");
validator.init(doc);
externalValidators.add(validator);
} catch (CoreException e1) {
Logger.logException(e1);
}
}
}
Aggregations