void () { final String s = """ class A { void m() { /** tool */ class Local {} } }"""; assertEquals("dangling javadoc followed by a local class", 1, findMatchesCount(s, "{\n/** tool */\nclass 'A {}\n}")); assertEquals("class with javadoc shouldn't find dangling javadoc and local class", 0, findMatchesCount(s, "/** tool */\nclass 'A {}")); final String s57 = """ /** @author Maxim */ class C { private int value; } class D { /** @serial */ private int value; private int value2; /** @since 1.4 */ void a() {} } class F { /** @since 1.4 */ void a() {} /** @serial */ private int value2; } class G { /** @param a*/ void a() {} }"""; assertEquals("java doc comment in class in file", 1, findMatchesCount(s57, "/** @'T '_T2 */ class '_ { }")); assertEquals("javadoc comment for field", 2, findMatchesCount(s57, "class '_ { /** @serial '_* */ '_ '_; }")); assertEquals("javadoc comment for method", 2, findMatchesCount(s57, "class '_ { /** @'T 1.4 */ '_ '_() {} }")); assertEquals("javadoc comment for method 2", 2, findMatchesCount(s57, "/** @'T 1.4 */ '_t '_m();")); assertEquals("just javadoc comment search", 4, findMatchesCount(s57, "/** @'T '_T2 */")); assertEquals("optional tag value match", 6, findMatchesCount(s57, "/** @'T '_T2? */")); assertEquals("no infinite loop on javadoc matching", 1, findMatchesCount(s57, "/** 'Text */ class '_ { }")); final String s83 = """ /** * @hibernate.class * table="CATS" */ public class Cat { private Long id; // identifier private Date birthdate; /** * @hibernate.id * generator-class="native" * column="CAT_ID" */ public Long getId() { return id; } private void setId(Long id) { this.id=id; } /** * @hibernate.property * column="BIRTH_DATE" */ public Date getBirthdate() { return birthdate; } void setBirthdate(Date date) { birthdate = date; } /** * @hibernate.property * column="SEX" * not-null="true" * update="false" */ public char getSex() { return sex; } void setSex(char sex) { this.sex=sex; } }"""; assertEquals("XDoclet metadata", 2, findMatchesCount(s83, """ /** * @hibernate.property * 'Property */ """)); assertEquals("XDoclet metadata 2", 1, findMatchesCount(s83, """ /** * @hibernate.property * update="fa.se" */ """)); final String s75 = """ /** @class aClass @author the author */ class A {} /** */ class B {} /** @class aClass */ class C {}"""; assertEquals("multiple tags match +", 2, findMatchesCount(s75, " /** @'_tag+ '_value+ */")); assertEquals("multiple tags match *", 3, findMatchesCount(s75, " /** @'_tag* '_value* */")); assertEquals("multiple tags match ?", 3, findMatchesCount(s75, " /** @'_tag? '_value? */ class 't {}")); final String source = """ class outer { /** bla */ class One {} class Two {} }"""; final String pattern = "class '_A { /** '_Text */class 'B {}}"; assertEquals("match inner class with javadoc", 1, findMatchesCount(source, pattern)); final String in = """ class X { /** * cool */ void x1() {} /** * cool * @since 1.1 */ void x2() {} /** * uncool * @since 2.1 */ void x3() {} }"""; assertEquals("match text & tag", 1, findMatchesCount(in, """ /** '_c:cool * @since '_x */""")); assertEquals("match text & tag 2", 1, findMatchesCount(in, """ /** * cool * @since '_x */""")); assertEquals("match tag, ignore text", 1, findMatchesCount(in, "/** '_c\n" + " * @since 2.1 */")); final String in2 = """ class X { /** * */ void empty() {} /** * @since 1.1 */ void x() {} /** * text */ void y() {} }"""; assertEquals("match empty javadoc", 1, findMatchesCount(in2, """ /** * @'_tag{0,0} */""")); }