Search in sources :

Example 1 with Segment

use of org.eclipse.wst.html.core.internal.validate.Segment in project webtools.sourceediting by eclipse.

the class CustomExtendedAttributeValidator method validateAttribute.

public ValidationMessage validateAttribute(IDOMElement target, String attrName) {
    if ("plugins".equals(attrName)) {
        try {
            String attrValue = target.getAttribute(attrName);
            Integer.parseInt(attrValue);
        } catch (NumberFormatException e) {
            Segment segment = CustomValidatorUtil.getAttributeSegment((IDOMNode) target.getAttributeNode(attrName), CustomValidatorUtil.ATTR_REGION_NAME);
            return new ValidationMessage("Attribute should be integer", segment.getOffset(), segment.getLength(), ValidationMessage.ERROR);
        }
    }
    return null;
}
Also used : ValidationMessage(org.eclipse.wst.sse.core.internal.validate.ValidationMessage) IDOMNode(org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode) Segment(org.eclipse.wst.html.core.internal.validate.Segment)

Example 2 with Segment

use of org.eclipse.wst.html.core.internal.validate.Segment in project webtools.sourceediting by eclipse.

the class CustomExtendedTagValidator method validateTag.

public ValidationMessage validateTag(IDOMElement target) {
    Assert.assertEquals(currentFileLocation, getResource(target.getStructuredDocument()));
    String tagName = target.getLocalName();
    if (tagName.indexOf("thym") >= 0) {
        Segment segment = CustomValidatorUtil.getTagSegment(target, CustomValidatorUtil.SEG_START_TAG_NAME);
        return new ValidationMessage("Thym is available only with external installation", segment.getOffset(), segment.getLength(), ValidationMessage.ERROR);
    }
    return null;
}
Also used : ValidationMessage(org.eclipse.wst.sse.core.internal.validate.ValidationMessage) Segment(org.eclipse.wst.html.core.internal.validate.Segment)

Aggregations

Segment (org.eclipse.wst.html.core.internal.validate.Segment)2 ValidationMessage (org.eclipse.wst.sse.core.internal.validate.ValidationMessage)2 IDOMNode (org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode)1