void () { final String s43 = """ interface A extends B { int B = 1; } interface D { public final static double e = 1; } interface E { final static ind d = 2; } interface F { }"""; assertEquals("no modifier for interface vars", 3, findMatchesCount(s43, "interface '_ { '_T 'T2 = '_T3; } ")); final String s45 = """ class A extends B { private static final int B = 1; } class C extends D { int B = 1; } class E { }"""; assertEquals("different order of access modifiers", 1, findMatchesCount(s45, "class '_ { final static private '_T 'T2 = '_T3; } ")); assertEquals("no access modifier", 2, findMatchesCount(s45, "class '_ { '_T 'T2 = '_T3; } ")); final String s47 = "class C { java.lang.String t; } class B { BufferedString t2;} class A { String p;} "; assertEquals("type differs with package", 2, findMatchesCount(s47, "class '_ { String '_; }")); final String s49 = "class C { void a() throws java.lang.RuntimeException {} } class B { BufferedString t2;}"; assertEquals("reference could differ in package", 1, findMatchesCount(s49, "class '_ { '_ '_() throws RuntimeException; }")); String s51 = "class C extends java.awt.List {} class A extends java.util.List {} class B extends java.awt.List {} "; assertEquals("reference could differ in package 2", 2, findMatchesCount(s51, "class 'B extends '_C:java\\.awt\\.List {}")); final String s93 = """ class A { private int field; public void b() {} }"""; assertEquals("method access modifier", 0, findMatchesCount(s93, " class '_ {private void b() {}}")); assertEquals("method access modifier 2", 1, findMatchesCount(s93, " class '_ {public void b() {}}")); assertEquals("field access modifier", 0, findMatchesCount(s93, " class '_ {protected int field;}")); assertEquals("field access modifier 2", 1, findMatchesCount(s93, " class '_ {private int field;}")); final String s127 = "class a { void b() { new c() {}; } }"; assertEquals("class finds anonymous class", 2, findMatchesCount(s127, "class 't {}")); final String s129 = """ class a { public void run() {} } class a2 { public void run() { run(); } } class a3 { public void run() { run(); } } class a4 { public void run(); }"""; assertEquals("empty method finds empty method only", 1, findMatchesCount(s129, "class 'a { public void run() {} }")); assertEquals("nonempty method finds nonempty method", 2, findMatchesCount(s129, "class 'a { public void run() { '_statement; } }")); assertEquals("nonempty method finds nonempty method", 4, findMatchesCount(s129, "class 'a { public void run(); }")); final String s133 = """ class S { void cc() { new Runnable() { public void run() { f(); } private void f() { //To change body of created methods use File | Settings | File Templates. } }; new Runnable() { public void run() { f(); } private void g() { //To change body of created methods use File | Settings | File Templates. } }; new Runnable() { public void run() { f(); } }; } private void f() { //To change body of created methods use File | Settings | File Templates. } }"""; final String s134 = """ new Runnable() { public void run() { '_f (); } private void '_f (); }"""; assertEquals( "complex expr matching", 1, findMatchesCount(s133,s134) ); final String s135 = """ abstract class My { abstract void f(); } abstract class My2 { abstract void f(); void fg() {} }"""; final String s136 = """ class 'm { void f(); '_type '_method{0,0} ('_paramtype '_paramname* ); }"""; assertEquals("reject method with 0 max occurence", 1, findMatchesCount(s135,s136)); final String s137 = """ abstract class My { int a; } abstract class My2 { Project b; } abstract class My3 { Class clazz; Project b = null; } abstract class My { int a = 1; } """; assertEquals("reject field with 0 max occurence", 2, findMatchesCount(s137, "class 'm { Project '_f{0,0} = '_t?; }")); final String s139 = "class My { boolean equals(Object o); int hashCode(); }"; final String s140 = "class 'A { boolean equals(Object '_o ); int '_hashCode{0,0}:hashCode (); }"; assertEquals("reject method with constraint", 0, findMatchesCount(s139,s140)); final String s139_2 = "class My { boolean equals(Object o); }"; assertEquals("reject field with 0 max occurence", 1, findMatchesCount(s139_2,s140)); final String s141 = """ class A { static { a = 10; } } class B { { a = 10; } } class C { { a = 10; } }"""; assertEquals("static block search", 1, findMatchesCount(s141, "class '_ { static { a = 10; } } ")); final String in = "class D<T> {}\n" + "class T {}"; assertEquals("search for class should not find type parameters", 2, findMatchesCount(in, "class 'A {}")); }