### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core Index: search/org/eclipse/jdt/core/search/SearchEngine.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/search/org/eclipse/jdt/core/search/SearchEngine.java,v retrieving revision 1.148 diff -u -r1.148 SearchEngine.java --- search/org/eclipse/jdt/core/search/SearchEngine.java 7 Oct 2009 15:10:51 -0000 1.148 +++ search/org/eclipse/jdt/core/search/SearchEngine.java 24 Nov 2009 13:37:57 -0000 @@ -198,24 +198,23 @@ * neither including supertypes nor the focus type itself. *

*

- * By default, hierarchy scopes include also member types and enclosing types of those types - * that actually span the hierarchy. This method, however, allows to inhibit this behavior, - * by passing true to the parameter noMemberTypes. + * Unlike the other createHierarchyScope methods, this method creates + * scopes that only contain types that actually span the hierarchy of the focus + * type, but do not include additional enclosing or member types. *

* * @param project the project to which to constrain the search, or null if * search should consider all types in the workspace * @param type the focus of the hierarchy scope * @param onlySubtypes if true only subtypes of type are considered - * @param noMemberTypes if true do not consider member or enclosing types of types in the given type hiearchy * @param owner the owner of working copies that take precedence over original compilation units, * or null if the primary working copy owner should be used * @return a new hierarchy scope * @exception JavaModelException if the hierarchy could not be computed on the given type * @since 3.6 */ - public static IJavaSearchScope createHierarchyScope(IJavaProject project, IType type, boolean onlySubtypes, boolean noMemberTypes, WorkingCopyOwner owner) throws JavaModelException { - return BasicSearchEngine.createHierarchyScope(project, type, onlySubtypes, noMemberTypes, owner); + public static IJavaSearchScope createHierarchyScope(IJavaProject project, IType type, boolean onlySubtypes, WorkingCopyOwner owner) throws JavaModelException { + return BasicSearchEngine.createHierarchyScope(project, type, onlySubtypes, owner); } /** Index: search/org/eclipse/jdt/internal/core/search/BasicSearchEngine.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/BasicSearchEngine.java,v retrieving revision 1.62 diff -u -r1.62 BasicSearchEngine.java --- search/org/eclipse/jdt/internal/core/search/BasicSearchEngine.java 7 Oct 2009 15:10:51 -0000 1.62 +++ search/org/eclipse/jdt/internal/core/search/BasicSearchEngine.java 24 Nov 2009 13:37:59 -0000 @@ -109,10 +109,10 @@ } /** - * @see SearchEngine#createHierarchyScope(IJavaProject,IType,boolean,boolean,WorkingCopyOwner) for detailed comment. + * @see SearchEngine#createHierarchyScope(IJavaProject,IType,boolean,WorkingCopyOwner) for detailed comment. */ - public static IJavaSearchScope createHierarchyScope(IJavaProject project, IType type, boolean onlySubtypes, boolean noMemberTypes, WorkingCopyOwner owner) throws JavaModelException { - return new HierarchyScope(project, type, owner, onlySubtypes, noMemberTypes); + public static IJavaSearchScope createHierarchyScope(IJavaProject project, IType type, boolean onlySubtypes, WorkingCopyOwner owner) throws JavaModelException { + return new HierarchyScope(project, type, owner, onlySubtypes); } /** Index: search/org/eclipse/jdt/internal/core/search/HierarchyScope.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/HierarchyScope.java,v retrieving revision 1.47 diff -u -r1.47 HierarchyScope.java --- search/org/eclipse/jdt/internal/core/search/HierarchyScope.java 7 Oct 2009 15:10:51 -0000 1.47 +++ search/org/eclipse/jdt/internal/core/search/HierarchyScope.java 24 Nov 2009 13:38:00 -0000 @@ -62,21 +62,23 @@ /** * Creates a new hierarchy scope for the given type. + * Unlike the other constructor, this constructor creates scopes that only contain types + * that actually span the hierarchy of the focus type, but do not include additional + * enclosing or member types. * @param project constrain the search result to this project, * or null if search should consider all types in the workspace * @param type the focus type of the hierarchy * @param owner the owner of working copies that take precedence over original compilation units, * or null if the primary working copy owner should be used * @param onlySubtypes if true search only subtypes of 'type' (not including 'type') - * @param noMemberTypes if true do not consider member or enclosing types of types in the given type hierarchy. */ - public HierarchyScope(IJavaProject project, IType type, WorkingCopyOwner owner, boolean onlySubtypes, boolean noMemberTypes) throws JavaModelException { + public HierarchyScope(IJavaProject project, IType type, WorkingCopyOwner owner, boolean onlySubtypes) throws JavaModelException { this(type, owner); this.javaProject = project; if (onlySubtypes) { this.subTypes = new HashSet(); } - this.allowMemberTypes = !noMemberTypes; + this.allowMemberTypes = false; } /* (non-Javadoc) #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 13:38:25 -0000 @@ -7729,7 +7729,7 @@ this.resultCollector.showSelection(); search(packageFragment, REFERENCES); assertSearchResults( - "src/b153765/test/SomeClass.java void b153765.test.SomeClass.foo() [ @�|b153765|�.Unimportant public void foo() {}] EXACT_MATCH" + "src/b153765/test/SomeClass.java void b153765.test.SomeClass.foo() [ @�|b153765|�.Unimportant public void foo() {}] EXACT_MATCH" ); } finally { @@ -9479,7 +9479,7 @@ collector.showSelection(); search(type, REFERENCES, EXACT_RULE, getJavaSearchScope(), collector); assertSearchResults( - "src/test/Test.java void test.Test.method() [ @Annot(clazz=�|Test|�.class) int x;]+[@Annot on x]", + "src/test/Test.java void test.Test.method() [ @Annot(clazz=�|Test|�.class) int x;]+[@Annot on x]", collector ); } @@ -9495,7 +9495,7 @@ collector.showSelection(); search("Deprecated", TYPE, REFERENCES, EXACT_RULE, getJavaSearchScope(), collector); assertSearchResults( - "src/test/Test.java void test.Test.foo() [ @�|Deprecated|� foo() {}]+[@Deprecated on foo]", + "src/test/Test.java void test.Test.foo() [ @�|Deprecated|� foo() {}]+[@Deprecated on foo]", collector ); } @@ -9521,11 +9521,11 @@ collector.showSelection(); search(type, REFERENCES, EXACT_RULE, getJavaSearchScope(), collector); assertSearchResults( - "src/comment5/Ref.java void comment5.Ref.doA(Ref) [ void doA(�|Ref|� ref) {}]+[ref]\n" + - "src/comment5/Ref.java void comment5.Ref.doB(List) [ void doB(List<�|Ref|�> ref) {}]+[ref]\n" + - "src/comment5/Ref.java void comment5.Ref.doC(Ref) [ void doC(@Tag(�|Ref|�.class) Ref ref) {}]+[@Tag on ref]\n" + - "src/comment5/Ref.java void comment5.Ref.doC(Ref) [ void doC(@Tag(Ref.class) �|Ref|� ref) {}]+[ref]\n" + - "src/comment5/Ref.java void comment5.Ref.dontD(Object) [ void dontD(@Tag(�|Ref|�.class) Object ref) {}]+[@Tag on ref]", + "src/comment5/Ref.java void comment5.Ref.doA(Ref) [ void doA(�|Ref|� ref) {}]+[ref]\n" + + "src/comment5/Ref.java void comment5.Ref.doB(List) [ void doB(List<�|Ref|�> ref) {}]+[ref]\n" + + "src/comment5/Ref.java void comment5.Ref.doC(Ref) [ void doC(@Tag(�|Ref|�.class) Ref ref) {}]+[@Tag on ref]\n" + + "src/comment5/Ref.java void comment5.Ref.doC(Ref) [ void doC(@Tag(Ref.class) �|Ref|� ref) {}]+[ref]\n" + + "src/comment5/Ref.java void comment5.Ref.dontD(Object) [ void dontD(@Tag(�|Ref|�.class) Object ref) {}]+[@Tag on ref]", collector ); } @@ -9544,7 +9544,7 @@ collector.showSelection(); search(field, REFERENCES, EXACT_RULE, getJavaSearchScope(), collector); assertSearchResults( - "src/comment10/Ref.java comment10.Num [@Num(number= Num.�|CONST|�)]+[@Num on Num]", + "src/comment10/Ref.java comment10.Num [@Num(number= Num.�|CONST|�)]+[@Num on Num]", collector ); } @@ -9566,9 +9566,9 @@ collector.showSelection(); search(type, REFERENCES, EXACT_RULE, getJavaSearchScope(), collector); assertSearchResults( - "src/comment22/Test.java comment22.Test.test1 [ @�|Tag|� Test test1, test2, test3;]+[@Tag on test1]+[@Tag on test2,@Tag on test3]\n" + - "src/comment22/Test.java void comment22.Test.method() [ @�|Tag|� Test local= null;]+[@Tag on local]\n" + - "src/comment22/Test.java void comment22.Test.method() [ @�|Tag|� Test local1, local2, local3;]+[@Tag on local1]+[@Tag on local2,@Tag on local3]", + "src/comment22/Test.java comment22.Test.test1 [ @�|Tag|� Test test1, test2, test3;]+[@Tag on test1]+[@Tag on test2,@Tag on test3]\n" + + "src/comment22/Test.java void comment22.Test.method() [ @�|Tag|� Test local= null;]+[@Tag on local]\n" + + "src/comment22/Test.java void comment22.Test.method() [ @�|Tag|� Test local1, local2, local3;]+[@Tag on local1]+[@Tag on local2,@Tag on local3]", collector ); } @@ -9588,7 +9588,7 @@ collector.showSelection(); search(type, REFERENCES, EXACT_RULE, getJavaSearchScope(), collector); assertSearchResults( - "src/test/Test.java test.TestMethodReference.x [ @Annot(clazz = �|test.Test|�.class) int x, y;]+[@Annot on x]+[@Annot on y]", + "src/test/Test.java test.TestMethodReference.x [ @Annot(clazz = �|test.Test|�.class) int x, y;]+[@Annot on x]+[@Annot on y]", collector ); } @@ -9643,21 +9643,21 @@ this.resultCollector.showSelection(); search("*", TYPE, REFERENCES, getJavaSearchWorkingCopiesScope(), this.resultCollector); assertSearchResults( - "src/generics/Generic.java [import �|java.io.Serializable|�;] EXACT_MATCH\n" + - "src/generics/Generic.java [import �|type.def.Types|�;] EXACT_MATCH\n" + - "src/generics/Generic.java generics.Generic [public class Generic & Serializable, V extends A> {] EXACT_MATCH\n" + - "src/generics/Generic.java generics.Generic [public class Generic & Serializable, V extends A> {] EXACT_MATCH\n" + - "src/generics/Generic.java generics.Generic [public class Generic & Serializable, V extends A> {] EXACT_MATCH\n" + - "src/generics/Generic.java generics.Generic [public class Generic & Serializable, V extends A> {] EXACT_MATCH\n" + - "src/generics/Generic.java generics.Generic [public class Generic & �|Serializable|�, V extends A> {] EXACT_MATCH\n" + - "src/generics/Generic.java generics.Generic [public class Generic & Serializable, V extends �|A|�> {] EXACT_MATCH\n" + - "src/generics/Generic.java generics.Generic [public class Generic & Serializable, V extends A> {] EXACT_MATCH\n" + - "src/generics/Generic.java generics.Generic.field [ �|Generic|� field;] EXACT_MATCH\n" + - "src/generics/Generic.java generics.Generic.field [ Generic field;] EXACT_MATCH\n" + - "src/generics/Generic.java generics.Generic.comp [ �|Comparable|� comp;] EXACT_MATCH\n" + - "src/generics/Generic.java generics.Generic.comp [ Comparable<�|String|�> comp;] EXACT_MATCH\n" + - "src/generics/Generic.java generics.Generic.clazz [ �|Class|� clazz;] EXACT_MATCH\n" + - "src/generics/Generic.java generics.Generic.clazz [ Class clazz;] EXACT_MATCH" + "src/generics/Generic.java [import �|java.io.Serializable|�;] EXACT_MATCH\n" + + "src/generics/Generic.java [import �|type.def.Types|�;] EXACT_MATCH\n" + + "src/generics/Generic.java generics.Generic [public class Generic & Serializable, V extends A> {] EXACT_MATCH\n" + + "src/generics/Generic.java generics.Generic [public class Generic & Serializable, V extends A> {] EXACT_MATCH\n" + + "src/generics/Generic.java generics.Generic [public class Generic & Serializable, V extends A> {] EXACT_MATCH\n" + + "src/generics/Generic.java generics.Generic [public class Generic & Serializable, V extends A> {] EXACT_MATCH\n" + + "src/generics/Generic.java generics.Generic [public class Generic & �|Serializable|�, V extends A> {] EXACT_MATCH\n" + + "src/generics/Generic.java generics.Generic [public class Generic & Serializable, V extends �|A|�> {] EXACT_MATCH\n" + + "src/generics/Generic.java generics.Generic [public class Generic & Serializable, V extends A> {] EXACT_MATCH\n" + + "src/generics/Generic.java generics.Generic.field [ �|Generic|� field;] EXACT_MATCH\n" + + "src/generics/Generic.java generics.Generic.field [ Generic field;] EXACT_MATCH\n" + + "src/generics/Generic.java generics.Generic.comp [ �|Comparable|� comp;] EXACT_MATCH\n" + + "src/generics/Generic.java generics.Generic.comp [ Comparable<�|String|�> comp;] EXACT_MATCH\n" + + "src/generics/Generic.java generics.Generic.clazz [ �|Class|� clazz;] EXACT_MATCH\n" + + "src/generics/Generic.java generics.Generic.clazz [ Class clazz;] EXACT_MATCH" ); } @@ -9682,8 +9682,8 @@ this.resultCollector.showSelection(); search("*", TYPE, REFERENCES, getJavaSearchWorkingCopiesScope(), this.resultCollector); assertSearchResults( - "src/test/Ref.java [import �|pack.Test|�;] EXACT_MATCH\n" + - "src/test/Ref.java test.Ref.test [ �|Test|� test;] EXACT_MATCH" + "src/test/Ref.java [import �|pack.Test|�;] EXACT_MATCH\n" + + "src/test/Ref.java test.Ref.test [ �|Test|� test;] EXACT_MATCH" ); } @@ -9906,7 +9906,7 @@ ILocalVariable variable = selectLocalVariable(this.workingCopies[0], "test"); search(variable, READ_ACCESSES, getJavaSearchWorkingCopiesScope(), this.resultCollector); assertSearchResults( - "src/Test.java void Test.m() [ �|test|�.fField = 42; // match for t is writeAccess, should be readAccess] EXACT_MATCH" + "src/Test.java void Test.m() [ �|test|�.fField = 42; // match for t is writeAccess, should be readAccess] EXACT_MATCH" ); } public void testBug216875b() throws CoreException { @@ -9926,7 +9926,7 @@ IField field = this.workingCopies[0].getType("Test").getField("fWrapped"); search(field, READ_ACCESSES, getJavaSearchWorkingCopiesScope(), this.resultCollector); assertSearchResults( - "src/Test.java void Test.wrapper() [ �|fWrapped|�.fField = 12; // match for fWrapped is writeAccess] EXACT_MATCH" + "src/Test.java void Test.wrapper() [ �|fWrapped|�.fField = 12; // match for fWrapped is writeAccess] EXACT_MATCH" ); } public void testBug216875c() throws CoreException { @@ -9952,9 +9952,9 @@ ILocalVariable variable = selectLocalVariable(this.workingCopies[1], "t1"); search(variable, READ_ACCESSES, getJavaSearchWorkingCopiesScope(), this.resultCollector); assertSearchResults( - "src/test/X.java void test.X.foo(Test, Test) [ �|t1|�.field = t1.field;] EXACT_MATCH\n" + - "src/test/X.java void test.X.foo(Test, Test) [ t1.field = �|t1|�.field;] EXACT_MATCH\n" + - "src/test/X.java void test.X.foo(Test, Test) [ t2.field = �|t1|�.field;] EXACT_MATCH" + "src/test/X.java void test.X.foo(Test, Test) [ �|t1|�.field = t1.field;] EXACT_MATCH\n" + + "src/test/X.java void test.X.foo(Test, Test) [ t1.field = �|t1|�.field;] EXACT_MATCH\n" + + "src/test/X.java void test.X.foo(Test, Test) [ t2.field = �|t1|�.field;] EXACT_MATCH" ); } public void testBug216875d() throws CoreException { @@ -9981,9 +9981,9 @@ IField field = this.workingCopies[1].getType("X").getField("t1"); search(field, READ_ACCESSES, getJavaSearchWorkingCopiesScope(), this.resultCollector); assertSearchResults( - "src/test/X.java void test.X.foo() [ �|t1|�.field = t1.field;] EXACT_MATCH\n" + - "src/test/X.java void test.X.foo() [ t1.field = �|t1|�.field;] EXACT_MATCH\n" + - "src/test/X.java void test.X.foo() [ t2.field = �|t1|�.field;] EXACT_MATCH" + "src/test/X.java void test.X.foo() [ �|t1|�.field = t1.field;] EXACT_MATCH\n" + + "src/test/X.java void test.X.foo() [ t1.field = �|t1|�.field;] EXACT_MATCH\n" + + "src/test/X.java void test.X.foo() [ t2.field = �|t1|�.field;] EXACT_MATCH" ); } public void testBug216875e() throws CoreException { @@ -10009,7 +10009,7 @@ ILocalVariable variable = selectLocalVariable(this.workingCopies[1], "t1"); search(variable, WRITE_ACCESSES, getJavaSearchWorkingCopiesScope(), this.resultCollector); assertSearchResults( - "src/test/X.java void test.X.foo(Test, Test) [ �|t1|� = t2;] EXACT_MATCH" + "src/test/X.java void test.X.foo(Test, Test) [ �|t1|� = t2;] EXACT_MATCH" ); } public void testBug216875f() throws CoreException { @@ -10036,7 +10036,7 @@ IField field = this.workingCopies[1].getType("X").getField("t1"); search(field, WRITE_ACCESSES, getJavaSearchWorkingCopiesScope(), this.resultCollector); assertSearchResults( - "src/test/X.java void test.X.foo() [ �|t1|� = t2;] EXACT_MATCH" + "src/test/X.java void test.X.foo() [ �|t1|� = t2;] EXACT_MATCH" ); } public void testBug216875g() throws CoreException { @@ -10064,10 +10064,10 @@ ILocalVariable variable = selectLocalVariable(this.workingCopies[1], "t1"); search(variable, REFERENCES, getJavaSearchWorkingCopiesScope(), this.resultCollector); assertSearchResults( - "src/test/X.java void test.X.foo(Test, Test) [ �|t1|� = t2;] WRITE ACCESS\n" + - "src/test/X.java void test.X.foo(Test, Test) [ �|t1|�.field = t1.field;] READ ACCESS\n" + - "src/test/X.java void test.X.foo(Test, Test) [ t1.field = �|t1|�.field;] READ ACCESS\n" + - "src/test/X.java void test.X.foo(Test, Test) [ t2.field = �|t1|�.field;] READ ACCESS" + "src/test/X.java void test.X.foo(Test, Test) [ �|t1|� = t2;] WRITE ACCESS\n" + + "src/test/X.java void test.X.foo(Test, Test) [ �|t1|�.field = t1.field;] READ ACCESS\n" + + "src/test/X.java void test.X.foo(Test, Test) [ t1.field = �|t1|�.field;] READ ACCESS\n" + + "src/test/X.java void test.X.foo(Test, Test) [ t2.field = �|t1|�.field;] READ ACCESS" ); } public void testBug216875h() throws CoreException { @@ -10096,10 +10096,10 @@ IField field = this.workingCopies[1].getType("X").getField("t1"); search(field, REFERENCES, getJavaSearchWorkingCopiesScope(), this.resultCollector); assertSearchResults( - "src/test/X.java void test.X.foo() [ �|t1|� = t2;] WRITE ACCESS\n" + - "src/test/X.java void test.X.foo() [ �|t1|�.field = t1.field;] READ ACCESS\n" + - "src/test/X.java void test.X.foo() [ t1.field = �|t1|�.field;] READ ACCESS\n" + - "src/test/X.java void test.X.foo() [ t2.field = �|t1|�.field;] READ ACCESS" + "src/test/X.java void test.X.foo() [ �|t1|� = t2;] WRITE ACCESS\n" + + "src/test/X.java void test.X.foo() [ �|t1|�.field = t1.field;] READ ACCESS\n" + + "src/test/X.java void test.X.foo() [ t1.field = �|t1|�.field;] READ ACCESS\n" + + "src/test/X.java void test.X.foo() [ t2.field = �|t1|�.field;] READ ACCESS" ); } @@ -10124,7 +10124,7 @@ IType type = selectType(this.workingCopies[0], "Row"); search(type, REFERENCES, getJavaSearchWorkingCopiesScope(), this.resultCollector); assertSearchResults( - "src/Bug.java Bug.{}:Inner#1.field [ �|Row|� field;//LINE 3] EXACT_MATCH" + "src/Bug.java Bug.{}:Inner#1.field [ �|Row|� field;//LINE 3] EXACT_MATCH" ); } @@ -10160,12 +10160,12 @@ this.resultCollector, null); assertSearchResults( - "src/Test.java Test [public class �|Test|� {] EXACT_MATCH\n" + - "src/Test.java Test.test [ Test �|test|�;] EXACT_MATCH\n" + - "src/Test.java Test.test [ �|Test|� test;] EXACT_MATCH\n" + - "src/Test.java void Test.test(Test) [ void �|test|�(Test test) {] EXACT_MATCH\n" + - "src/Test.java void Test.test(Test) [ void test(�|Test|� test) {] EXACT_MATCH\n" + - "src/Test.java void Test.test(Test) [ if (test == this.�|test|�) {] EXACT_MATCH" + "src/Test.java Test [public class �|Test|� {] EXACT_MATCH\n" + + "src/Test.java Test.test [ Test �|test|�;] EXACT_MATCH\n" + + "src/Test.java Test.test [ �|Test|� test;] EXACT_MATCH\n" + + "src/Test.java void Test.test(Test) [ void �|test|�(Test test) {] EXACT_MATCH\n" + + "src/Test.java void Test.test(Test) [ void test(�|Test|� test) {] EXACT_MATCH\n" + + "src/Test.java void Test.test(Test) [ if (test == this.�|test|�) {] EXACT_MATCH" ); } @@ -10190,7 +10190,7 @@ IType type = this.workingCopies[0].getType("X"); search(type, REFERENCES, SearchPattern.R_ERASURE_MATCH, getJavaSearchWorkingCopiesScope(), this.resultCollector); assertSearchResults( - "src/Y.java Y [public class Y> {] ERASURE_MATCH" + "src/Y.java Y [public class Y> {] ERASURE_MATCH" ); } public void testBug221110b() throws CoreException { @@ -10212,7 +10212,7 @@ IType type = this.workingCopies[0].getType("I"); search(type, REFERENCES, SearchPattern.R_ERASURE_MATCH, getJavaSearchWorkingCopiesScope(), this.resultCollector); assertSearchResults( - "src/Z.java Z [public class Z & �|I|�> {] ERASURE_MATCH" + "src/Z.java Z [public class Z & �|I|�> {] ERASURE_MATCH" ); } @@ -10537,8 +10537,8 @@ this.resultCollector.showSelection(); search("B251827*", TYPE, REFERENCES); assertSearchResults( - "src/b251827/X.java [import static b251827.�|B251827|�.VAL;] EXACT_MATCH\n" + - "src/b251827/X.java [import static b251827.�|B251827|�.foo;] EXACT_MATCH" + "src/b251827/X.java [import static b251827.�|B251827|�.VAL;] EXACT_MATCH\n" + + "src/b251827/X.java [import static b251827.�|B251827|�.foo;] EXACT_MATCH" ); } public void testBug251827b() throws CoreException { @@ -10564,7 +10564,7 @@ this.resultCollector.showSelection(); search("B251827*", TYPE, REFERENCES); assertSearchResults( - "src/b251827/X.java [import static b251827.�|B251827|�.*;] EXACT_MATCH" + "src/b251827/X.java [import static b251827.�|B251827|�.*;] EXACT_MATCH" ); } public void testBug251827c() throws CoreException { @@ -10592,7 +10592,7 @@ ); search("B251827*", TYPE, REFERENCES); assertSearchResults( - "src/b251827/X.java void b251827.X.bar(B251827) [ void bar(�|B251827|� m) {;] EXACT_MATCH" + "src/b251827/X.java void b251827.X.bar(B251827) [ void bar(�|B251827|� m) {;] EXACT_MATCH" ); } @@ -11029,4 +11029,103 @@ deleteProject("P"); } } + +static { TESTS_PREFIX = "testBug295894"; } +/** + * @bug 295894: Search shows focus type implementation for nested types even though the scope is restricted to subtypes. + * @test using the hierarchy with the old API includes the focus type. + * @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" + ); +} +/** + * @bug 295894: Search shows focus type implementation for nested types even though the scope is restricted to subtypes. + * @test when restricting the hierarchy to sub types the focus should not be included + * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=295894" + */ +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, null), + this.resultCollector); + // Test$Sub is a true sub type, not affected by filtering member types + assertSearchResults( + "src/Test.java void Test$Sub.foo() [foo] EXACT_MATCH" + ); +} +/** + * @bug 295894: Search shows focus type implementation for nested types even though the scope is restricted to subtypes. + * @test when not restricting the hierarchy to sub types the focus should be included + * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=295894" + */ +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, null), + this.resultCollector); + // Same results as with the old API + assertSearchResults( + "src/Test.java void Test.foo() [foo] EXACT_MATCH\n" + + "src/Test.java void Test$Sub.foo() [foo] EXACT_MATCH" + ); +} } \ No newline at end of file Index: src/org/eclipse/jdt/core/tests/model/JavaSearchTests.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchTests.java,v retrieving revision 1.183 diff -u -r1.183 JavaSearchTests.java --- src/org/eclipse/jdt/core/tests/model/JavaSearchTests.java 7 Oct 2009 15:10:54 -0000 1.183 +++ src/org/eclipse/jdt/core/tests/model/JavaSearchTests.java 24 Nov 2009 13:38:32 -0000 @@ -1365,7 +1365,7 @@ "foo", METHOD, DECLARATIONS, - SearchEngine.createHierarchyScope(null, type, false, true, null), + SearchEngine.createHierarchyScope(null, type, false, null), this.resultCollector); assertSearchResults( "src/p/X.java void p.X.foo(int, String, X) [foo]\n" + @@ -2450,7 +2450,7 @@ ICompilationUnit cuB = this. getCompilationUnit("JavaSearch", "src", "a10", "B.java"); ICompilationUnit cuC = this. getCompilationUnit("JavaSearch", "src", "a10", "C.java"); IType type = cuC.getType("C"); - IJavaSearchScope scope = SearchEngine.createHierarchyScope(null, type, true, true, null); + IJavaSearchScope scope = SearchEngine.createHierarchyScope(null, type, true, null); // don't include super-classes: assertFalse("a10.A should not be included in hierarchy scope", scope.encloses(cuB.getType("A"))); @@ -2464,7 +2464,7 @@ public void testSearchScope07() throws CoreException { ICompilationUnit cuC = this. getCompilationUnit("JavaSearch", "src", "a10", "C.java"); IType type = cuC.getType("C"); - IJavaSearchScope scope = SearchEngine.createHierarchyScope(null, type, true, true, null); + IJavaSearchScope scope = SearchEngine.createHierarchyScope(null, type, true, null); // don't include focus type: assertFalse("a10.C should be not included in hierarchy scope", scope.encloses(type)); @@ -2479,7 +2479,7 @@ ICompilationUnit cuD = this. getCompilationUnit("JavaSearch", "src", "a10", "D.java"); ICompilationUnit cuE = this. getCompilationUnit("JavaSearch", "src", "a10", "E.java"); IType type = cuC.getType("C"); - IJavaSearchScope scope = SearchEngine.createHierarchyScope(null, type, true, true, null); + IJavaSearchScope scope = SearchEngine.createHierarchyScope(null, type, true, null); // regular sub-types: assertTrue("a10.D should be included in hierarchy scope", scope.encloses(cuD.getType("D"))); @@ -2496,7 +2496,7 @@ ICompilationUnit cuC = this. getCompilationUnit("JavaSearch", "src", "a10", "C.java"); ICompilationUnit cuE = this. getCompilationUnit("JavaSearch", "src", "a10", "E.java"); IType type = cuC.getType("C"); - IJavaSearchScope scope = SearchEngine.createHierarchyScope(null, type, true, true, null); + IJavaSearchScope scope = SearchEngine.createHierarchyScope(null, type, true, null); // sub-type is a nested type: assertTrue("a10.H$I should be included in hierarchy scope", scope.encloses(cuE.getType("H").getType("I"))); @@ -2509,7 +2509,7 @@ ICompilationUnit cuC = this. getCompilationUnit("JavaSearch", "src", "a10", "C.java"); ICompilationUnit cuE = this. getCompilationUnit("JavaSearch", "src", "a10", "E.java"); IType type = cuC.getType("C"); - IJavaSearchScope scope = SearchEngine.createHierarchyScope(null, type, true, true, null); + IJavaSearchScope scope = SearchEngine.createHierarchyScope(null, type, true, null); // member of a sub-type: assertFalse("a10.F$G should not be included in hierarchy scope", scope.encloses(cuE.getType("F").getType("G"))); @@ -2517,12 +2517,13 @@ /** * Hierarchy scope test. * (test for enhancement bug 215139 encloses(): find only subtypes and their member types). + * Note: this combination of arguments is no longer supported after the change from bug 295894 */ -public void testSearchScope11() throws CoreException { +public void _testSearchScope11() throws CoreException { ICompilationUnit cuC = this. getCompilationUnit("JavaSearch", "src", "a10", "C.java"); ICompilationUnit cuE = this. getCompilationUnit("JavaSearch", "src", "a10", "E.java"); IType type = cuC.getType("C"); - IJavaSearchScope scope = SearchEngine.createHierarchyScope(null, type, true, false, null); + IJavaSearchScope scope = SearchEngine.createHierarchyScope(null, type, true, null); // member of a sub-type: assertTrue("a10.F$G should be included in hierarchy scope", scope.encloses(cuE.getType("F").getType("G"))); @@ -2535,7 +2536,7 @@ ICompilationUnit cuC = this. getCompilationUnit("JavaSearch", "src", "a10", "C.java"); ICompilationUnit cuE = this. getCompilationUnit("JavaSearch", "src", "a10", "E.java"); IType type = cuC.getType("C"); - IJavaSearchScope scope = SearchEngine.createHierarchyScope(null, type, true, true, null); + IJavaSearchScope scope = SearchEngine.createHierarchyScope(null, type, true, null); // enclosing of a sub-type: assertFalse("a10.H should not be included in hierarchy scope", scope.encloses(cuE.getType("H"))); @@ -2548,7 +2549,7 @@ public void testSearchScope13() throws CoreException { ICompilationUnit cuC = this. getCompilationUnit("JavaSearch", "src", "a10", "C.java"); IType type = cuC.getType("C"); - IJavaSearchScope scope = SearchEngine.createHierarchyScope(null, type, true, true, null); + IJavaSearchScope scope = SearchEngine.createHierarchyScope(null, type, true, null); search("**", TYPE, DECLARATIONS, scope); assertSearchResults( @@ -2565,7 +2566,7 @@ public void testSearchScope14() throws CoreException { ICompilationUnit cuC = this. getCompilationUnit("JavaSearch", "src", "a10", "C.java"); IType type = cuC.getType("C"); - IJavaSearchScope scope = SearchEngine.createHierarchyScope(null, type, /*onlySubTypes*/false, true, null); + IJavaSearchScope scope = SearchEngine.createHierarchyScope(null, type, /*onlySubTypes*/false, null); search("**", TYPE, DECLARATIONS, scope); assertSearchResults( @@ -2586,7 +2587,7 @@ public void testSearchScope15() throws CoreException { ICompilationUnit cuC = this. getCompilationUnit("JavaSearch", "src", "a10", "C.java"); IType type = cuC.getType("C"); - IJavaSearchScope scope = SearchEngine.createHierarchyScope(null, type, true, true, null); + IJavaSearchScope scope = SearchEngine.createHierarchyScope(null, type, true, null); TypeNameMatchCollector collector = new TypeNameMatchCollector() { public String toString(){ return toFullyQualifiedNamesString(); @@ -2610,11 +2611,12 @@ /** * Hierarchy scope test. * (test for enhancement bug 215139 search: find only subtypes plus member & enclosing types - different call chain). + * Note: this combination of arguments is no longer supported after the change from bug 295894 */ -public void testSearchScope16() throws CoreException { +public void _testSearchScope16() throws CoreException { ICompilationUnit cuC = this. getCompilationUnit("JavaSearch", "src", "a10", "C.java"); IType type = cuC.getType("C"); - IJavaSearchScope scope = SearchEngine.createHierarchyScope(null, type, true, false, null); + IJavaSearchScope scope = SearchEngine.createHierarchyScope(null, type, true, null); TypeNameMatchCollector collector = new TypeNameMatchCollector() { public String toString(){ return toFullyQualifiedNamesString(); @@ -2645,7 +2647,7 @@ ICompilationUnit cuC = this. getCompilationUnit("JavaSearch", "src", "a10", "C.java"); ICompilationUnit cuE = this. getCompilationUnit("JavaSearch", "src", "a10", "E.java"); IType type = cuC.getType("C"); - IJavaSearchScope scope = SearchEngine.createHierarchyScope(null, type, true, true, null); + IJavaSearchScope scope = SearchEngine.createHierarchyScope(null, type, true, null); // method of a member of a sub-type: assertFalse("a10.F$G.m() should not be included in hierarchy scope", scope.encloses(cuE.getType("F").getType("G").getMethod("m", new String[0]))); @@ -2653,12 +2655,13 @@ /** * Hierarchy scope test. * (test for enhancement bug 215139 encloses(method): find only subtypes but also member types). + * Note: this combination of arguments is no longer supported after the change from bug 295894 */ -public void testSearchScope18() throws CoreException { +public void _testSearchScope18() throws CoreException { ICompilationUnit cuC = this. getCompilationUnit("JavaSearch", "src", "a10", "C.java"); ICompilationUnit cuE = this. getCompilationUnit("JavaSearch", "src", "a10", "E.java"); IType type = cuC.getType("C"); - IJavaSearchScope scope = SearchEngine.createHierarchyScope(null, type, true, false, null); + IJavaSearchScope scope = SearchEngine.createHierarchyScope(null, type, true, null); // method of a member of a sub-type: assertTrue("a10.F$G.m() should be included in hierarchy scope", scope.encloses(cuE.getType("F").getType("G").getMethod("m", new String[0]))); @@ -3426,9 +3429,9 @@ }), this.resultCollector); assertSearchResults( - "src/b5/A.java b5.A.{} [ �|Zork|�[] zork = new Zork[0];] POTENTIAL_MATCH\n" + - "src/b5/A.java b5.A.{} [ Zork[] zork = new �|Zork|�[0];] POTENTIAL_MATCH\n" + - "src/b5/A.java b5.A.{} [ int i = �|Zork|�.foo;] POTENTIAL_MATCH", + "src/b5/A.java b5.A.{} [ �|Zork|�[] zork = new Zork[0];] POTENTIAL_MATCH\n" + + "src/b5/A.java b5.A.{} [ Zork[] zork = new �|Zork|�[0];] POTENTIAL_MATCH\n" + + "src/b5/A.java b5.A.{} [ int i = �|Zork|�.foo;] POTENTIAL_MATCH", this.resultCollector); } /** @@ -3613,7 +3616,7 @@ scope, this.resultCollector); assertSearchResults( - "src/f2/X.java Object f2.X.foo1() [ return new �|Y|�();]", + "src/f2/X.java Object f2.X.foo1() [ return new �|Y|�();]", this.resultCollector); } /* @@ -3633,7 +3636,7 @@ scope, this.resultCollector); assertSearchResults( - "src/f2/X.java Object f2.X.foo1() [ return new �|Y|�();]", + "src/f2/X.java Object f2.X.foo1() [ return new �|Y|�();]", this.resultCollector); } /**