use of org.eclipse.wst.html.core.validate.extension.IHTMLCustomTagValidator in project webtools.sourceediting by eclipse.
the class SyntaxValidator method validateNames.
/* perform validation about tag name definition. */
private void validateNames(ElementInfo info) {
boolean corrupted = info.hasEndTag() && isEndTagCorrupted(info);
if (info.decl == null) {
// unknown element.
if (!info.hasStartTag() && corrupted) {
reportCorruptedEndTagError(info);
} else {
if (shouldValidateElementName(info.target)) {
// not excluded in preferences - check for extension point
boolean validated = false;
if (externalValidators == null) {
initValidators(info.target.getStructuredDocument());
}
for (IHTMLCustomTagValidator v : externalValidators) {
try {
if (v.canValidate(info.target)) {
validated = true;
ValidationMessage result = v.validateTag(info.target);
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) {
Segment errorSeg = FMUtil.getSegment(info.target, FMUtil.SEG_START_TAG_NAME);
report(UNDEFINED_NAME_ERROR, errorSeg, info.target);
}
}
}
} else {
// name. (D202493)
if (corrupted) {
reportCorruptedEndTagError(info);
}
}
}
use of org.eclipse.wst.html.core.validate.extension.IHTMLCustomTagValidator in project webtools.sourceediting by eclipse.
the class SyntaxValidator method initValidators.
private void initValidators(IStructuredDocument doc) {
externalValidators = new ArrayList<IHTMLCustomTagValidator>();
for (IConfigurationElement e : CustomHTMLTagValidatorExtensionLoader.getInstance().getValidators()) {
IHTMLCustomTagValidator validator;
try {
validator = (IHTMLCustomTagValidator) e.createExecutableExtension("class");
validator.init(doc);
externalValidators.add(validator);
} catch (CoreException e1) {
Logger.logException(e1);
}
}
}
Aggregations