Search in sources :

Example 6 with ValidationProblem

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());
}
Also used : ValidationProblem(org.eclipse.mylyn.wikitext.validation.ValidationProblem)

Example 7 with ValidationProblem

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());
}
Also used : ValidationProblem(org.eclipse.mylyn.wikitext.validation.ValidationProblem)

Example 8 with ValidationProblem

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());
}
Also used : ValidationProblem(org.eclipse.mylyn.wikitext.validation.ValidationProblem)

Example 9 with ValidationProblem

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());
}
Also used : ValidationProblem(org.eclipse.mylyn.wikitext.validation.ValidationProblem)

Example 10 with ValidationProblem

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;
}
Also used : Matcher(java.util.regex.Matcher) ValidationProblem(org.eclipse.mylyn.wikitext.validation.ValidationProblem)

Aggregations

ValidationProblem (org.eclipse.mylyn.wikitext.validation.ValidationProblem)27 Matcher (java.util.regex.Matcher)4 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 BuildException (org.apache.tools.ant.BuildException)2 StandaloneMarkupValidator (org.eclipse.mylyn.wikitext.validation.StandaloneMarkupValidator)2 Map (java.util.Map)1 IMarker (org.eclipse.core.resources.IMarker)1 BadLocationException (org.eclipse.jface.text.BadLocationException)1 ISynchronizable (org.eclipse.jface.text.ISynchronizable)1 Position (org.eclipse.jface.text.Position)1 Annotation (org.eclipse.jface.text.source.Annotation)1 IAnnotationModelExtension (org.eclipse.jface.text.source.IAnnotationModelExtension)1 MarkdownLanguage (org.eclipse.mylyn.wikitext.markdown.MarkdownLanguage)1 LinkDefinitionUsageTracker (org.eclipse.mylyn.wikitext.markdown.internal.LinkDefinitionUsageTracker)1 Position (org.eclipse.mylyn.wikitext.markdown.internal.LinkDefinitionUsageTracker.Position)1 MarkdownContentState (org.eclipse.mylyn.wikitext.markdown.internal.MarkdownContentState)1 MarkupParser (org.eclipse.mylyn.wikitext.parser.MarkupParser)1 Severity (org.eclipse.mylyn.wikitext.validation.ValidationProblem.Severity)1