void () { final String s73 = " class A { int A; static int B=5; public abstract void a(int c); void q() { ind d=7; } }"; assertEquals("optional init match in definition", 4, findMatchesCount(s73, " '_Type 'Var = '_Init?; ")); final String s77 = """ class X {{ new ActionListener() {}; }}"""; assertEquals("null match", 0, findMatchesCount(s77, " class 'T:.*aaa {} ")); final String s79 = " class A { static { int c; } void a() { int b; b=1; }} "; assertEquals("body of method by block search", 2, findMatchesCount(s79, " { '_T 'T3 = '_T2?; '_*; } ")); final String s95 = """ class Clazz { private int field; private int field2; private int fielxd2; }"""; assertEquals("first matches, next not", 2, findMatchesCount(s95, " class '_ {private int 'T:field.* ;}")); final String s97 = """ class A { int c; int d; void b(){} void x(){ C d; } } class C { C() { A a; A z; z.b(); a.x(); z.c=1; a.d=2; } }"""; assertEquals("method predicate match", 1, findMatchesCount(s97, "'_.'_:[ref( \"void b(){}\" )] ()")); assertEquals("field predicate match", 1, findMatchesCount(s97, "'_.'_:[ref( \"int c;\" )]")); assertEquals("dcl predicate match", 1, findMatchesCount(s97, "'_:[ref( \"A a;\" )].'_ ();")); final String s99 = "class X {{ char s = '\\u1111'; char s1 = '\\n'; }}"; assertEquals("char constants in pattern", 1, findMatchesCount(s99, " char 'var = '\\u1111'; ")); assertEquals("char constants in pattern 2", 1, findMatchesCount(s99, " char 'var = '\\n'; ")); assertEquals("class predicate match (from definition)", 3, findMatchesCount(s97, "'_:[ref( \"class '_A {}\" )] '_;")); String s107 = """ class A { /* */ void a() { } /* */ int b = 1; /* * */ class C {} }"""; String s108 = """ /* * */\ """; assertEquals("finding comments without typed var", 1, findMatchesCount(s107,s108)); String s109 = """ class X {{ class A { void b(); int b(int c); char d(char e); } A a; a.b(1); a.b(2); a.b(); a.d('e'); a.d('f'); a.d('g'); }}"""; assertEquals("caring about method return type", 2, findMatchesCount(s109, "'_a.'_b:[exprtype( int ) ]('_c*);")); String s111 = "class A { void getManager() { getManager(); } };\n" + "class B { void getManager() { getManager(); getManager(); } };"; assertEquals("caring about missing qualifier type", 2, findMatchesCount(s111, "'_Instance?:[exprtype( B )].getManager()")); assertEquals("static query should not match instance method", 0, findMatchesCount(s111, "'_Instance?:[regex( B )].getManager()")); assertEquals("static query should not match instance method 2", 0, findMatchesCount(s111, "B.getManager()")); String s113 = """ class A { static void a() { a(); }} class B { static void a() { a(); a(); }} """; assertEquals("should care about implicit class qualifier", 2, findMatchesCount(s113, "'_Q?:[regex( B )].a()")); assertEquals("should match simple implicit class qualifier query", 2, findMatchesCount(s113, "B.a()")); assertEquals("instance query should not match static method", 0, findMatchesCount(s113, "'_Q?:[exprtype( B )].a()")); String s115 = """ class A { int a; int f() { return a; }} class B { int a; int g() { return a + a; }} """; assertEquals("should care about implicit instance qualifier", 2, findMatchesCount(s115, "'_Instance?:[exprtype( B )].a")); assertEquals("should not match instance method", 0, findMatchesCount(s115, "A.a")); String s117 = """ class A { static int a; static int f() { return a; }} class B { static int a; static int g() { return a + a; }} """; assertEquals("should care about implicit class qualifier for field", 2, findMatchesCount(s117, "'_Q?:[regex( B )].a")); // b) hierarchy navigation support // c) or search support // e) xml search (down-up, nested query), navigation from xml representation <-> java code // f) impl data conversion (jdk 1.5 style) <-> other from (replace support) // Directions: // @todo different navigation on sub/supertyping relation (fixed depth), methods implementing interface, // g. like predicates // i. performance // more context for top level classes, difference with interface, etc // global issues: // @todo matches out of context // @todo proper regexp support // @todo define strict equality of the matches // @todo search for field selection retrieves packages also }