void () { final String s105 = "class B {} class A extends B { } class C {} class D extends C {}"; assertEquals("extends match", 1, findMatchesCount(s105, "class '_ extends '_:[ref( \"class B {}\" )] {}")); final String s107 = """ interface IA {} interface IB extends IA {} interface IC extends IB {} interface ID extends IC {} class A implements IA {} class B extends A {} class C extends B implements IC {} class D extends C {}"""; assertEquals("extends navigation match", 2, findMatchesCount(s107, "class '_ extends 'Type:+A {}")); assertEquals("extends navigation match 2", 3, findMatchesCount(s107, "interface '_ extends 'Type:*IA {}")); assertEquals("extends navigation match 3", 2, findMatchesCount(s107, "interface '_ extends 'Type:+IA {}")); assertEquals("implements navigation match", 3, findMatchesCount(s107, "class '_ implements 'Type:+IA {}")); assertEquals("without hierarchy finds only direct implements", 1, findMatchesCount(s107, "class '_ implements '_T:IA {}")); final String s109 = """ interface I {} interface I2 extends I {} class A implements I2 {} class B extends A {} class C extends B {} class D { void e() { D d; C c; B b; A a; } }"""; assertEquals("extends navigation match in definition", 3, findMatchesCount(s109, "'_:*A '_;")); assertEquals("implements navigation match in definition 2", 3, findMatchesCount(s109, "'_:*I '_;")); assertEquals("implements navigation match in definition 2 with nested conditions", 3, findMatchesCount(s109, "'_:[ref( \"class '_A:*[regex( I )] {}\" )] '_;")); try { findMatchesCount(s109, "'_:*[regex( I ) && ref2('T)] '_;"); fail("implements navigation match in definition 2 with nested conditions - incorrect cond"); } catch (MalformedPatternException ignored) {} final String s111 = "interface E {} class A implements E {} class B extends A { int f = 0; } class C extends B {} class D { void e() { C c; B b; A a;} }"; final String s112 = "'_"; assertEquals("symbol match", 17, findMatchesCount(s111,s112)); final String s115 = "class B {} public class C {}"; assertEquals("public modifier for class", 1, findMatchesCount(s115, "public class '_ {}")); final String s117 = """ class A { int b; void c() { int e; b=1; this.b=1; e=5; System.out.println(e); System.out.println(b); System.out.println(this.b); } }"""; assertEquals("fields of class", 4, findMatchesCount(s117, "this.'Field")); final String s119 = "class X {{ try { a.b(); } catch(IOException e) { c(); } catch(Exception ex) { d(); }}}"; assertEquals("catches loose matching", 1, findMatchesCount(s119, "try { '_; } catch('_ '_) { '_; }")); assertEquals("catches loose matching 2", 0, findMatchesCount(s119, "try { '_; } catch(Throwable '_) { '_; }")); final String s121 = "class A { private int a; class Inner {} } \n" + "class B extends A { private int a; class Inner2 {} }"; assertEquals("hierarchical matching", 2, findMatchesCount(s121, "class '_ { int '_:* ; }")); assertEquals("hierarchical matching 2", 4, findMatchesCount(s121, "class '_ { int '_:+hashCode (); }")); assertEquals("hierarchical matching 3", 2, findMatchesCount(s121, "class '_ { class '_:* {} }")); }