### 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 13 Jan 2010 17:13:14 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2009 IBM Corporation and others. + * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -7,7 +7,7 @@ * * Contributors: * IBM Corporation - initial API and implementation - * Stephan Herrmann - Contribution for bug 215139 + * Stephan Herrmann - Contributions for bug 215139 and bug 295894 *******************************************************************************/ package org.eclipse.jdt.core.search; @@ -212,6 +212,7 @@ * 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 + * @deprecated Will be removed shortly before 3.6M5. Use {@link #createStrictHierarchyScope(IJavaProject, IType, boolean, boolean, WorkingCopyOwner)} instead. * @since 3.6 */ public static IJavaSearchScope createHierarchyScope(IJavaProject project, IType type, boolean onlySubtypes, boolean noMemberTypes, WorkingCopyOwner owner) throws JavaModelException { @@ -219,6 +220,36 @@ } /** + * Returns a Java search scope limited to the hierarchy of the given type and to a given project. + * The Java elements resulting from a search with this scope will be types in this hierarchy. + *

+ * Unlike the createHierarchyScope methods, this method creates strict + * scopes that only contain types that actually span the hierarchy of the focus + * type, but do not include additional enclosing or member types. + *

+ *

+ * By default, hierarchy scopes include all direct and indirect supertypes and subtypes of the + * focus type. This method, however, allows to restrict the hierarchy to true subtypes, + * not including supertypes. Also inclusion of the focus type itself is controled by a parameter. + *

