Search in sources :

Example 1 with IHTMLCustomAttributeValidator

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));
        }
    }
}
Also used : ValidationMessage(org.eclipse.wst.sse.core.internal.validate.ValidationMessage) IDOMNode(org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode) IHTMLCustomAttributeValidator(org.eclipse.wst.html.core.validate.extension.IHTMLCustomAttributeValidator)

Example 2 with IHTMLCustomAttributeValidator

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);
        }
    }
}
Also used : CoreException(org.eclipse.core.runtime.CoreException) IHTMLCustomAttributeValidator(org.eclipse.wst.html.core.validate.extension.IHTMLCustomAttributeValidator) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement)

Aggregations

IHTMLCustomAttributeValidator (org.eclipse.wst.html.core.validate.extension.IHTMLCustomAttributeValidator)2 CoreException (org.eclipse.core.runtime.CoreException)1 IConfigurationElement (org.eclipse.core.runtime.IConfigurationElement)1 ValidationMessage (org.eclipse.wst.sse.core.internal.validate.ValidationMessage)1 IDOMNode (org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode)1