use of org.eclipse.mylyn.wikitext.validation.ValidationProblem in project mylyn.docs by eclipse.
the class ListWhitespaceValidationRuleTest method testPositiveMatchStartOfInput.
public void testPositiveMatchStartOfInput() {
String markup = "* a bad list item";
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 ListWhitespaceValidationRuleTest method testPositiveMatchStartOfLine.
public void testPositiveMatchStartOfLine() {
String markup = "some text\n\n* a bad list item";
ValidationProblem problem = rule.findProblem(markup, 0, markup.length());
assertNotNull(problem);
assertEquals(11, problem.getOffset());
}
use of org.eclipse.mylyn.wikitext.validation.ValidationProblem in project mylyn.docs by eclipse.
the class ListWhitespaceValidationRuleTest method testPositiveMatchSecondItemTab.
public void testPositiveMatchSecondItemTab() {
String markup = "some text\n\n * a valid list item\n \t * not a list item\n\nmore text";
ValidationProblem problem = rule.findProblem(markup, 0, markup.length());
assertNotNull(problem);
assertEquals(34, problem.getOffset());
}
use of org.eclipse.mylyn.wikitext.validation.ValidationProblem in project mylyn.docs by eclipse.
the class ListWhitespaceValidationRuleTest method testPositiveMatchNoFollowingWhitespace.
public void testPositiveMatchNoFollowingWhitespace() {
String markup = " *a bad list item";
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 BlockWhitespaceRule method findProblem.
@Override
public ValidationProblem findProblem(String markup, int offset, int length) {
Matcher matcher = pattern.matcher(markup);
if (offset > 0) {
matcher.region(offset, offset + length);
}
while (matcher.find()) {
int start = matcher.start();
boolean startOfLine = false;
if (start == 0) {
startOfLine = true;
} else {
char c = markup.charAt(start - 1);
if (c == '\r' || c == '\n') {
startOfLine = true;
}
}
if (startOfLine) {
String followingCharacter = matcher.group(2);
if (followingCharacter == null || !followingCharacter.equals(" ")) {
// $NON-NLS-1$
int problemLength = matcher.end(1) - start;
String matched = matcher.group(1);
return new ValidationProblem(ValidationProblem.Severity.WARNING, MessageFormat.format(// $NON-NLS-1$
Messages.getString("BlockWhitespaceRule.2"), matched), start, problemLength);
}
}
}
return null;
}
Aggregations