CommentUtil { @Deprecated public static Map<String, Integer> javadocTagsIn(String comment) { Map<String, Integer> tags = new HashMap<>(); if (comment != null) { Matcher m = JAVADOC_TAG.matcher(comment); while (m.find()) { String match = comment.substring(m.start() + 1, m.end()); tags.put(match, m.start()); } } return tags; } private  CommentUtil(); @Deprecated // will be removed with PMD 7.0.0 static String wordAfter(String text, int position); @Deprecated // will be removed with PMD 7.0.0 static String javadocContentAfter(String text, int position); @Deprecated // will be removed with PMD 7.0.0 static Map<String, Integer> javadocTagsIn(String comment); @Deprecated // will be removed with PMD 7.0.0 static List<String> multiLinesIn(String comment); @Deprecated // will be removed with PMD 7.0.0 static List<String> trim(List<String> lines);  }
@Test public void testFindJavaDocTags() { String formalComment = "\n"; Map<String, Integer> javadocTagsIn = CommentUtil.javadocTagsIn(formalComment); Assert.assertEquals(3, javadocTagsIn.size()); Assert.assertEquals(7, javadocTagsIn.get("see").intValue()); Assert.assertEquals("@see", formalComment.substring(7, 7 + 4)); Assert.assertEquals("@author", formalComment.substring(javadocTagsIn.get("author"), javadocTagsIn.get("author") + "author".length() + 1)); }
@Test public void testFindJavaDocTagsEmpty() { Map<String, Integer> javadocTagsIn = CommentUtil.javadocTagsIn(""); Assert.assertEquals(0, javadocTagsIn.size()); }
@Test public void testFindJavaDocTagsNull() { Map<String, Integer> javadocTagsIn = CommentUtil.javadocTagsIn(null); Assert.assertEquals(0, javadocTagsIn.size()); }