Search in sources :

Example 1 with Comment

use of com.puppycrawl.tools.checkstyle.api.Comment in project checkstyle by checkstyle.

the class CommentsTest method testToString.

@Test
public void testToString() {
    final Comment comment = new Comment(new String[] { "value" }, 1, 2, 3);
    Assert.assertEquals("Comment[2:1-2:3]", comment.toString());
}
Also used : Comment(com.puppycrawl.tools.checkstyle.api.Comment) Test(org.junit.Test)

Example 2 with Comment

use of com.puppycrawl.tools.checkstyle.api.Comment in project checkstyle by checkstyle.

the class JavadocUtilsTest method testInlineTagMethodRef.

@Test
public void testInlineTagMethodRef() {
    final String[] text = { "/** {@link List#add(Object)}" };
    final Comment comment = new Comment(text, 1, 1, text[0].length());
    final List<JavadocTag> tags = JavadocUtils.getJavadocTags(comment, JavadocUtils.JavadocTagType.ALL).getValidTags();
    assertEquals("List#add(Object)", tags.get(0).getFirstArg());
}
Also used : Comment(com.puppycrawl.tools.checkstyle.api.Comment) JavadocTag(com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocTag) Test(org.junit.Test)

Example 3 with Comment

use of com.puppycrawl.tools.checkstyle.api.Comment in project checkstyle by checkstyle.

the class JavadocUtilsTest method testTags.

@Test
public void testTags() {
    final String[] text = { "/** @see elsewhere ", " * {@link List }, {@link List link text }", "   {@link List#add(Object) link text}", " * {@link Class link text}" };
    final Comment comment = new Comment(text, 1, 4, text[3].length());
    final JavadocTags allTags = JavadocUtils.getJavadocTags(comment, JavadocUtils.JavadocTagType.ALL);
    assertEquals(5, allTags.getValidTags().size());
}
Also used : Comment(com.puppycrawl.tools.checkstyle.api.Comment) JavadocTags(com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocTags) Test(org.junit.Test)

Example 4 with Comment

use of com.puppycrawl.tools.checkstyle.api.Comment in project checkstyle by checkstyle.

the class CommentsTest method testGetCommentMeasures.

@Test
public void testGetCommentMeasures() {
    final String[] commentText = { "/**", "     * Creates new instance.", "     * @param text the lines that make up the comment.", "     * @param firstCol number of the first column of the comment.", "     * @param lastLine number of the last line of the comment.", "     * @param lastCol number of the last column of the comment.", "     */" };
    final Comment comment = new Comment(commentText, 5, 49, 66);
    assertWithMessage("Invalid comment start line number").that(comment.getStartLineNo()).isEqualTo(43);
    assertWithMessage("Invalid comment start column number").that(comment.getStartColNo()).isEqualTo(5);
    assertWithMessage("Invalid comment end line number").that(comment.getEndLineNo()).isEqualTo(49);
    assertWithMessage("Invalid comment end column number").that(comment.getEndColNo()).isEqualTo(66);
}
Also used : Comment(com.puppycrawl.tools.checkstyle.api.Comment) Test(org.junit.jupiter.api.Test)

Example 5 with Comment

use of com.puppycrawl.tools.checkstyle.api.Comment in project checkstyle by checkstyle.

the class JavadocUtilTest method testInlineTagPositions.

@Test
public void testInlineTagPositions() {
    final String[] text = { "/** Also {@link Name value} */" };
    final Comment comment = new Comment(text, 1, 0, text[0].length());
    final List<JavadocTag> tags = JavadocUtil.getJavadocTags(comment, JavadocUtil.JavadocTagType.INLINE).getValidTags();
    assertWithMessage("Invalid tags size").that(tags).hasSize(1);
    final int lineNo = tags.get(0).getLineNo();
    assertWithMessage("Unexpected line number").that(lineNo).isEqualTo(0);
    final int columnNo = tags.get(0).getColumnNo();
    assertWithMessage("Unexpected column number").that(columnNo).isEqualTo(10);
}
Also used : Comment(com.puppycrawl.tools.checkstyle.api.Comment) InvalidJavadocTag(com.puppycrawl.tools.checkstyle.checks.javadoc.InvalidJavadocTag) JavadocTag(com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocTag) Test(org.junit.jupiter.api.Test)

Aggregations

Comment (com.puppycrawl.tools.checkstyle.api.Comment)18 Test (org.junit.jupiter.api.Test)11 JavadocTag (com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocTag)8 JavadocTags (com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocTags)7 Test (org.junit.Test)7 InvalidJavadocTag (com.puppycrawl.tools.checkstyle.checks.javadoc.InvalidJavadocTag)5