use of org.eclipse.mylyn.wikitext.validation.ValidationProblem in project mylyn.docs by eclipse.
the class TestMarkupValidationRule method findProblem.
@Override
public ValidationProblem findProblem(String markup, int offset, int length) {
Matcher matcher = pattern.matcher(markup);
if (offset > 0 || length != markup.length()) {
matcher.region(offset, offset + length);
}
if (matcher.find()) {
String group = matcher.group(1);
Severity severity;
if ("ERROR".equals(group)) {
severity = Severity.ERROR;
} else {
severity = Severity.WARNING;
}
return new ValidationProblem(severity, "test error", matcher.start(1), matcher.end(1) - matcher.start(1));
}
return null;
}
use of org.eclipse.mylyn.wikitext.validation.ValidationProblem in project mylyn.docs by eclipse.
the class CommentValidationRuleTest method testOk.
public void testOk() {
String markup = "a <!-- valid comment -->";
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 CommentValidationRule method findProblem.
@Override
public ValidationProblem findProblem(String markup, int offset, int length) {
Matcher matcher = commentPattern.matcher(markup);
if (offset > 0 || length != markup.length()) {
matcher.region(offset, offset + length);
}
if (matcher.find()) {
int problemOffset = matcher.start();
int problemLength = Math.max(2, matcher.end() - problemOffset);
return new // $NON-NLS-1$
ValidationProblem(// $NON-NLS-1$
Severity.WARNING, // $NON-NLS-1$
Messages.getString("CommentValidationRule.1"), problemOffset, problemLength);
}
return null;
}
use of org.eclipse.mylyn.wikitext.validation.ValidationProblem in project mylyn.docs by eclipse.
the class StandaloneMarkupValidatorTest method testSimple.
public void testSimple() {
List<ValidationProblem> problems = validator.validate("some text ERROR more text WARNING and ERROR");
assertNotNull(problems);
assertEquals(3, problems.size());
ValidationProblem first = problems.get(0);
assertEquals(Severity.ERROR, first.getSeverity());
assertEquals(10, first.getOffset());
assertEquals(5, first.getLength());
ValidationProblem second = problems.get(1);
assertEquals(Severity.WARNING, second.getSeverity());
assertEquals(26, second.getOffset());
assertEquals(7, second.getLength());
ValidationProblem third = problems.get(2);
assertEquals(Severity.ERROR, third.getSeverity());
assertEquals(38, third.getOffset());
assertEquals(5, third.getLength());
}
use of org.eclipse.mylyn.wikitext.validation.ValidationProblem in project mylyn.docs by eclipse.
the class ListWhitespaceValidationRule method findProblem.
@Override
public ValidationProblem findProblem(String markup, int offset, int length) {
Matcher matcher = almostListPattern.matcher(markup);
if (offset > 0 || length != markup.length()) {
matcher.region(offset, offset + length);
}
while (matcher.find()) {
String spaces = matcher.group(1);
if (spaces == null || spaces.length() == 0 || (spaces.length() % 3) != 0 || containsNonSpace(spaces)) {
int problemOffset = matcher.start();
int problemLength = Math.max(2, matcher.end(2) - problemOffset);
return new ValidationProblem(Severity.WARNING, Messages.getString("ListWhitespaceValidationRule.1"), problemOffset, // $NON-NLS-1$
problemLength);
}
String after = matcher.group(5);
if (after != null) {
int problemOffset = matcher.start();
int problemLength = Math.max(2, matcher.end(2) - problemOffset);
return new // $NON-NLS-1$
ValidationProblem(// $NON-NLS-1$
Severity.WARNING, // $NON-NLS-1$
Messages.getString("ListWhitespaceValidationRule.2"), problemOffset, problemLength);
}
}
return null;
}
Aggregations