use of com.puppycrawl.tools.checkstyle.api.Comment in project checkstyle by checkstyle.
the class JavadocUtilsTest 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 = JavadocUtils.getJavadocTags(comment, JavadocUtils.JavadocTagType.ALL).getValidTags();
assertEquals(2, tags.size());
for (final JavadocTag tag : tags) {
if (JavadocTagInfo.SEE.getName().equals(tag.getTagName())) {
assertEquals(1, tag.getLineNo());
assertEquals(5, tag.getColumnNo());
} else if (JavadocTagInfo.LINK.getName().equals(tag.getTagName())) {
assertEquals(2, tag.getLineNo());
assertEquals(10, tag.getColumnNo());
} else {
fail("Unexpected tag: " + tag);
}
}
}
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);
assertWithMessage("Invalid toString result").that(comment.toString()).isEqualTo("Comment[text=[value], startLineNo=2, endLineNo=2, " + "startColNo=1, endColNo=3]");
}
use of com.puppycrawl.tools.checkstyle.api.Comment in project checkstyle by checkstyle.
the class CommentsTest method testIntersects.
@Test
public void testIntersects() {
final String[] commentText = { "// compute a single number for start and end", "// to simplify conditional logic" };
final Comment comment = new Comment(commentText, 9, 89, 53);
assertWithMessage("Invalid intersection result").that(comment.intersects(89, 9, 89, 41)).isTrue();
assertWithMessage("Invalid intersection result").that(comment.intersects(89, 53, 90, 50)).isTrue();
assertWithMessage("Invalid intersection result").that(comment.intersects(87, 7, 88, 9)).isTrue();
assertWithMessage("Invalid intersection result").that(comment.intersects(90, 7, 91, 20)).isFalse();
assertWithMessage("Invalid intersection result").that(comment.intersects(89, 56, 89, 80)).isFalse();
}
use of com.puppycrawl.tools.checkstyle.api.Comment in project checkstyle by checkstyle.
the class JavadocUtilTest 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 = JavadocUtil.getJavadocTags(comment, JavadocUtil.JavadocTagType.ALL).getValidTags();
assertWithMessage("Invalid first arg").that(tags.get(0).getFirstArg()).isEqualTo("List#add(Object)");
}
use of com.puppycrawl.tools.checkstyle.api.Comment in project checkstyle by checkstyle.
the class JavadocUtilTest 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 = JavadocUtil.getJavadocTags(comment, JavadocUtil.JavadocTagType.ALL);
assertWithMessage("Invalid valid tags size").that(allTags.getValidTags()).hasSize(5);
}
Aggregations