use of org.eclipse.mylyn.wikitext.validation.ValidationProblem in project mylyn.docs by eclipse.
the class BlockWhitespaceRuleTest method testMatch2.
public void testMatch2() {
final String markup = "\nbc.\nfoo";
ValidationProblem problem = rule.findProblem(markup, 0, markup.length());
assertNotNull(problem);
assertEquals(1, problem.getOffset());
}
use of org.eclipse.mylyn.wikitext.validation.ValidationProblem in project mylyn.docs by eclipse.
the class BlockWhitespaceRuleTest method testNoMatch2.
public void testNoMatch2() {
final String markup = "\nabc.\nfoo";
ValidationProblem problem = rule.findProblem(markup, 0, markup.length());
assertNull(problem);
}
use of org.eclipse.mylyn.wikitext.validation.ValidationProblem in project mylyn.docs by eclipse.
the class BlockWhitespaceRuleTest method testMatch.
public void testMatch() {
final String markup = "bc.\nfoo";
ValidationProblem problem = rule.findProblem(markup, 0, markup.length());
assertNotNull(problem);
assertEquals(0, problem.getOffset());
}
use of org.eclipse.mylyn.wikitext.validation.ValidationProblem in project mylyn.docs by eclipse.
the class LinkDefinitionValidationRule method findProblems.
@Override
public List<ValidationProblem> findProblems(String markup, int offset, int length) {
MarkupParser parser = new MarkupParser(new MarkdownLanguage());
MarkdownContentStateDocumentBuilder builder = new MarkdownContentStateDocumentBuilder();
parser.setBuilder(builder);
parser.parse(markup);
MarkdownContentState markdownContentState = builder.markdownContentState;
LinkDefinitionUsageTracker linkDefinitionUsageTracker = markdownContentState.getLinkDefinitionUsageTracker();
List<ValidationProblem> problems = new ArrayList<ValidationProblem>();
List<Position> missingLinkDefinitionPositions = linkDefinitionUsageTracker.getMissingLinkDefinitionPositions();
for (Position position : missingLinkDefinitionPositions) {
problems.add(new ValidationProblem(Severity.ERROR, MessageFormat.format(// $NON-NLS-1$
Messages.getString("LinkDefinitionValidationRule.missing"), position.getId()), position.getOffset(), position.getLength()));
}
List<Position> unusedLinkDefinitionPositions = linkDefinitionUsageTracker.getUnusedLinkDefinitionPositions();
for (Position position : unusedLinkDefinitionPositions) {
problems.add(new ValidationProblem(Severity.WARNING, MessageFormat.format(// $NON-NLS-1$
Messages.getString("LinkDefinitionValidationRule.unused"), position.getId()), position.getOffset(), position.getLength()));
}
return problems;
}
use of org.eclipse.mylyn.wikitext.validation.ValidationProblem 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));
}
}
Aggregations