void () { String source = """ abstract class A<T/*1*/> implements java.util.List<T/*2*/>, /*3*/java.io.Serializable { @SuppressWarnings({"one",/*10*/ "two"}) public /*11*/ static void m(/*12*/) { System./*4*/out.println(/*5*/); A<String/*6*/> a1 = new A(){}; int i = 1 + /*7*/ + 2; try (java.io.FileInputStream /*8*/in = new java.io.FileInputStream("name")) { } catch (java.lang./*9*/Exception e) { } } }"""; String pattern = "/*$Text$*/"; assertEquals("should find comments in all the right places", 12, findMatchesCount(source, pattern)); String source2 = """ package /*test*/ xxx; import /*test*/ java.util.*; public class XXX {}"""; String pattern2 = "/*test*/"; assertEquals("find comments in package and import statements", 2, findMatchesCount(source2, pattern2)); String source3 = """ class X { void m() { System.out.println(); // tokamak } }"""; String pattern3 = "'_st;\n" + "// tokamak"; assertEquals("find statement followed by comment", 1, findMatchesCount(source3, pattern3)); String source4 = "/*"; String pattern4 = "//'_comment:[regex( .* )]"; assertEquals("no error on broken code", 1, findMatchesCount(source4, pattern4)); }