Index: src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java =================================================================== RCS file: /home/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java,v retrieving revision 1.48 diff -u -r1.48 JavaSearchBugsTests.java --- src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java 15 Jun 2005 06:30:01 -0000 1.48 +++ src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java 7 Jul 2005 16:53:09 -0000 @@ -30,6 +30,7 @@ * Non-regression tests for bugs fixed in Java Search engine. */ public class JavaSearchBugsTests extends AbstractJavaSearchTests implements IJavaSearchConstants { + private final static int UI_DECLARATIONS = DECLARATIONS|IGNORE_DECLARING_TYPE|IGNORE_RETURN_TYPE; public JavaSearchBugsTests(String name) { super(name); @@ -44,8 +45,8 @@ // org.eclipse.jdt.internal.core.search.BasicSearchEngine.VERBOSE = true; // org.eclipse.jdt.internal.codeassist.SelectionEngine.DEBUG = true; // TESTS_PREFIX = "testBug97547"; -// TESTS_NAMES = new String[] { "testBug83304" }; -// TESTS_NUMBERS = new int[] { 99600 }; +// TESTS_NAMES = new String[] { "testBug100772_ClassAndSubclass04" }; + TESTS_NUMBERS = new int[] { 100772 }; // TESTS_RANGE = new int[] { 83304, -1 }; } @@ -3329,34 +3330,6 @@ } /** - * Bug 97087: [1.5][search] Can't find reference of generic class's constructor. - * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=97087" - */ - public void testBug97087() throws CoreException { - workingCopies = new ICompilationUnit[1]; - this.resultCollector.showRule = true; - workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b97087/Bug.java", - "package b97087;\n" + - "public class Bug {\n" + - " Bug(){}\n" + - "}\n" + - "class Foo extends Bug{\n" + - " Foo(){}\n" + - "}\n" + - "class Bar extends Bug{\n" + - " Bar(){super();}\n" + - "}" - ); - IType type = workingCopies[0].getType("Bug"); - IMethod method= type.getMethods()[0]; - search(method, REFERENCES, SearchPattern.R_ERASURE_MATCH); - assertSearchResults( - "src/b97087/Bug.java b97087.Foo() [Foo] EXACT_MATCH\n" + - "src/b97087/Bug.java b97087.Bar() [super()] ERASURE_MATCH" - ); - } - - /** * Bug 96761: [1.5][search] Search for declarations of generic method finds non-overriding method * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=96761" */ @@ -3416,7 +3389,7 @@ "src/b96763/Test.java void b96763.Sub.second(Exception) [second] EXACT_MATCH" ); } - public void testBug96763d() throws CoreException { + public void testBug96763c() throws CoreException { workingCopies = new ICompilationUnit[1]; workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b96763/Test.java", "package b96763;\n" + @@ -3436,6 +3409,60 @@ } /** + * Bug 97087: [1.5][search] Can't find reference of generic class's constructor. + * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=97087" + */ + public void testBug97087() throws CoreException { + workingCopies = new ICompilationUnit[1]; + this.resultCollector.showRule = true; + workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b97087/Bug.java", + "package b97087;\n" + + "public class Bug {\n" + + " Bug(){}\n" + + "}\n" + + "class Foo extends Bug{\n" + + " Foo(){}\n" + + "}\n" + + "class Bar extends Bug{\n" + + " Bar(){super();}\n" + + "}" + ); + IType type = workingCopies[0].getType("Bug"); + IMethod method= type.getMethods()[0]; + search(method, REFERENCES, SearchPattern.R_ERASURE_MATCH); + assertSearchResults( + "src/b97087/Bug.java b97087.Foo() [Foo] EXACT_MATCH\n" + + "src/b97087/Bug.java b97087.Bar() [super()] ERASURE_MATCH" + ); + } + + /** + * Bug 97120: + * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=97120" + */ + public void testBug97120() throws CoreException { + IType type = getClassFile("JavaSearchBugs", getExternalJCLPathString("1.5"), "java.lang", "Throwable.class").getType(); + IJavaSearchScope scope = SearchEngine.createHierarchyScope(type); + TypeNameRequestor requestor = new SearchTests.SearchTypeNameRequestor(); + new SearchEngine().searchAllTypeNames( + null, + "E*".toCharArray(), + SearchPattern.R_PATTERN_MATCH, + TYPE, + scope, + requestor, + IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, + null + ); + assertSearchResults( + "Unexpected all type names", + "java.lang.Error\n" + + "java.lang.Exception", + requestor + ); + } + + /** * Bug 97322: [search] Search for method references sometimes reports potential match with differing argument count * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=97322" */ @@ -3709,4 +3736,388 @@ "src/b99600/Test.java int b99600.Test$C2$C3.foo(C1) [foo(C1 c)] EXACT_MATCH" ); } + + /** + * Bug 100695: [1.5][search] Renaming a field of generic array type has no effect + * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=100695" + */ + public void testBug100695() throws CoreException { + workingCopies = new ICompilationUnit[1]; + workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b100695/Test.java", + "package b100695;\n" + + "public class Test {\n" + + " Class[] foo;\n" + + " Class[] bar = foo;\n" + + " Test() {\n" + + " foo = null;\n" + + " }\n" + + "}\n" + ); + IField field = workingCopies[0].getType("Test").getField("foo"); + search(field, REFERENCES); + this.discard = false; + assertSearchResults( + "src/b100695/Test.java b100695.Test.bar [foo] EXACT_MATCH\n" + + "src/b100695/Test.java b100695.Test() [foo] EXACT_MATCH" + ); + } + public void testBug100695a() throws CoreException { + assertNotNull("There should be working copies!", workingCopies); + assertEquals("Invalid number of working copies kept between tests!", 1, workingCopies.length); + IField field = workingCopies[0].getType("Test").getField("foo"); + search(field, ALL_OCCURRENCES); + assertSearchResults( + "src/b100695/Test.java b100695.Test.foo [foo] EXACT_MATCH\n" + + "src/b100695/Test.java b100695.Test.bar [foo] EXACT_MATCH\n" + + "src/b100695/Test.java b100695.Test() [foo] EXACT_MATCH" + ); + } + public void testBug100695b() throws CoreException { + workingCopies = new ICompilationUnit[1]; + workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b100695/Test.java", + "package b100695;\n" + + "public class Test {\n" + + " Class foo;\n" + + " Class bar = foo;\n" + + " Test() {\n" + + " foo = null;\n" + + " }\n" + + "}\n" + ); + IField field = workingCopies[0].getType("Test").getField("foo"); + search(field, ALL_OCCURRENCES); + assertSearchResults( + "src/b100695/Test.java b100695.Test.foo [foo] EXACT_MATCH\n" + + "src/b100695/Test.java b100695.Test.bar [foo] EXACT_MATCH\n" + + "src/b100695/Test.java b100695.Test() [foo] EXACT_MATCH" + ); + } + public void testBug100695c() throws CoreException { + workingCopies = new ICompilationUnit[1]; + workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b100695/Test.java", + "package b100695;\n" + + "public class Test {\n" + + " Class[] foo;\n" + + " Class[] bar = foo;\n" + + " Test() {\n" + + " foo = null;\n" + + " }\n" + + "}\n" + ); + IField field = workingCopies[0].getType("Test").getField("foo"); + search(field, ALL_OCCURRENCES); + assertSearchResults( + "src/b100695/Test.java b100695.Test.foo [foo] EXACT_MATCH\n" + + "src/b100695/Test.java b100695.Test.bar [foo] EXACT_MATCH\n" + + "src/b100695/Test.java b100695.Test() [foo] EXACT_MATCH" + ); + } + public void testBug100695d() throws CoreException { + workingCopies = new ICompilationUnit[1]; + workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b100695/Test.java", + "package b100695;\n" + + "public class Test {\n" + + " public Class[] foo(Class[] a) {\n" + + " return a;\n" + + " }\n" + + " void bar() {\n" + + " foo(new Class[0]);\n" + + " }\n" + + "}\n" + ); + IMethod method = workingCopies[0].getType("Test").getMethods()[0]; + search(method, ALL_OCCURRENCES); + assertSearchResults( + "src/b100695/Test.java Class[] b100695.Test.foo(Class[]) [foo] EXACT_MATCH\n" + + "src/b100695/Test.java void b100695.Test.bar() [foo(new Class[0])] EXACT_MATCH" + ); + } + public void testBug100695e() throws CoreException { + workingCopies = new ICompilationUnit[1]; + workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b100695/Test.java", + "package b100695;\n" + + "public class Test {\n" + + " public Class foo(Class a) {\n" + + " return a;\n" + + " }\n" + + " void bar() {\n" + + " foo(null);\n" + + " }\n" + + "}\n" + ); + IMethod method = workingCopies[0].getType("Test").getMethods()[0]; + search(method, ALL_OCCURRENCES); + assertSearchResults( + "src/b100695/Test.java Class b100695.Test.foo(Class) [foo] EXACT_MATCH\n" + + "src/b100695/Test.java void b100695.Test.bar() [foo(null)] EXACT_MATCH" + ); + } + public void testBug100695f() throws CoreException { + workingCopies = new ICompilationUnit[1]; + workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b100695/Test.java", + "package b100695;\n" + + "public class Test {\n" + + " public Class[] foo(Class[] a) {\n" + + " return a;\n" + + " }\n" + + " void bar() {\n" + + " foo(new Class[0]);\n" + + " }\n" + + "}\n" + ); + IMethod method = workingCopies[0].getType("Test").getMethods()[0]; + search(method, ALL_OCCURRENCES); + assertSearchResults( + "src/b100695/Test.java Class[] b100695.Test.foo(Class[]) [foo] EXACT_MATCH\n" + + "src/b100695/Test.java void b100695.Test.bar() [foo(new Class[0])] EXACT_MATCH" + ); + } + + /** + * Bug 100772: [1.5][search] Search for declarations in hierarchy reports to many matches + * @see "http://bugs.eclipse.org/bugs/show_bug.cgi?id=100772" + */ + public void testBug100772_ClassAndSubclass01() throws CoreException { + workingCopies = new ICompilationUnit[1]; + workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b100772/Test.java", + "package b100772;\n" + + "class Test {\n" + + " public void foo(T t) {}\n" + + " public void foo(Class c) {}\n" + + "}\n" + + "class Sub extends Test {\n" + + " public void foo(String str) {}\n" + + " public void foo(Exception e) {}\n" + + "}\n" + ); + IType type = workingCopies[0].getType("Test"); + IMethod method = type.getMethods()[0]; + search(method, UI_DECLARATIONS, SearchEngine.createHierarchyScope(type)); + this.discard = false; + assertSearchResults( + "src/b100772/Test.java void b100772.Test.foo(T) [foo] EXACT_MATCH\n" + + "src/b100772/Test.java void b100772.Sub.foo(String) [foo] EXACT_MATCH" + ); + } + public void testBug100772_ClassAndSubclass02() throws CoreException { + assertNotNull("There should be working copies!", workingCopies); + assertEquals("Invalid number of working copies kept between tests!", 1, workingCopies.length); + IType type = workingCopies[0].getType("Test"); + IMethod method = type.getMethods()[0]; + search(method, DECLARATIONS, SearchEngine.createHierarchyScope(type)); + this.discard = false; + assertSearchResults( + "src/b100772/Test.java void b100772.Test.foo(T) [foo] EXACT_MATCH\n" + + "src/b100772/Test.java void b100772.Sub.foo(String) [foo] EXACT_MATCH" + ); + } + public void testBug100772_ClassAndSubclass03() throws CoreException { + assertNotNull("There should be working copies!", workingCopies); + assertEquals("Invalid number of working copies kept between tests!", 1, workingCopies.length); + IType type = workingCopies[0].getType("Test"); + IMethod method = type.getMethods()[1]; + search(method, UI_DECLARATIONS, SearchEngine.createHierarchyScope(type)); + this.discard = false; + assertSearchResults( + "src/b100772/Test.java void b100772.Test.foo(Class) [foo] EXACT_MATCH" + ); + } + public void testBug100772_ClassAndSubclass04() throws CoreException { +// org.eclipse.jdt.internal.core.search.BasicSearchEngine.VERBOSE = true; + assertNotNull("There should be working copies!", workingCopies); + assertEquals("Invalid number of working copies kept between tests!", 1, workingCopies.length); + IType type = workingCopies[0].getType("Sub"); + IMethod method = type.getMethods()[0]; + search(method, UI_DECLARATIONS, SearchEngine.createHierarchyScope(type)); + this.discard = false; + assertSearchResults( + "src/b100772/Test.java void b100772.Test.foo(T) [foo] EXACT_MATCH\n" + + "src/b100772/Test.java void b100772.Sub.foo(String) [foo] EXACT_MATCH" + ); + } + public void testBug100772_ClassAndSubclass05() throws CoreException { + assertNotNull("There should be working copies!", workingCopies); + assertEquals("Invalid number of working copies kept between tests!", 1, workingCopies.length); + IType type = workingCopies[0].getType("Sub"); + IMethod method = type.getMethods()[1]; + search(method, UI_DECLARATIONS, SearchEngine.createHierarchyScope(type)); + assertSearchResults( + "src/b100772/Test.java void b100772.Sub.foo(Exception) [foo] EXACT_MATCH" + ); + } + public void testBug100772_InterfacesAndClass01() throws CoreException { + workingCopies = new ICompilationUnit[1]; + workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b100772/Test.java", + "package b100772;\n" + + "interface Test {\n" + + " public void foo(T t);\n" + + " public void foo(Class c);\n" + + "}\n" + + "interface Sub extends Test {\n" + + " public void foo(String str);\n" + + " public void foo(Exception e);\n" + + "}\n" + + "class X implements Test {\n" + + " public void foo(String str) {}\n" + + " public void foo(Class c) {}\n" + + " public void foo(Exception e) {}\n" + + "}\n" + ); + IType type = workingCopies[0].getType("Test"); + IMethod method = type.getMethods()[0]; + search(method, UI_DECLARATIONS, SearchEngine.createHierarchyScope(type)); + this.discard = false; + assertSearchResults( + "src/b100772/Test.java void b100772.Test.foo(T) [foo] EXACT_MATCH\n" + + "src/b100772/Test.java void b100772.Sub.foo(String) [foo] EXACT_MATCH\n" + + "src/b100772/Test.java void b100772.X.foo(String) [foo] EXACT_MATCH" + ); + } + public void testBug100772_InterfacesAndClass02() throws CoreException { + assertNotNull("There should be working copies!", workingCopies); + assertEquals("Invalid number of working copies kept between tests!", 1, workingCopies.length); + IType type = workingCopies[0].getType("Test"); + IMethod method = type.getMethods()[0]; + search(method, DECLARATIONS, SearchEngine.createHierarchyScope(type)); + this.discard = false; + assertSearchResults( + "src/b100772/Test.java void b100772.Test.foo(T) [foo] EXACT_MATCH\n" + + "src/b100772/Test.java void b100772.Sub.foo(String) [foo] EXACT_MATCH\n" + + "src/b100772/Test.java void b100772.X.foo(String) [foo] EXACT_MATCH" + ); + } + public void testBug100772_InterfacesAndClass03() throws CoreException { + assertNotNull("There should be working copies!", workingCopies); + assertEquals("Invalid number of working copies kept between tests!", 1, workingCopies.length); + IType type = workingCopies[0].getType("Test"); + IMethod method = type.getMethods()[1]; + search(method, UI_DECLARATIONS, SearchEngine.createHierarchyScope(type)); + this.discard = false; + assertSearchResults( + "src/b100772/Test.java void b100772.Test.foo(Class) [foo] EXACT_MATCH\n" + + "src/b100772/Test.java void b100772.X.foo(Class) [foo] EXACT_MATCH" + ); + } + public void testBug100772_InterfacesAndClass04() throws CoreException { + assertNotNull("There should be working copies!", workingCopies); + assertEquals("Invalid number of working copies kept between tests!", 1, workingCopies.length); + IType type = workingCopies[0].getType("Sub"); + IMethod method = type.getMethods()[0]; + search(method, UI_DECLARATIONS, SearchEngine.createHierarchyScope(type)); + this.discard = false; + assertSearchResults( + "src/b100772/Test.java void b100772.Test.foo(T) [foo] EXACT_MATCH\n" + + "src/b100772/Test.java void b100772.Sub.foo(String) [foo] EXACT_MATCH" + ); + } + public void testBug100772_InterfacesAndClass05() throws CoreException { + assertNotNull("There should be working copies!", workingCopies); + assertEquals("Invalid number of working copies kept between tests!", 1, workingCopies.length); + IType type = workingCopies[0].getType("Sub"); + IMethod method = type.getMethods()[1]; + search(method, UI_DECLARATIONS, SearchEngine.createHierarchyScope(type)); + this.discard = false; + assertSearchResults( + "src/b100772/Test.java void b100772.Sub.foo(Exception) [foo] EXACT_MATCH" + ); + } + public void testBug100772_InterfacesAndClass06() throws CoreException { + assertNotNull("There should be working copies!", workingCopies); + assertEquals("Invalid number of working copies kept between tests!", 1, workingCopies.length); + IType type = workingCopies[0].getType("X"); + IMethod method = type.getMethods()[0]; + search(method, UI_DECLARATIONS, SearchEngine.createHierarchyScope(type)); + this.discard = false; + assertSearchResults( + "src/b100772/Test.java void b100772.Test.foo(T) [foo] EXACT_MATCH\n" + + "src/b100772/Test.java void b100772.X.foo(String) [foo] EXACT_MATCH" + ); + } + public void testBug100772_InterfacesAndClass07() throws CoreException { + assertNotNull("There should be working copies!", workingCopies); + assertEquals("Invalid number of working copies kept between tests!", 1, workingCopies.length); + IType type = workingCopies[0].getType("X"); + IMethod method = type.getMethods()[1]; + search(method, UI_DECLARATIONS, SearchEngine.createHierarchyScope(type)); + this.discard = false; + assertSearchResults( + "src/b100772/Test.java void b100772.Test.foo(Class) [foo] EXACT_MATCH\n" + + "src/b100772/Test.java void b100772.X.foo(Class) [foo] EXACT_MATCH" + ); + } + public void testBug100772_InterfacesAndClass08() throws CoreException { + assertNotNull("There should be working copies!", workingCopies); + assertEquals("Invalid number of working copies kept between tests!", 1, workingCopies.length); + IType type = workingCopies[0].getType("X"); + IMethod method = type.getMethods()[2]; + search(method, UI_DECLARATIONS, SearchEngine.createHierarchyScope(type)); + assertSearchResults( + "src/b100772/Test.java void b100772.X.foo(Exception) [foo] EXACT_MATCH" + ); + } + public void testBug100772_Complex01() throws CoreException { + workingCopies = new ICompilationUnit[1]; + workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b100772/Test.java", + "package b100772;\n" + + "public class X implements IX {\n" + + " public void foo(T t) {}\n" + + "}\n" + + "class XX extends X {\n" + + " public void foo(String s) {}\n" + + " public void foo(Exception e) {}\n" + + "}\n" + + "interface IX {\n" + + " public void foo(U u);\n" + + "}\n" + + "class Y implements IX {\n" + + " public void foo(String s) {}\n" + + " public void foo(Exception e) {}\n" + + "}\n" + + "interface IXX extends IX {\n" + + " public void foo(V v);\n" + + "}\n" + + "class Z extends Y implements IXX {\n" + + " public void foo(String s) {}\n" + + " public void foo(Exception e) {}\n" + + "}\n" + ); + IMethod method = workingCopies[0].getType("IX").getMethods()[0]; + search(method, DECLARATIONS); + this.discard = false; + assertSearchResults( + "src/b100772/Test.java void b100772.X.foo(T) [foo] EXACT_MATCH\n" + + "src/b100772/Test.java void b100772.XX.foo(String) [foo] EXACT_MATCH\n" + + "src/b100772/Test.java void b100772.IX.foo(U) [foo] EXACT_MATCH\n" + + "src/b100772/Test.java void b100772.Y.foo(String) [foo] EXACT_MATCH\n" + + "src/b100772/Test.java void b100772.IXX.foo(V) [foo] EXACT_MATCH\n" + + "src/b100772/Test.java void b100772.Z.foo(String) [foo] EXACT_MATCH\n" + + "src/b100772/Test.java void b100772.Z.foo(Exception) [foo] EXACT_MATCH" + ); + } + public void testBug100772_Complex02() throws CoreException { + assertNotNull("There should be working copies!", workingCopies); + assertEquals("Invalid number of working copies kept between tests!", 1, workingCopies.length); + IType type = workingCopies[0].getType("Z"); + IMethod method = type.getMethods()[0]; + search(method, UI_DECLARATIONS, SearchEngine.createHierarchyScope(type)); + this.discard = false; + assertSearchResults( + "src/b100772/Test.java void b100772.IX.foo(U) [foo] EXACT_MATCH\n" + + "src/b100772/Test.java void b100772.Y.foo(String) [foo] EXACT_MATCH\n" + + "src/b100772/Test.java void b100772.Z.foo(String) [foo] EXACT_MATCH" + ); + } + public void testBug100772_Complex03() throws CoreException { + assertNotNull("There should be working copies!", workingCopies); + assertEquals("Invalid number of working copies kept between tests!", 1, workingCopies.length); + IType type = workingCopies[0].getType("Z"); + IMethod method = type.getMethods()[1]; + search(method, UI_DECLARATIONS, SearchEngine.createHierarchyScope(type)); + assertSearchResults( + "src/b100772/Test.java void b100772.IX.foo(U) [foo] EXACT_MATCH\n" + + "src/b100772/Test.java void b100772.Y.foo(Exception) [foo] EXACT_MATCH\n" + + "src/b100772/Test.java void b100772.IXX.foo(V) [foo] EXACT_MATCH\n" + + "src/b100772/Test.java void b100772.Z.foo(Exception) [foo] EXACT_MATCH" + ); + } }