### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core.tests.model Index: src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java,v retrieving revision 1.181 diff -u -r1.181 JavaSearchBugsTests.java --- src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java 23 Nov 2009 15:41:54 -0000 1.181 +++ src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java 24 Nov 2009 09:43:45 -0000 @@ -11029,4 +11029,147 @@ deleteProject("P"); } } + +static { TESTS_PREFIX = "testBug295894"; } +/** + * @bug 295894: SourceField.getConstant does not supply a value if type is fully qualified + * @test Ensure that source field constant is not null when fully qualified type String is used + * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=295894" + */ +public void testBug295894() throws Exception { + this.workingCopies = new ICompilationUnit[1]; + this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/Test.java", + "public class Test {\n" + + " void test() {\n" + + " Test t = new Test();\n" + + " t.foo();\n" + + " }\n" + + " public void foo() {\n" + + " }\n" + + " public class Sub extends Test {\n" + + " public void foo() {}\n" + + " }\n" + + "}\n" + + "" + ); + search( + "foo", + METHOD, + DECLARATIONS, + SearchEngine.createHierarchyScope(this.workingCopies[0].findPrimaryType()), + this.resultCollector); + assertSearchResults( + "src/Test.java void Test.foo() [foo] EXACT_MATCH\n" + + "src/Test.java void Test$Sub.foo() [foo] EXACT_MATCH" + ); +} +public void testBug295894a() throws Exception { + this.workingCopies = new ICompilationUnit[1]; + this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/Test.java", + "public class Test {\n" + + " void test() {\n" + + " Test t = new Test();\n" + + " t.foo();\n" + + " }\n" + + " public void foo() {\n" + + " }\n" + + " public class Sub extends Test {\n" + + " public void foo() {}\n" + + " }\n" + + "}\n" + + "" + ); + search( + "foo", + METHOD, + DECLARATIONS, + SearchEngine.createHierarchyScope(null, this.workingCopies[0].findPrimaryType(), true, true, null), + this.resultCollector); + // No results expected as only sub-types and no member types are set... + assertSearchResults( + "" + ); +} +public void testBug295894b() throws Exception { + this.workingCopies = new ICompilationUnit[1]; + this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/Test.java", + "public class Test {\n" + + " void test() {\n" + + " Test t = new Test();\n" + + " t.foo();\n" + + " }\n" + + " public void foo() {\n" + + " }\n" + + " public class Sub extends Test {\n" + + " public void foo() {}\n" + + " }\n" + + "}\n" + + "" + ); + search( + "foo", + METHOD, + DECLARATIONS, + SearchEngine.createHierarchyScope(null, this.workingCopies[0].findPrimaryType(), false, false, null), + this.resultCollector); + // Same results as the default + assertSearchResults( + "src/Test.java void Test.foo() [foo] EXACT_MATCH\n" + + "src/Test.java void Test$Sub.foo() [foo] EXACT_MATCH" + ); +} +public void testBug295894c() throws Exception { + this.workingCopies = new ICompilationUnit[1]; + this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/Test.java", + "public class Test {\n" + + " void test() {\n" + + " Test t = new Test();\n" + + " t.foo();\n" + + " }\n" + + " public void foo() {\n" + + " }\n" + + " public class Sub extends Test {\n" + + " public void foo() {}\n" + + " }\n" + + "}\n" + + "" + ); + search( + "foo", + METHOD, + DECLARATIONS, + SearchEngine.createHierarchyScope(null, this.workingCopies[0].findPrimaryType(), false, true, null), + this.resultCollector); + // Results in member types are filtered + assertSearchResults( + "src/Test.java void Test.foo() [foo] EXACT_MATCH" + ); +} +public void testBug295894d() throws Exception { + this.workingCopies = new ICompilationUnit[1]; + this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/Test.java", + "public class Test {\n" + + " void test() {\n" + + " Test t = new Test();\n" + + " t.foo();\n" + + " }\n" + + " public void foo() {\n" + + " }\n" + + " public class Sub extends Test {\n" + + " public void foo() {}\n" + + " }\n" + + "}\n" + + "" + ); + search( + "foo", + METHOD, + DECLARATIONS, + SearchEngine.createHierarchyScope(null, this.workingCopies[0].findPrimaryType(), true, false, null), + this.resultCollector); + // Only results in sub-types are returned + assertSearchResults( + "src/Test.java void Test$Sub.foo() [foo] EXACT_MATCH" + ); +} } \ No newline at end of file