Search in sources :

Example 1 with IHTMLCustomTagValidator

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

Example 2 with IHTMLCustomTagValidator

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

Aggregations

IHTMLCustomTagValidator (org.eclipse.wst.html.core.validate.extension.IHTMLCustomTagValidator)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