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());
}
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());
}
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());
}
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);
}
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);
}
Aggregations