void () { final String in = """ class X { void x(int i) { switch (i) { case 10: System.out.println(10); } switch (i) { case 1: default: } switch (i) { case 1: default: } switch (i) { case 1: case 2: default: } } }"""; assertEquals("Should find switch with one case", 1, findMatchesCount(in, """ switch ('_a) { case '_c : '_st*; }""")); assertEquals("should find switch with 2 cases", 2, findMatchesCount(in, """ switch ('_a) { case '_c1 : case '_c2? : }""")); assertEquals("should find swith with one case and default", 2, findMatchesCount(in, """ switch ('_a) { case '_c : '_st1*; default: '_st2*; }""")); assertEquals("should find defaults", 3, findMatchesCount(in, "default:")); assertEquals("should find cases", 5, findMatchesCount(in, "case '_a :")); assertEquals("should find cases & defaults", 8, findMatchesCount(in, "case '_a? :")); assertEquals("should match switch containing 2 statements", 3, findMatchesCount(in, """ switch ('_x) { '_st{2,2}; }""")); }