+ * + * @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 includeFocusType if true the focus type type is included in the resulting scope, + * otherwise it is excluded + * @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 createStrictHierarchyScope(IJavaProject project, IType type, boolean onlySubtypes, boolean includeFocusType, WorkingCopyOwner owner) throws JavaModelException { + return BasicSearchEngine.createStrictHierarchyScope(project, type, onlySubtypes, includeFocusType, owner); + } + + /** * Returns a Java search scope limited to the given resources. * The Java elements resulting from a search with this scope will * have their underlying resource included in or equals to one of the given 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 13 Jan 2010 17:13:14 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2009 IBM Corporation and others. + * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -7,7 +7,7 @@ * * Contributors: * IBM Corporation - initial API and implementation - * Stephan Herrmann - Contribution for bug 215139 + * Stephan Herrmann - Contributions for bug 215139 and bug 295894 *******************************************************************************/ package org.eclipse.jdt.internal.core.search; @@ -110,9 +110,17 @@ /** * @see SearchEngine#createHierarchyScope(IJavaProject,IType,boolean,boolean,WorkingCopyOwner) for detailed comment. + * @deprecated Will be removed shortly before 3.6M5. Use {@link #createHierarchyScope(IJavaProject, IType, boolean, boolean, WorkingCopyOwner)} instead. */ public static IJavaSearchScope createHierarchyScope(IJavaProject project, IType type, boolean onlySubtypes, boolean noMemberTypes, WorkingCopyOwner owner) throws JavaModelException { - return new HierarchyScope(project, type, owner, onlySubtypes, noMemberTypes); + return new HierarchyScope(project, type, owner, onlySubtypes, noMemberTypes, !onlySubtypes); + } + + /** + * @see SearchEngine#createStrictHierarchyScope(IJavaProject,IType,boolean,boolean,WorkingCopyOwner) for detailed comment. + */ + public static IJavaSearchScope createStrictHierarchyScope(IJavaProject project, IType type, boolean onlySubtypes, boolean includeFocusType, WorkingCopyOwner owner) throws JavaModelException { + return new HierarchyScope(project, type, owner, onlySubtypes, true, includeFocusType); } /** 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 13 Jan 2010 17:13:14 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2009 IBM Corporation and others. + * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -7,7 +7,7 @@ * * Contributors: * IBM Corporation - initial API and implementation - * Stephan Herrmann - Contribution for bug 215139 + * Stephan Herrmann - Contributions for bug 215139 and bug 295894 *******************************************************************************/ package org.eclipse.jdt.internal.core.search; @@ -43,7 +43,8 @@ private HashSet subTypes = null; // null means: don't filter for subTypes private IJavaProject javaProject = null; // null means: don't constrain the search to a project - private boolean allowMemberTypes = true; + private boolean allowMemberAndEnclosingTypes = true; + private boolean includeFocusType = true; /* (non-Javadoc) * Adds the given resource to this search scope. @@ -61,22 +62,26 @@ } /** - * Creates a new hierarchy scope for the given type. + * Creates a new hierarchy scope for the given type with the given configuration options. * @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. + * @param onlySubtypes if true search only subtypes of 'type' + * @param noMembersOrEnclosingTypes if true the hierarchy is strict, + * i.e., no additional member types or enclosing types of types spanning the hierarchy are included, + * otherwise all member and enclosing types of types in the hierarchy are included. + * @param includeFocusType if true the focus type type is included in the resulting scope, otherwise it is excluded */ - public HierarchyScope(IJavaProject project, IType type, WorkingCopyOwner owner, boolean onlySubtypes, boolean noMemberTypes) throws JavaModelException { + public HierarchyScope(IJavaProject project, IType type, WorkingCopyOwner owner, boolean onlySubtypes, boolean noMembersOrEnclosingTypes, boolean includeFocusType) throws JavaModelException { this(type, owner); this.javaProject = project; if (onlySubtypes) { this.subTypes = new HashSet(); } - this.allowMemberTypes = !noMemberTypes; + this.includeFocusType = includeFocusType; + this.allowMemberAndEnclosingTypes = !noMembersOrEnclosingTypes; } /* (non-Javadoc) @@ -293,7 +298,7 @@ * (regarding subtypes and members) is requested */ public boolean enclosesFineGrained(IJavaElement element) { - if ((this.subTypes == null) && this.allowMemberTypes) + if ((this.subTypes == null) && this.allowMemberAndEnclosingTypes) return true; // no fine grained checking requested return encloses(element); } @@ -302,7 +307,7 @@ */ public boolean encloses(IJavaElement element) { if (this.hierarchy == null) { - if (this.subTypes == null && this.focusType.equals(element.getAncestor(IJavaElement.TYPE))) { + if (this.includeFocusType && this.focusType.equals(element.getAncestor(IJavaElement.TYPE))) { return true; } else { if (this.needsRefresh) { @@ -332,11 +337,13 @@ type = ((IMember) element).getDeclaringType(); } if (type != null) { + if (this.focusType.equals(type)) + return this.includeFocusType; // potentially allow travelling in: - if (enclosesType(type, this.allowMemberTypes)) { + if (enclosesType(type, this.allowMemberAndEnclosingTypes)) { return true; } - if (this.allowMemberTypes) { + if (this.allowMemberAndEnclosingTypes) { // travel out: queried type is enclosed in this scope if its (indirect) declaring type is: IType enclosing = type.getDeclaringType(); while (enclosing != null) { #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.188 diff -u -r1.188 JavaSearchBugsTests.java --- src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java 7 Jan 2010 20:18:11 -0000 1.188 +++ src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java 13 Jan 2010 17:13:15 -0000 @@ -11039,6 +11039,104 @@ } /** + * @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 explicitly excluding the focus type + * @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.createStrictHierarchyScope(null, this.workingCopies[0].findPrimaryType(), true, false, 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 explicitly including the focus type + * @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.createStrictHierarchyScope(null, this.workingCopies[0].findPrimaryType(), false, true, 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" + ); +} + +/** * @bug 288174: NullPointerException when searching for type references * @test Ensure that no NPE occurs when searching for type references * when a binary type has matches in several member or anonymous types 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.184 diff -u -r1.184 JavaSearchTests.java --- src/org/eclipse/jdt/core/tests/model/JavaSearchTests.java 25 Nov 2009 12:26:50 -0000 1.184 +++ src/org/eclipse/jdt/core/tests/model/JavaSearchTests.java 13 Jan 2010 17:13:15 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2009 IBM Corporation and others. + * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -1356,7 +1356,6 @@ } /** * Method declaration in hierarchy test. - * Explicitly request behavior pre https://bugs.eclipse.org/bugs/show_bug.cgi?id=215139 */ public void testMethodDeclaration04() throws CoreException { // was testMethodDeclarationInHierarchyScope1 IType type = getCompilationUnit("JavaSearch", "src", "p", "X.java").getType("X"); @@ -1365,24 +1364,6 @@ "foo", METHOD, DECLARATIONS, - SearchEngine.createHierarchyScope(null, type, false, true, null), - this.resultCollector); - assertSearchResults( - "src/p/X.java void p.X.foo(int, String, X) [foo]\n" + - "src/p/Z.java void p.Z.foo(int, String, X) [foo]", - this.resultCollector); -} -/** - * Method declaration in hierarchy test. - * After https://bugs.eclipse.org/bugs/show_bug.cgi?id=215139 result contains more types. - */ -public void testMethodDeclaration04a() throws CoreException { // was testMethodDeclarationInHierarchyScope1 - IType type = getCompilationUnit("JavaSearch", "src", "p", "X.java").getType("X"); - - search( - "foo", - METHOD, - DECLARATIONS, SearchEngine.createHierarchyScope(type), this.resultCollector); assertSearchResults( @@ -2450,7 +2431,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.createStrictHierarchyScope(null, type, true, false, null); // don't include super-classes: assertFalse("a10.A should not be included in hierarchy scope", scope.encloses(cuB.getType("A"))); @@ -2464,11 +2445,25 @@ 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.createStrictHierarchyScope(null, type, true, false, null); // don't include focus type: - assertFalse("a10.C should be not included in hierarchy scope", scope.encloses(type)); - assertFalse("a10/C.java should be included in hierarchy scope", scope.encloses(cuC.getUnderlyingResource().getFullPath().toString())); + assertFalse("a10.C should not be included in hierarchy scope", scope.encloses(type)); + assertFalse("a10/C.java should not be included in hierarchy scope", scope.encloses(cuC.getUnderlyingResource().getFullPath().toString())); +} +/** + * Hierarchy scope test. + * test for enhancement bug 215139 encloses(): find only subtypes. + * also test enhancement bug 295894: include focus type. + */ +public void testSearchScope07a() throws CoreException { + ICompilationUnit cuC = this. getCompilationUnit("JavaSearch", "src", "a10", "C.java"); + IType type = cuC.getType("C"); + IJavaSearchScope scope = SearchEngine.createStrictHierarchyScope(null, type, true, true, null); + + // include focus type: + assertTrue("a10.C should be included in hierarchy scope", scope.encloses(type)); + assertTrue("a10/C.java should be included in hierarchy scope", scope.encloses(cuC.getUnderlyingResource().getFullPath().toString())); } /** * Hierarchy scope test. @@ -2479,7 +2474,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.createStrictHierarchyScope(null, type, true, false, null); // regular sub-types: assertTrue("a10.D should be included in hierarchy scope", scope.encloses(cuD.getType("D"))); @@ -2496,7 +2491,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.createStrictHierarchyScope(null, type, true, false, 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,33 +2504,20 @@ 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.createStrictHierarchyScope(null, type, true, false, null); // member of a sub-type: assertFalse("a10.F$G should not be included in hierarchy scope", scope.encloses(cuE.getType("F").getType("G"))); } /** * Hierarchy scope test. - * (test for enhancement bug 215139 encloses(): find only subtypes and their member types). - */ -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); - - // member of a sub-type: - assertTrue("a10.F$G should be included in hierarchy scope", scope.encloses(cuE.getType("F").getType("G"))); -} -/** - * Hierarchy scope test. * (test for enhancement bug 215139 encloses(): find only subtypes). */ public void testSearchScope12() 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, true, null); + IJavaSearchScope scope = SearchEngine.createStrictHierarchyScope(null, type, true, false, null); // enclosing of a sub-type: assertFalse("a10.H should not be included in hierarchy scope", scope.encloses(cuE.getType("H"))); @@ -2548,7 +2530,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.createStrictHierarchyScope(null, type, true, false, null); search("**", TYPE, DECLARATIONS, scope); assertSearchResults( @@ -2565,7 +2547,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.createStrictHierarchyScope(null, type, /*onlySubTypes*/false, true, null); search("**", TYPE, DECLARATIONS, scope); assertSearchResults( @@ -2581,40 +2563,33 @@ } /** * Hierarchy scope test. - * (test for enhancement bug 215139 search: find only subtypes - different call chain). + * test for enhancement bug 215139 search: find only subtypes - disabled, + * also test enhancement bug 295894: exclude focus type. */ -public void testSearchScope15() throws CoreException { +public void testSearchScope14a() 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); - TypeNameMatchCollector collector = new TypeNameMatchCollector() { - public String toString(){ - return toFullyQualifiedNamesString(); - } - }; - new SearchEngine().searchAllTypeNames( - null, - null, - scope, - collector, - IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, - null); - String expected = - "a10.D\n" + - "a10.E\n" + - "a10.F\n" + - "a10.H$I"; - assertTrue("We should get some types!", collector.size() > 0); - assertEquals("Found types sound not to be correct", expected, collector.toString()); + IJavaSearchScope scope = SearchEngine.createStrictHierarchyScope(null, type, /*onlySubTypes*/false, false, null); + + search("**", TYPE, DECLARATIONS, scope); + assertSearchResults( + "src/a10/B.java a10.A [A]\n" + + "src/a10/B.java a10.B [B]\n" + + "src/a10/D.java a10.D [D]\n" + + "src/a10/E.java a10.E [E]\n" + + "src/a10/E.java a10.F [F]\n" + + "src/a10/E.java a10.H$I [I]\n" + + getExternalJCLPathString() + " java.lang.Object" + ); } /** * Hierarchy scope test. - * (test for enhancement bug 215139 search: find only subtypes plus member & enclosing types - different call chain). + * (test for enhancement bug 215139 search: find only subtypes - different call chain). */ -public void testSearchScope16() throws CoreException { +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, false, null); + IJavaSearchScope scope = SearchEngine.createStrictHierarchyScope(null, type, true, false, null); TypeNameMatchCollector collector = new TypeNameMatchCollector() { public String toString(){ return toFullyQualifiedNamesString(); @@ -2631,8 +2606,6 @@ "a10.D\n" + "a10.E\n" + "a10.F\n" + - "a10.F$G\n" + - "a10.H\n" + "a10.H$I"; assertTrue("We should get some types!", collector.size() > 0); assertEquals("Found types sound not to be correct", expected, collector.toString()); @@ -2645,25 +2618,12 @@ 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.createStrictHierarchyScope(null, type, true, false, 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]))); } /** - * Hierarchy scope test. - * (test for enhancement bug 215139 encloses(method): find only subtypes but also member types). - */ -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); - - // 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]))); -} -/** * Simple type declaration test. */ public void testTypeDeclaration01() throws CoreException { // was testSimpleTypeDeclaration