void () { String s1 = """ class A implements I {} interface I {} class B extends A implements I { } class B2 implements I { } class B3 extends A { } class C extends B2 { static void foo(); } """; assertEquals("Find class within type hierarchy with not", 1, findMatchesCount(s1, "class '_ extends '_Extends:[!regex( *A )] implements '_Implements:[regex( *I )] {}")); assertEquals("Find class within type hierarchy with not 2", 2, findMatchesCount(s1, "class '_C:[!regex( *A )] implements '_Implements:[regex( *I )] {}")); assertEquals("Find class within type hierarchy with not 3", 1, findMatchesCount(s1, "class '_ extends '_Extends:[!regex( *A )]{}")); assertEquals("Search in hierarchy on class identifier", 2, findMatchesCount(s1, "class '_X:*B2 {}")); String in2 = """ class A {} class B extends A {{ new Object() {}; new A() {}; new B() {}; new B(); new Object(); }}"""; assertEquals("Find anonymous class in hierarchy", 2, findMatchesCount(in2, "new '_X:*A () {}")); assertEquals("Find new expression in hierarchy", 3, findMatchesCount(in2, "new '_X:*A ()")); assertEquals("Find anonymous class in hierarchy negated", 1, findMatchesCount(in2, "new '_X:!*A () {}")); String in3 = """ class A {} class B extends A {} class C extends B {} class D extends Object {}"""; assertEquals("Find in hierarchy negated on class identifier", 1, findMatchesCount(in3, "class '_X:!*A {}")); }