use of org.eclipse.wst.sse.core.internal.validate.ValidationMessage 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.sse.core.internal.validate.ValidationMessage 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;
}
use of org.eclipse.wst.sse.core.internal.validate.ValidationMessage 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;
}
use of org.eclipse.wst.sse.core.internal.validate.ValidationMessage 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);
}
}
}
Aggregations