use of org.eclipse.mylyn.wikitext.validation.StandaloneMarkupValidator in project mylyn.docs by eclipse.
the class StandaloneMarkupValidatorTest method testImmutability.
public void testImmutability() {
StandaloneMarkupValidator validator = StandaloneMarkupValidator.getValidator("Test");
try {
validator.getRules().clear();
fail("not immutable");
} catch (Exception e) {
// expected
}
try {
validator.getRules().add(new TestMarkupValidationRule());
fail("not immutable");
} catch (Exception e) {
// expected
}
try {
validator.setClassLoader(StandaloneMarkupValidator.class.getClassLoader());
fail("not immutable");
} catch (Exception e) {
// expected
}
}
use of org.eclipse.mylyn.wikitext.validation.StandaloneMarkupValidator in project mylyn.docs by eclipse.
the class StandaloneMarkupValidatorTest method setUp.
@Override
protected void setUp() throws Exception {
super.setUp();
validator = new StandaloneMarkupValidator();
validator.setClassLoader(StandaloneMarkupValidatorTest.class.getClassLoader());
validator.computeRules("TestMarkupLanguage", StandaloneMarkupValidatorTest.class.getResource("test-plugin.xml"));
}
use of org.eclipse.mylyn.wikitext.validation.StandaloneMarkupValidator in project mylyn.docs by eclipse.
the class MarkupTask method performValidation.
protected void performValidation(File source, String markupContent) {
if (!validate) {
return;
}
if (markupLanguage == null) {
throw new IllegalStateException();
}
// $NON-NLS-1$
log(MessageFormat.format(Messages.getString("MarkupTask.1"), source), Project.MSG_VERBOSE);
StandaloneMarkupValidator markupValidator = StandaloneMarkupValidator.getValidator(markupLanguage);
List<ValidationProblem> problems = markupValidator.validate(markupContent);
int errorCount = 0;
int warningCount = 0;
for (ValidationProblem problem : problems) {
int messageLevel = Project.MSG_ERR;
if (problem.getSeverity() == Severity.ERROR) {
++errorCount;
} else if (problem.getSeverity() == Severity.WARNING) {
++warningCount;
messageLevel = Project.MSG_WARN;
}
// $NON-NLS-1$
log(String.format("%s:%s %s", source.getName(), problem.getOffset(), problem.getMessage()), messageLevel);
}
if ((errorCount > 0 && failOnValidationError) || (warningCount > 0 && failOnValidationWarning)) {
throw new BuildException(// $NON-NLS-1$
MessageFormat.format(// $NON-NLS-1$
Messages.getString("MarkupTask.3"), // $NON-NLS-1$
errorCount, warningCount, source));
}
}
use of org.eclipse.mylyn.wikitext.validation.StandaloneMarkupValidator in project mylyn.docs by eclipse.
the class WikiToDocTask method performValidation.
protected void performValidation(MarkupLanguage markupLanguage, Path path, String markupContent) {
// $NON-NLS-1$
getProject().log(MessageFormat.format("Validating {0}", path.name), Project.MSG_VERBOSE);
StandaloneMarkupValidator markupValidator = StandaloneMarkupValidator.getValidator(markupLanguage.getName());
List<ValidationProblem> problems = markupValidator.validate(markupContent);
int errorCount = 0;
int warningCount = 0;
for (ValidationProblem problem : problems) {
int messageLevel = Project.MSG_ERR;
if (problem.getSeverity() == Severity.ERROR) {
++errorCount;
} else if (problem.getSeverity() == Severity.WARNING) {
++warningCount;
messageLevel = Project.MSG_WARN;
}
// $NON-NLS-1$
log(String.format("%s:%s %s", path.name, problem.getOffset(), problem.getMessage()), messageLevel);
}
if ((errorCount > 0 && isFailOnValidationError()) || (warningCount > 0 && isFailOnValidationWarning())) {
throw new BuildException(// $NON-NLS-1$
MessageFormat.format(// $NON-NLS-1$
"Validation failed with {0} errors and {1} warnings: {0}", // $NON-NLS-1$
errorCount, warningCount, path.name));
}
}
Aggregations