use of org.eclipse.wst.xsl.core.internal.validation.XSLValidationMessage in project webtools.sourceediting by eclipse.
the class AbstractValidationTest method validateErrors.
private void validateErrors(StylesheetModel model, XSLValidationReport report, Map<Integer, String> expectedErrors) {
expectedErrors = new HashMap<Integer, String>(expectedErrors);
for (ValidationMessage msg : report.getValidationMessages()) {
XSLValidationMessage error = (XSLValidationMessage) msg;
assertTrue("Error report must be for the current stylesheet only", error.getNode().getStylesheet() == model.getStylesheet());
String comment = expectedErrors.remove(error.getLineNumber());
assertNotNull("Unxpected error at line " + error.getLineNumber() + ": " + error, comment);
assertFalse("Incorrect error level for error at line " + error.getLineNumber() + ": " + error, comment.startsWith("ERROR") && msg.getSeverity() != ValidationMessage.SEV_HIGH);
assertFalse("Incorrect error level for error at line " + error.getLineNumber() + ": " + error, comment.startsWith("WARN") && msg.getSeverity() == ValidationMessage.SEV_HIGH);
}
for (Map.Entry<Integer, String> entry : expectedErrors.entrySet()) {
assertTrue("Expected error " + entry.getValue() + " at line " + entry.getKey(), false);
}
}
use of org.eclipse.wst.xsl.core.internal.validation.XSLValidationMessage in project webtools.sourceediting by eclipse.
the class AbstractModelTest method validateErrors.
private void validateErrors(StylesheetModel model, XSLValidationReport report, Map<Integer, String> expectedErrors) {
expectedErrors = new HashMap<Integer, String>(expectedErrors);
for (ValidationMessage msg : report.getValidationMessages()) {
XSLValidationMessage error = (XSLValidationMessage) msg;
assertTrue("Error report must be for the current stylesheet only", error.getNode().getStylesheet() == model.getStylesheet());
String comment = expectedErrors.remove(error.getLineNumber());
assertNotNull("Unxpected error at line " + error.getLineNumber() + ": " + error, comment);
assertFalse("Incorrect error level for error at line " + error.getLineNumber() + ": " + error, comment.startsWith("ERROR") && msg.getSeverity() != ValidationMessage.SEV_HIGH);
assertFalse("Incorrect error level for error at line " + error.getLineNumber() + ": " + error, comment.startsWith("WARN") && msg.getSeverity() == ValidationMessage.SEV_HIGH);
}
for (Map.Entry<Integer, String> entry : expectedErrors.entrySet()) {
assertTrue("Expected error " + entry.getValue() + " at line " + entry.getKey(), false);
}
}
use of org.eclipse.wst.xsl.core.internal.validation.XSLValidationMessage in project webtools.sourceediting by eclipse.
the class Validator2 method validate.
@Override
public ValidationResult validate(IResource resource, int kind, ValidationState state, IProgressMonitor monitor) {
/*
* String s; switch(kind) { case IResourceDelta.ADDED: s = "added"; break; case IResourceDelta.CHANGED: s = "CHANGED"; break; case IResourceDelta.CONTENT: s = "CONTENT"; break; case
* IResourceDelta.REMOVED: s = "REMOVED"; break; default: s = "other"; } System.out.println(s);
*/
ValidationResult result = new ValidationResult();
if (resource.getType() == IResource.FILE) {
IFile file = (IFile) resource;
ValidationReport report = doValidation(file, kind, state, monitor);
StylesheetModel stylesheet = XSLCore.getInstance().getStylesheet(file);
IFile[] dependencies = stylesheet.getFileDependencies().toArray(new IFile[0]);
result.setDependsOn(dependencies);
for (ValidationMessage message : report.getValidationMessages()) {
XSLValidationMessage xslMsg = (XSLValidationMessage) message;
ValidatorMessage msg = ValidatorMessage.create(message.getMessage(), resource);
// $NON-NLS-1$
msg.setAttribute("lineNumber", xslMsg.getLineNumber());
// $NON-NLS-1$
msg.setAttribute("severity", xslMsg.getSeverity());
result.add(msg);
}
}
return result;
}
use of org.eclipse.wst.xsl.core.internal.validation.XSLValidationMessage in project webtools.sourceediting by eclipse.
the class Validator method addInfoToMessage.
@Override
protected void addInfoToMessage(ValidationMessage validationMessage, IMessage message) {
XSLValidationMessage msg = (XSLValidationMessage) validationMessage;
XSLNode node = msg.getNode();
// set this here as it gets set to the wrong value by the superclass
message.setSeverity(msg.getRealSeverity());
// constants are defined in org.eclipse.wst.xml.ui.internal.validation.DelegatingSourceValidator
if (node.getNodeType() == XSLNode.ATTRIBUTE_NODE) {
// $NON-NLS-1$//$NON-NLS-2$
message.setAttribute("ERROR_SIDE", "ERROR_SIDE_RIGHT");
message.setAttribute(COLUMN_NUMBER_ATTRIBUTE, Integer.valueOf(validationMessage.getColumnNumber()));
// whether to squiggle the element, attribute or text //$NON-NLS-1$
message.setAttribute(SQUIGGLE_SELECTION_STRATEGY_ATTRIBUTE, "ATTRIBUTE_VALUE");
message.setAttribute(SQUIGGLE_NAME_OR_VALUE_ATTRIBUTE, ((XSLAttribute) node).getName());
} else if (node.getNodeType() == XSLNode.ELEMENT_NODE) {
// $NON-NLS-1$//$NON-NLS-2$
message.setAttribute("ERROR_SIDE", "ERROR_SIDE_RIGHT");
message.setAttribute(COLUMN_NUMBER_ATTRIBUTE, Integer.valueOf(validationMessage.getColumnNumber()));
// whether to squiggle the element, attribute or text //$NON-NLS-1$
message.setAttribute(SQUIGGLE_SELECTION_STRATEGY_ATTRIBUTE, "START_TAG");
}
}
Aggregations