Search in sources :

Example 16 with Comment

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

the class JavadocUtilTest method testTagType.

@Test
public void testTagType() {
    final String[] text = { "/** @see block", " * {@link List inline}, {@link List#add(Object)}" };
    final Comment comment = new Comment(text, 1, 2, text[1].length());
    final JavadocTags blockTags = JavadocUtil.getJavadocTags(comment, JavadocUtil.JavadocTagType.BLOCK);
    final JavadocTags inlineTags = JavadocUtil.getJavadocTags(comment, JavadocUtil.JavadocTagType.INLINE);
    assertWithMessage("Invalid valid tags size").that(blockTags.getValidTags()).hasSize(1);
    assertWithMessage("Invalid valid tags size").that(inlineTags.getValidTags()).hasSize(2);
}
Also used : Comment(com.puppycrawl.tools.checkstyle.api.Comment) JavadocTags(com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocTags) Test(org.junit.jupiter.api.Test)

Example 17 with Comment

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

the class JavadocUtilTest method testTagPositions.

@Test
public void testTagPositions() {
    final String[] text = { "/** @see elsewhere", "    also {@link Name value} */" };
    final Comment comment = new Comment(text, 1, 2, text[1].length());
    final List<JavadocTag> tags = JavadocUtil.getJavadocTags(comment, JavadocUtil.JavadocTagType.ALL).getValidTags();
    assertWithMessage("Invalid tags size").that(tags).hasSize(2);
    final JavadocTag seeTag = tags.get(0);
    assertWithMessage("Invalid tag name").that(seeTag.getTagName()).isEqualTo(JavadocTagInfo.SEE.getName());
    assertWithMessage("Invalid line number").that(seeTag.getLineNo()).isEqualTo(1);
    assertWithMessage("Invalid column number").that(seeTag.getColumnNo()).isEqualTo(4);
    final JavadocTag linkTag = tags.get(1);
    assertWithMessage("Invalid tag name").that(linkTag.getTagName()).isEqualTo(JavadocTagInfo.LINK.getName());
    assertWithMessage("Invalid line number").that(linkTag.getLineNo()).isEqualTo(2);
    assertWithMessage("Invalid column number").that(linkTag.getColumnNo()).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)

Example 18 with Comment

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

the class JavadocUtilTest method testInlineTagLinkText.

@Test
public void testInlineTagLinkText() {
    final String[] text = { "/** {@link List link text }" };
    final Comment comment = new Comment(text, 1, 1, text[0].length());
    final List<JavadocTag> tags = JavadocUtil.getJavadocTags(comment, JavadocUtil.JavadocTagType.ALL).getValidTags();
    assertWithMessage("Invalid first arg").that(tags.get(0).getFirstArg()).isEqualTo("List link text");
}
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