View | Details | Raw Unified | Return to bug 295894 | Differences between
and this patch

Collapse All | Expand All

(-)search/org/eclipse/jdt/core/search/SearchEngine.java (-6 / +5 lines)
Lines 198-221 Link Here
198
	 * neither including supertypes nor the focus type itself.
198
	 * neither including supertypes nor the focus type itself.
199
	 * </p>
199
	 * </p>
200
	 * <p>
200
	 * <p>
201
	 * By default, hierarchy scopes include also member types and enclosing types of those types
201
	 * Unlike the other <code>createHierarchyScope</code> methods, this method creates
202
	 * that actually span the hierarchy. This method, however, allows to inhibit this behavior,
202
	 * scopes that only contain types that actually span the hierarchy of the focus
203
	 * by passing <code>true</code> to the parameter <code>noMemberTypes</code>.
203
	 * type, but do not include additional enclosing or member types.
204
	 * </p>
204
	 * </p>
205
	 * 
205
	 * 
206
	 * @param project the project to which to constrain the search, or <code>null</code> if
206
	 * @param project the project to which to constrain the search, or <code>null</code> if
207
	 *        search should consider all types in the workspace 
207
	 *        search should consider all types in the workspace 
208
	 * @param type the focus of the hierarchy scope
208
	 * @param type the focus of the hierarchy scope
209
	 * @param onlySubtypes if true only subtypes of <code>type</code> are considered
209
	 * @param onlySubtypes if true only subtypes of <code>type</code> are considered
210
	 * @param noMemberTypes if true do not consider member or enclosing types of types in the given type hiearchy
211
	 * @param owner the owner of working copies that take precedence over original compilation units, 
210
	 * @param owner the owner of working copies that take precedence over original compilation units, 
212
	 *        or <code>null</code> if the primary working copy owner should be used
211
	 *        or <code>null</code> if the primary working copy owner should be used
213
	 * @return a new hierarchy scope
212
	 * @return a new hierarchy scope
214
	 * @exception JavaModelException if the hierarchy could not be computed on the given type
213
	 * @exception JavaModelException if the hierarchy could not be computed on the given type
215
	 * @since 3.6
214
	 * @since 3.6
216
	 */
215
	 */
217
	public static IJavaSearchScope createHierarchyScope(IJavaProject project, IType type, boolean onlySubtypes, boolean noMemberTypes, WorkingCopyOwner owner) throws JavaModelException {
216
	public static IJavaSearchScope createHierarchyScope(IJavaProject project, IType type, boolean onlySubtypes, WorkingCopyOwner owner) throws JavaModelException {
218
		return BasicSearchEngine.createHierarchyScope(project, type, onlySubtypes, noMemberTypes, owner);
217
		return BasicSearchEngine.createHierarchyScope(project, type, onlySubtypes, owner);
219
	}
218
	}
220
219
221
	/**
220
	/**
(-)search/org/eclipse/jdt/internal/core/search/BasicSearchEngine.java (-3 / +3 lines)
Lines 109-118 Link Here
109
	}
109
	}
110
110
111
	/**
111
	/**
112
	 * @see SearchEngine#createHierarchyScope(IJavaProject,IType,boolean,boolean,WorkingCopyOwner) for detailed comment.
112
	 * @see SearchEngine#createHierarchyScope(IJavaProject,IType,boolean,WorkingCopyOwner) for detailed comment.
113
	 */
113
	 */
114
	public static IJavaSearchScope createHierarchyScope(IJavaProject project, IType type, boolean onlySubtypes, boolean noMemberTypes, WorkingCopyOwner owner) throws JavaModelException {
114
	public static IJavaSearchScope createHierarchyScope(IJavaProject project, IType type, boolean onlySubtypes, WorkingCopyOwner owner) throws JavaModelException {
115
		return new HierarchyScope(project, type, owner, onlySubtypes, noMemberTypes);
115
		return new HierarchyScope(project, type, owner, onlySubtypes);
116
	}
116
	}
117
117
118
	/**
118
	/**
(-)search/org/eclipse/jdt/internal/core/search/HierarchyScope.java (-3 / +5 lines)
Lines 62-82 Link Here
62
62
63
	/**
63
	/**
64
	 * Creates a new hierarchy scope for the given type.
64
	 * Creates a new hierarchy scope for the given type.
65
	 * Unlike the other constructor, this constructor creates scopes that only contain types
66
	 * that actually span the hierarchy of the focus type, but do not include additional
67
	 * enclosing or member types.
65
	 * @param project      constrain the search result to this project, 
68
	 * @param project      constrain the search result to this project, 
66
	 *                     or <code>null</code> if search should consider all types in the workspace 
69
	 *                     or <code>null</code> if search should consider all types in the workspace 
67
	 * @param type         the focus type of the hierarchy
70
	 * @param type         the focus type of the hierarchy
68
	 * @param owner 	   the owner of working copies that take precedence over original compilation units, 
71
	 * @param owner 	   the owner of working copies that take precedence over original compilation units, 
69
	 *                     or <code>null</code> if the primary working copy owner should be used
72
	 *                     or <code>null</code> if the primary working copy owner should be used
70
	 * @param onlySubtypes if true search only subtypes of 'type' (not including 'type')
73
	 * @param onlySubtypes if true search only subtypes of 'type' (not including 'type')
71
	 * @param noMemberTypes if true do not consider member or enclosing types of types in the given type hierarchy.
72
	 */
74
	 */
73
	public HierarchyScope(IJavaProject project, IType type, WorkingCopyOwner owner, boolean onlySubtypes, boolean noMemberTypes) throws JavaModelException {
75
	public HierarchyScope(IJavaProject project, IType type, WorkingCopyOwner owner, boolean onlySubtypes) throws JavaModelException {
74
		this(type, owner);
76
		this(type, owner);
75
		this.javaProject = project;
77
		this.javaProject = project;
76
		if (onlySubtypes) {
78
		if (onlySubtypes) {
77
			this.subTypes = new HashSet();
79
			this.subTypes = new HashSet();
78
		}
80
		}
79
		this.allowMemberTypes = !noMemberTypes;
81
		this.allowMemberTypes = false;
80
	}
82
	}
81
83
82
	/* (non-Javadoc)
84
	/* (non-Javadoc)
(-)src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java (-61 / +160 lines)
Lines 7729-7735 Link Here
7729
		this.resultCollector.showSelection();
7729
		this.resultCollector.showSelection();
7730
		search(packageFragment, REFERENCES);
7730
		search(packageFragment, REFERENCES);
7731
		assertSearchResults(
7731
		assertSearchResults(
7732
			"src/b153765/test/SomeClass.java void b153765.test.SomeClass.foo() [        @�|b153765|�.Unimportant public void foo() {}] EXACT_MATCH"
7732
			"src/b153765/test/SomeClass.java void b153765.test.SomeClass.foo() [        @�|b153765|�.Unimportant public void foo() {}] EXACT_MATCH"
7733
		);
7733
		);
7734
	}
7734
	}
7735
	finally {
7735
	finally {
Lines 9479-9485 Link Here
9479
	collector.showSelection();
9479
	collector.showSelection();
9480
	search(type, REFERENCES, EXACT_RULE, getJavaSearchScope(), collector);
9480
	search(type, REFERENCES, EXACT_RULE, getJavaSearchScope(), collector);
9481
	assertSearchResults(
9481
	assertSearchResults(
9482
		"src/test/Test.java void test.Test.method() [        @Annot(clazz=�|Test|�.class) int x;]+[@Annot on x]",
9482
		"src/test/Test.java void test.Test.method() [        @Annot(clazz=�|Test|�.class) int x;]+[@Annot on x]",
9483
		collector
9483
		collector
9484
	);
9484
	);
9485
}
9485
}
Lines 9495-9501 Link Here
9495
	collector.showSelection();
9495
	collector.showSelection();
9496
	search("Deprecated", TYPE, REFERENCES, EXACT_RULE, getJavaSearchScope(), collector);
9496
	search("Deprecated", TYPE, REFERENCES, EXACT_RULE, getJavaSearchScope(), collector);
9497
	assertSearchResults(
9497
	assertSearchResults(
9498
		"src/test/Test.java void test.Test.foo() [        @�|Deprecated|� foo() {}]+[@Deprecated on foo]",
9498
		"src/test/Test.java void test.Test.foo() [        @�|Deprecated|� foo() {}]+[@Deprecated on foo]",
9499
		collector
9499
		collector
9500
	);
9500
	);
9501
}
9501
}
Lines 9521-9531 Link Here
9521
	collector.showSelection();
9521
	collector.showSelection();
9522
	search(type, REFERENCES, EXACT_RULE, getJavaSearchScope(), collector);
9522
	search(type, REFERENCES, EXACT_RULE, getJavaSearchScope(), collector);
9523
	assertSearchResults(
9523
	assertSearchResults(
9524
		"src/comment5/Ref.java void comment5.Ref.doA(Ref) [    void doA(�|Ref|� ref) {}]+[ref]\n" + 
9524
		"src/comment5/Ref.java void comment5.Ref.doA(Ref) [    void doA(�|Ref|� ref) {}]+[ref]\n" + 
9525
		"src/comment5/Ref.java void comment5.Ref.doB(List<Ref>) [    void doB(List<�|Ref|�> ref) {}]+[ref]\n" + 
9525
		"src/comment5/Ref.java void comment5.Ref.doB(List<Ref>) [    void doB(List<�|Ref|�> ref) {}]+[ref]\n" + 
9526
		"src/comment5/Ref.java void comment5.Ref.doC(Ref) [    void doC(@Tag(�|Ref|�.class) Ref ref) {}]+[@Tag on ref]\n" + 
9526
		"src/comment5/Ref.java void comment5.Ref.doC(Ref) [    void doC(@Tag(�|Ref|�.class) Ref ref) {}]+[@Tag on ref]\n" + 
9527
		"src/comment5/Ref.java void comment5.Ref.doC(Ref) [    void doC(@Tag(Ref.class) �|Ref|� ref) {}]+[ref]\n" + 
9527
		"src/comment5/Ref.java void comment5.Ref.doC(Ref) [    void doC(@Tag(Ref.class) �|Ref|� ref) {}]+[ref]\n" + 
9528
		"src/comment5/Ref.java void comment5.Ref.dontD(Object) [    void dontD(@Tag(�|Ref|�.class) Object ref) {}]+[@Tag on ref]",
9528
		"src/comment5/Ref.java void comment5.Ref.dontD(Object) [    void dontD(@Tag(�|Ref|�.class) Object ref) {}]+[@Tag on ref]",
9529
		collector
9529
		collector
9530
	);
9530
	);
9531
}
9531
}
Lines 9544-9550 Link Here
9544
	collector.showSelection();
9544
	collector.showSelection();
9545
	search(field, REFERENCES, EXACT_RULE, getJavaSearchScope(), collector);
9545
	search(field, REFERENCES, EXACT_RULE, getJavaSearchScope(), collector);
9546
	assertSearchResults(
9546
	assertSearchResults(
9547
		"src/comment10/Ref.java comment10.Num [@Num(number= Num.�|CONST|�)]+[@Num on Num]",
9547
		"src/comment10/Ref.java comment10.Num [@Num(number= Num.�|CONST|�)]+[@Num on Num]",
9548
		collector
9548
		collector
9549
	);
9549
	);
9550
}
9550
}
Lines 9566-9574 Link Here
9566
	collector.showSelection();
9566
	collector.showSelection();
9567
	search(type, REFERENCES, EXACT_RULE, getJavaSearchScope(), collector);
9567
	search(type, REFERENCES, EXACT_RULE, getJavaSearchScope(), collector);
9568
	assertSearchResults(
9568
	assertSearchResults(
9569
		"src/comment22/Test.java comment22.Test.test1 [    @�|Tag|� Test test1, test2, test3;]+[@Tag on test1]+[@Tag on test2,@Tag on test3]\n" + 
9569
		"src/comment22/Test.java comment22.Test.test1 [    @�|Tag|� Test test1, test2, test3;]+[@Tag on test1]+[@Tag on test2,@Tag on test3]\n" + 
9570
		"src/comment22/Test.java void comment22.Test.method() [        @�|Tag|� Test local= null;]+[@Tag on local]\n" + 
9570
		"src/comment22/Test.java void comment22.Test.method() [        @�|Tag|� Test local= null;]+[@Tag on local]\n" + 
9571
		"src/comment22/Test.java void comment22.Test.method() [        @�|Tag|� Test local1, local2, local3;]+[@Tag on local1]+[@Tag on local2,@Tag on local3]",
9571
		"src/comment22/Test.java void comment22.Test.method() [        @�|Tag|� Test local1, local2, local3;]+[@Tag on local1]+[@Tag on local2,@Tag on local3]",
9572
		collector
9572
		collector
9573
	);
9573
	);
9574
}
9574
}
Lines 9588-9594 Link Here
9588
	collector.showSelection();
9588
	collector.showSelection();
9589
	search(type, REFERENCES, EXACT_RULE, getJavaSearchScope(), collector);
9589
	search(type, REFERENCES, EXACT_RULE, getJavaSearchScope(), collector);
9590
	assertSearchResults(
9590
	assertSearchResults(
9591
		"src/test/Test.java test.TestMethodReference.x [    @Annot(clazz = �|test.Test|�.class) int x, y;]+[@Annot on x]+[@Annot on y]",
9591
		"src/test/Test.java test.TestMethodReference.x [    @Annot(clazz = �|test.Test|�.class) int x, y;]+[@Annot on x]+[@Annot on y]",
9592
		collector
9592
		collector
9593
	);
9593
	);
9594
}
9594
}
Lines 9643-9663 Link Here
9643
	this.resultCollector.showSelection();
9643
	this.resultCollector.showSelection();
9644
	search("*", TYPE, REFERENCES, getJavaSearchWorkingCopiesScope(), this.resultCollector);
9644
	search("*", TYPE, REFERENCES, getJavaSearchWorkingCopiesScope(), this.resultCollector);
9645
	assertSearchResults(
9645
	assertSearchResults(
9646
		"src/generics/Generic.java [import �|java.io.Serializable|�;] EXACT_MATCH\n" +
9646
		"src/generics/Generic.java [import �|java.io.Serializable|�;] EXACT_MATCH\n" +
9647
		"src/generics/Generic.java [import �|type.def.Types|�;] EXACT_MATCH\n" +
9647
		"src/generics/Generic.java [import �|type.def.Types|�;] EXACT_MATCH\n" +
9648
		"src/generics/Generic.java generics.Generic [public class Generic<T extends �|Types|�, U extends Types & Comparable<Types> & Serializable, V extends A<? super Types>> {] EXACT_MATCH\n" +
9648
		"src/generics/Generic.java generics.Generic [public class Generic<T extends �|Types|�, U extends Types & Comparable<Types> & Serializable, V extends A<? super Types>> {] EXACT_MATCH\n" +
9649
		"src/generics/Generic.java generics.Generic [public class Generic<T extends Types, U extends �|Types|� & Comparable<Types> & Serializable, V extends A<? super Types>> {] EXACT_MATCH\n" +
9649
		"src/generics/Generic.java generics.Generic [public class Generic<T extends Types, U extends �|Types|� & Comparable<Types> & Serializable, V extends A<? super Types>> {] EXACT_MATCH\n" +
9650
		"src/generics/Generic.java generics.Generic [public class Generic<T extends Types, U extends Types & �|Comparable|�<Types> & Serializable, V extends A<? super Types>> {] EXACT_MATCH\n" +
9650
		"src/generics/Generic.java generics.Generic [public class Generic<T extends Types, U extends Types & �|Comparable|�<Types> & Serializable, V extends A<? super Types>> {] EXACT_MATCH\n" +
9651
		"src/generics/Generic.java generics.Generic [public class Generic<T extends Types, U extends Types & Comparable<�|Types|�> & Serializable, V extends A<? super Types>> {] EXACT_MATCH\n" +
9651
		"src/generics/Generic.java generics.Generic [public class Generic<T extends Types, U extends Types & Comparable<�|Types|�> & Serializable, V extends A<? super Types>> {] EXACT_MATCH\n" +
9652
		"src/generics/Generic.java generics.Generic [public class Generic<T extends Types, U extends Types & Comparable<Types> & �|Serializable|�, V extends A<? super Types>> {] EXACT_MATCH\n" +
9652
		"src/generics/Generic.java generics.Generic [public class Generic<T extends Types, U extends Types & Comparable<Types> & �|Serializable|�, V extends A<? super Types>> {] EXACT_MATCH\n" +
9653
		"src/generics/Generic.java generics.Generic [public class Generic<T extends Types, U extends Types & Comparable<Types> & Serializable, V extends �|A|�<? super Types>> {] EXACT_MATCH\n" +
9653
		"src/generics/Generic.java generics.Generic [public class Generic<T extends Types, U extends Types & Comparable<Types> & Serializable, V extends �|A|�<? super Types>> {] EXACT_MATCH\n" +
9654
		"src/generics/Generic.java generics.Generic [public class Generic<T extends Types, U extends Types & Comparable<Types> & Serializable, V extends A<? super �|Types|�>> {] EXACT_MATCH\n" +
9654
		"src/generics/Generic.java generics.Generic [public class Generic<T extends Types, U extends Types & Comparable<Types> & Serializable, V extends A<? super �|Types|�>> {] EXACT_MATCH\n" +
9655
		"src/generics/Generic.java generics.Generic.field [	�|Generic|�<? extends Types, ?, ?> field;] EXACT_MATCH\n" +
9655
		"src/generics/Generic.java generics.Generic.field [	�|Generic|�<? extends Types, ?, ?> field;] EXACT_MATCH\n" +
9656
		"src/generics/Generic.java generics.Generic.field [	Generic<? extends �|Types|�, ?, ?> field;] EXACT_MATCH\n" +
9656
		"src/generics/Generic.java generics.Generic.field [	Generic<? extends �|Types|�, ?, ?> field;] EXACT_MATCH\n" +
9657
		"src/generics/Generic.java generics.Generic.comp [	�|Comparable|�<String> comp;] EXACT_MATCH\n" +
9657
		"src/generics/Generic.java generics.Generic.comp [	�|Comparable|�<String> comp;] EXACT_MATCH\n" +
9658
		"src/generics/Generic.java generics.Generic.comp [	Comparable<�|String|�> comp;] EXACT_MATCH\n" +
9658
		"src/generics/Generic.java generics.Generic.comp [	Comparable<�|String|�> comp;] EXACT_MATCH\n" +
9659
		"src/generics/Generic.java generics.Generic.clazz [	�|Class|�<? extends Exception> clazz;] EXACT_MATCH\n" +
9659
		"src/generics/Generic.java generics.Generic.clazz [	�|Class|�<? extends Exception> clazz;] EXACT_MATCH\n" +
9660
		"src/generics/Generic.java generics.Generic.clazz [	Class<? extends �|Exception|�> clazz;] EXACT_MATCH"
9660
		"src/generics/Generic.java generics.Generic.clazz [	Class<? extends �|Exception|�> clazz;] EXACT_MATCH"
9661
	);
9661
	);
9662
}
9662
}
9663
9663
Lines 9682-9689 Link Here
9682
	this.resultCollector.showSelection();
9682
	this.resultCollector.showSelection();
9683
	search("*", TYPE, REFERENCES, getJavaSearchWorkingCopiesScope(), this.resultCollector);
9683
	search("*", TYPE, REFERENCES, getJavaSearchWorkingCopiesScope(), this.resultCollector);
9684
	assertSearchResults(
9684
	assertSearchResults(
9685
		"src/test/Ref.java [import �|pack.Test|�;] EXACT_MATCH\n" +
9685
		"src/test/Ref.java [import �|pack.Test|�;] EXACT_MATCH\n" +
9686
		"src/test/Ref.java test.Ref.test [	�|Test|� test;] EXACT_MATCH"
9686
		"src/test/Ref.java test.Ref.test [	�|Test|� test;] EXACT_MATCH"
9687
	);
9687
	);
9688
}
9688
}
9689
9689
Lines 9906-9912 Link Here
9906
	ILocalVariable variable = selectLocalVariable(this.workingCopies[0], "test");
9906
	ILocalVariable variable = selectLocalVariable(this.workingCopies[0], "test");
9907
	search(variable, READ_ACCESSES, getJavaSearchWorkingCopiesScope(), this.resultCollector);
9907
	search(variable, READ_ACCESSES, getJavaSearchWorkingCopiesScope(), this.resultCollector);
9908
	assertSearchResults(
9908
	assertSearchResults(
9909
		"src/Test.java void Test.m() [        �|test|�.fField = 42; // match for t is writeAccess, should be readAccess] EXACT_MATCH"
9909
		"src/Test.java void Test.m() [        �|test|�.fField = 42; // match for t is writeAccess, should be readAccess] EXACT_MATCH"
9910
	);
9910
	);
9911
}
9911
}
9912
public void testBug216875b() throws CoreException {
9912
public void testBug216875b() throws CoreException {
Lines 9926-9932 Link Here
9926
	IField field = this.workingCopies[0].getType("Test").getField("fWrapped");
9926
	IField field = this.workingCopies[0].getType("Test").getField("fWrapped");
9927
	search(field, READ_ACCESSES, getJavaSearchWorkingCopiesScope(), this.resultCollector);
9927
	search(field, READ_ACCESSES, getJavaSearchWorkingCopiesScope(), this.resultCollector);
9928
	assertSearchResults(
9928
	assertSearchResults(
9929
		"src/Test.java void Test.wrapper() [        �|fWrapped|�.fField = 12; // match for fWrapped is writeAccess] EXACT_MATCH"
9929
		"src/Test.java void Test.wrapper() [        �|fWrapped|�.fField = 12; // match for fWrapped is writeAccess] EXACT_MATCH"
9930
	);
9930
	);
9931
}
9931
}
9932
public void testBug216875c() throws CoreException {
9932
public void testBug216875c() throws CoreException {
Lines 9952-9960 Link Here
9952
	ILocalVariable variable = selectLocalVariable(this.workingCopies[1], "t1");
9952
	ILocalVariable variable = selectLocalVariable(this.workingCopies[1], "t1");
9953
	search(variable, READ_ACCESSES, getJavaSearchWorkingCopiesScope(), this.resultCollector);
9953
	search(variable, READ_ACCESSES, getJavaSearchWorkingCopiesScope(), this.resultCollector);
9954
	assertSearchResults(
9954
	assertSearchResults(
9955
		"src/test/X.java void test.X.foo(Test, Test) [		�|t1|�.field = t1.field;] EXACT_MATCH\n" +
9955
		"src/test/X.java void test.X.foo(Test, Test) [		�|t1|�.field = t1.field;] EXACT_MATCH\n" +
9956
		"src/test/X.java void test.X.foo(Test, Test) [		t1.field = �|t1|�.field;] EXACT_MATCH\n" +
9956
		"src/test/X.java void test.X.foo(Test, Test) [		t1.field = �|t1|�.field;] EXACT_MATCH\n" +
9957
		"src/test/X.java void test.X.foo(Test, Test) [		t2.field = �|t1|�.field;] EXACT_MATCH"
9957
		"src/test/X.java void test.X.foo(Test, Test) [		t2.field = �|t1|�.field;] EXACT_MATCH"
9958
	);
9958
	);
9959
}
9959
}
9960
public void testBug216875d() throws CoreException {
9960
public void testBug216875d() throws CoreException {
Lines 9981-9989 Link Here
9981
	IField field = this.workingCopies[1].getType("X").getField("t1");
9981
	IField field = this.workingCopies[1].getType("X").getField("t1");
9982
	search(field, READ_ACCESSES, getJavaSearchWorkingCopiesScope(), this.resultCollector);
9982
	search(field, READ_ACCESSES, getJavaSearchWorkingCopiesScope(), this.resultCollector);
9983
	assertSearchResults(
9983
	assertSearchResults(
9984
		"src/test/X.java void test.X.foo() [		�|t1|�.field = t1.field;] EXACT_MATCH\n" +
9984
		"src/test/X.java void test.X.foo() [		�|t1|�.field = t1.field;] EXACT_MATCH\n" +
9985
		"src/test/X.java void test.X.foo() [		t1.field = �|t1|�.field;] EXACT_MATCH\n" +
9985
		"src/test/X.java void test.X.foo() [		t1.field = �|t1|�.field;] EXACT_MATCH\n" +
9986
		"src/test/X.java void test.X.foo() [		t2.field = �|t1|�.field;] EXACT_MATCH"
9986
		"src/test/X.java void test.X.foo() [		t2.field = �|t1|�.field;] EXACT_MATCH"
9987
	);
9987
	);
9988
}
9988
}
9989
public void testBug216875e() throws CoreException {
9989
public void testBug216875e() throws CoreException {
Lines 10009-10015 Link Here
10009
	ILocalVariable variable = selectLocalVariable(this.workingCopies[1], "t1");
10009
	ILocalVariable variable = selectLocalVariable(this.workingCopies[1], "t1");
10010
	search(variable, WRITE_ACCESSES, getJavaSearchWorkingCopiesScope(), this.resultCollector);
10010
	search(variable, WRITE_ACCESSES, getJavaSearchWorkingCopiesScope(), this.resultCollector);
10011
	assertSearchResults(
10011
	assertSearchResults(
10012
		"src/test/X.java void test.X.foo(Test, Test) [		�|t1|� = t2;] EXACT_MATCH"
10012
		"src/test/X.java void test.X.foo(Test, Test) [		�|t1|� = t2;] EXACT_MATCH"
10013
	);
10013
	);
10014
}
10014
}
10015
public void testBug216875f() throws CoreException {
10015
public void testBug216875f() throws CoreException {
Lines 10036-10042 Link Here
10036
	IField field = this.workingCopies[1].getType("X").getField("t1");
10036
	IField field = this.workingCopies[1].getType("X").getField("t1");
10037
	search(field, WRITE_ACCESSES, getJavaSearchWorkingCopiesScope(), this.resultCollector);
10037
	search(field, WRITE_ACCESSES, getJavaSearchWorkingCopiesScope(), this.resultCollector);
10038
	assertSearchResults(
10038
	assertSearchResults(
10039
		"src/test/X.java void test.X.foo() [		�|t1|� = t2;] EXACT_MATCH"
10039
		"src/test/X.java void test.X.foo() [		�|t1|� = t2;] EXACT_MATCH"
10040
	);
10040
	);
10041
}
10041
}
10042
public void testBug216875g() throws CoreException {
10042
public void testBug216875g() throws CoreException {
Lines 10064-10073 Link Here
10064
	ILocalVariable variable = selectLocalVariable(this.workingCopies[1], "t1");
10064
	ILocalVariable variable = selectLocalVariable(this.workingCopies[1], "t1");
10065
	search(variable, REFERENCES, getJavaSearchWorkingCopiesScope(), this.resultCollector);
10065
	search(variable, REFERENCES, getJavaSearchWorkingCopiesScope(), this.resultCollector);
10066
	assertSearchResults(
10066
	assertSearchResults(
10067
		"src/test/X.java void test.X.foo(Test, Test) [		�|t1|� = t2;] WRITE ACCESS\n" +
10067
		"src/test/X.java void test.X.foo(Test, Test) [		�|t1|� = t2;] WRITE ACCESS\n" +
10068
		"src/test/X.java void test.X.foo(Test, Test) [		�|t1|�.field = t1.field;] READ ACCESS\n" +
10068
		"src/test/X.java void test.X.foo(Test, Test) [		�|t1|�.field = t1.field;] READ ACCESS\n" +
10069
		"src/test/X.java void test.X.foo(Test, Test) [		t1.field = �|t1|�.field;] READ ACCESS\n" +
10069
		"src/test/X.java void test.X.foo(Test, Test) [		t1.field = �|t1|�.field;] READ ACCESS\n" +
10070
		"src/test/X.java void test.X.foo(Test, Test) [		t2.field = �|t1|�.field;] READ ACCESS"
10070
		"src/test/X.java void test.X.foo(Test, Test) [		t2.field = �|t1|�.field;] READ ACCESS"
10071
	);
10071
	);
10072
}
10072
}
10073
public void testBug216875h() throws CoreException {
10073
public void testBug216875h() throws CoreException {
Lines 10096-10105 Link Here
10096
	IField field = this.workingCopies[1].getType("X").getField("t1");
10096
	IField field = this.workingCopies[1].getType("X").getField("t1");
10097
	search(field, REFERENCES, getJavaSearchWorkingCopiesScope(), this.resultCollector);
10097
	search(field, REFERENCES, getJavaSearchWorkingCopiesScope(), this.resultCollector);
10098
	assertSearchResults(
10098
	assertSearchResults(
10099
		"src/test/X.java void test.X.foo() [		�|t1|� = t2;] WRITE ACCESS\n" +
10099
		"src/test/X.java void test.X.foo() [		�|t1|� = t2;] WRITE ACCESS\n" +
10100
		"src/test/X.java void test.X.foo() [		�|t1|�.field = t1.field;] READ ACCESS\n" +
10100
		"src/test/X.java void test.X.foo() [		�|t1|�.field = t1.field;] READ ACCESS\n" +
10101
		"src/test/X.java void test.X.foo() [		t1.field = �|t1|�.field;] READ ACCESS\n" +
10101
		"src/test/X.java void test.X.foo() [		t1.field = �|t1|�.field;] READ ACCESS\n" +
10102
		"src/test/X.java void test.X.foo() [		t2.field = �|t1|�.field;] READ ACCESS"
10102
		"src/test/X.java void test.X.foo() [		t2.field = �|t1|�.field;] READ ACCESS"
10103
	);
10103
	);
10104
}
10104
}
10105
10105
Lines 10124-10130 Link Here
10124
	IType type = selectType(this.workingCopies[0], "Row");
10124
	IType type = selectType(this.workingCopies[0], "Row");
10125
	search(type, REFERENCES, getJavaSearchWorkingCopiesScope(), this.resultCollector);
10125
	search(type, REFERENCES, getJavaSearchWorkingCopiesScope(), this.resultCollector);
10126
	assertSearchResults(
10126
	assertSearchResults(
10127
		"src/Bug.java Bug.{}:Inner#1.field [			�|Row|� field;//LINE 3] EXACT_MATCH"
10127
		"src/Bug.java Bug.{}:Inner#1.field [			�|Row|� field;//LINE 3] EXACT_MATCH"
10128
	);
10128
	);
10129
}
10129
}
10130
10130
Lines 10160-10171 Link Here
10160
		this.resultCollector,
10160
		this.resultCollector,
10161
		null);
10161
		null);
10162
	assertSearchResults(
10162
	assertSearchResults(
10163
		"src/Test.java Test [public class �|Test|� {] EXACT_MATCH\n" +
10163
		"src/Test.java Test [public class �|Test|� {] EXACT_MATCH\n" +
10164
		"src/Test.java Test.test [	Test �|test|�;] EXACT_MATCH\n" +
10164
		"src/Test.java Test.test [	Test �|test|�;] EXACT_MATCH\n" +
10165
		"src/Test.java Test.test [	�|Test|� test;] EXACT_MATCH\n" +
10165
		"src/Test.java Test.test [	�|Test|� test;] EXACT_MATCH\n" +
10166
		"src/Test.java void Test.test(Test) [	void �|test|�(Test test) {] EXACT_MATCH\n" +
10166
		"src/Test.java void Test.test(Test) [	void �|test|�(Test test) {] EXACT_MATCH\n" +
10167
		"src/Test.java void Test.test(Test) [	void test(�|Test|� test) {] EXACT_MATCH\n" +
10167
		"src/Test.java void Test.test(Test) [	void test(�|Test|� test) {] EXACT_MATCH\n" +
10168
		"src/Test.java void Test.test(Test) [		if (test == this.�|test|�) {] EXACT_MATCH"
10168
		"src/Test.java void Test.test(Test) [		if (test == this.�|test|�) {] EXACT_MATCH"
10169
	);
10169
	);
10170
}
10170
}
10171
10171
Lines 10190-10196 Link Here
10190
	IType type = this.workingCopies[0].getType("X");
10190
	IType type = this.workingCopies[0].getType("X");
10191
	search(type, REFERENCES, SearchPattern.R_ERASURE_MATCH, getJavaSearchWorkingCopiesScope(), this.resultCollector);
10191
	search(type, REFERENCES, SearchPattern.R_ERASURE_MATCH, getJavaSearchWorkingCopiesScope(), this.resultCollector);
10192
	assertSearchResults(
10192
	assertSearchResults(
10193
		"src/Y.java Y [public class Y<T extends �|X|�<?>> {] ERASURE_MATCH"
10193
		"src/Y.java Y [public class Y<T extends �|X|�<?>> {] ERASURE_MATCH"
10194
	);
10194
	);
10195
}
10195
}
10196
public void testBug221110b() throws CoreException {
10196
public void testBug221110b() throws CoreException {
Lines 10212-10218 Link Here
10212
	IType type = this.workingCopies[0].getType("I");
10212
	IType type = this.workingCopies[0].getType("I");
10213
	search(type, REFERENCES, SearchPattern.R_ERASURE_MATCH, getJavaSearchWorkingCopiesScope(), this.resultCollector);
10213
	search(type, REFERENCES, SearchPattern.R_ERASURE_MATCH, getJavaSearchWorkingCopiesScope(), this.resultCollector);
10214
	assertSearchResults(
10214
	assertSearchResults(
10215
		"src/Z.java Z [public class Z<T extends X<?> & �|I|�<?>> {] ERASURE_MATCH"
10215
		"src/Z.java Z [public class Z<T extends X<?> & �|I|�<?>> {] ERASURE_MATCH"
10216
	);
10216
	);
10217
}
10217
}
10218
10218
Lines 10537-10544 Link Here
10537
	this.resultCollector.showSelection();
10537
	this.resultCollector.showSelection();
10538
	search("B251827*", TYPE, REFERENCES);
10538
	search("B251827*", TYPE, REFERENCES);
10539
	assertSearchResults(
10539
	assertSearchResults(
10540
		"src/b251827/X.java [import static b251827.�|B251827|�.VAL;] EXACT_MATCH\n" + 
10540
		"src/b251827/X.java [import static b251827.�|B251827|�.VAL;] EXACT_MATCH\n" + 
10541
		"src/b251827/X.java [import static b251827.�|B251827|�.foo;] EXACT_MATCH"
10541
		"src/b251827/X.java [import static b251827.�|B251827|�.foo;] EXACT_MATCH"
10542
	);
10542
	);
10543
}
10543
}
10544
public void testBug251827b() throws CoreException {
10544
public void testBug251827b() throws CoreException {
Lines 10564-10570 Link Here
10564
	this.resultCollector.showSelection();
10564
	this.resultCollector.showSelection();
10565
	search("B251827*", TYPE, REFERENCES);
10565
	search("B251827*", TYPE, REFERENCES);
10566
	assertSearchResults(
10566
	assertSearchResults(
10567
		"src/b251827/X.java [import static b251827.�|B251827|�.*;] EXACT_MATCH"
10567
		"src/b251827/X.java [import static b251827.�|B251827|�.*;] EXACT_MATCH"
10568
	);
10568
	);
10569
}
10569
}
10570
public void testBug251827c() throws CoreException {
10570
public void testBug251827c() throws CoreException {
Lines 10592-10598 Link Here
10592
	);
10592
	);
10593
	search("B251827*", TYPE, REFERENCES);
10593
	search("B251827*", TYPE, REFERENCES);
10594
	assertSearchResults(
10594
	assertSearchResults(
10595
		"src/b251827/X.java void b251827.X.bar(B251827) [	void bar(�|B251827|� m) {;] EXACT_MATCH"
10595
		"src/b251827/X.java void b251827.X.bar(B251827) [	void bar(�|B251827|� m) {;] EXACT_MATCH"
10596
	);
10596
	);
10597
}
10597
}
10598
10598
Lines 11029-11032 Link Here
11029
		deleteProject("P");
11029
		deleteProject("P");
11030
	}
11030
	}
11031
}
11031
}
11032
11033
static { TESTS_PREFIX = "testBug295894"; }
11034
/**
11035
 * @bug 295894: Search shows focus type implementation for nested types even though the scope is restricted to subtypes.
11036
 * @test using the hierarchy with the old API includes the focus type. 
11037
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=295894"
11038
 */
11039
public void testBug295894() throws Exception {
11040
	this.workingCopies = new ICompilationUnit[1];
11041
	this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/Test.java",
11042
		"public class Test {\n" + 
11043
		"    void test() {\n" + 
11044
		"        Test t = new Test();\n" + 
11045
		"        t.foo();\n" + 
11046
		"    }\n" + 
11047
		"    public void foo() {\n" + 
11048
		"    }\n" + 
11049
		"    public class Sub extends Test {\n" + 
11050
		"        public void foo() {}\n" + 
11051
		"    }\n" + 
11052
		"}\n" + 
11053
		""
11054
	);
11055
	search(
11056
		"foo",
11057
		METHOD,
11058
		DECLARATIONS,
11059
		SearchEngine.createHierarchyScope(this.workingCopies[0].findPrimaryType()),
11060
		this.resultCollector);
11061
	assertSearchResults(
11062
		"src/Test.java void Test.foo() [foo] EXACT_MATCH\n" + 
11063
		"src/Test.java void Test$Sub.foo() [foo] EXACT_MATCH"
11064
	);
11065
}
11066
/**
11067
 * @bug 295894: Search shows focus type implementation for nested types even though the scope is restricted to subtypes.
11068
 * @test when restricting the hierarchy to sub types the focus should not be included 
11069
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=295894"
11070
 */
11071
public void testBug295894a() throws Exception {
11072
	this.workingCopies = new ICompilationUnit[1];
11073
	this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/Test.java",
11074
		"public class Test {\n" + 
11075
		"    void test() {\n" + 
11076
		"        Test t = new Test();\n" + 
11077
		"        t.foo();\n" + 
11078
		"    }\n" + 
11079
		"    public void foo() {\n" + 
11080
		"    }\n" + 
11081
		"    public class Sub extends Test {\n" + 
11082
		"        public void foo() {}\n" + 
11083
		"    }\n" + 
11084
		"}\n" + 
11085
		""
11086
	);
11087
	search(
11088
		"foo",
11089
		METHOD,
11090
		DECLARATIONS,
11091
		SearchEngine.createHierarchyScope(null, this.workingCopies[0].findPrimaryType(), true, null),
11092
		this.resultCollector);
11093
	// Test$Sub is a true sub type, not affected by filtering member types
11094
	assertSearchResults(
11095
		"src/Test.java void Test$Sub.foo() [foo] EXACT_MATCH"
11096
	);
11097
}
11098
/**
11099
 * @bug 295894: Search shows focus type implementation for nested types even though the scope is restricted to subtypes.
11100
 * @test when not restricting the hierarchy to sub types the focus should be included 
11101
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=295894"
11102
 */
11103
public void testBug295894b() throws Exception {
11104
	this.workingCopies = new ICompilationUnit[1];
11105
	this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/Test.java",
11106
		"public class Test {\n" + 
11107
		"    void test() {\n" + 
11108
		"        Test t = new Test();\n" + 
11109
		"        t.foo();\n" + 
11110
		"    }\n" + 
11111
		"    public void foo() {\n" + 
11112
		"    }\n" + 
11113
		"    public class Sub extends Test {\n" + 
11114
		"        public void foo() {}\n" + 
11115
		"    }\n" + 
11116
		"}\n" + 
11117
		""
11118
	);
11119
	search(
11120
		"foo",
11121
		METHOD,
11122
		DECLARATIONS,
11123
		SearchEngine.createHierarchyScope(null, this.workingCopies[0].findPrimaryType(), false, null),
11124
		this.resultCollector);
11125
	// Same results as with the old API
11126
	assertSearchResults(
11127
		"src/Test.java void Test.foo() [foo] EXACT_MATCH\n" + 
11128
		"src/Test.java void Test$Sub.foo() [foo] EXACT_MATCH"
11129
	);
11130
}
11032
}
11131
}
(-)src/org/eclipse/jdt/core/tests/model/JavaSearchTests.java (-22 / +25 lines)
Lines 1365-1371 Link Here
1365
		"foo",
1365
		"foo",
1366
		METHOD,
1366
		METHOD,
1367
		DECLARATIONS,
1367
		DECLARATIONS,
1368
		SearchEngine.createHierarchyScope(null, type, false, true, null),
1368
		SearchEngine.createHierarchyScope(null, type, false, null),
1369
		this.resultCollector);
1369
		this.resultCollector);
1370
	assertSearchResults(
1370
	assertSearchResults(
1371
		"src/p/X.java void p.X.foo(int, String, X) [foo]\n" +
1371
		"src/p/X.java void p.X.foo(int, String, X) [foo]\n" +
Lines 2450-2456 Link Here
2450
    	ICompilationUnit cuB = this. getCompilationUnit("JavaSearch", "src", "a10", "B.java");
2450
    	ICompilationUnit cuB = this. getCompilationUnit("JavaSearch", "src", "a10", "B.java");
2451
        ICompilationUnit cuC = this. getCompilationUnit("JavaSearch", "src", "a10", "C.java");
2451
        ICompilationUnit cuC = this. getCompilationUnit("JavaSearch", "src", "a10", "C.java");
2452
        IType type = cuC.getType("C");
2452
        IType type = cuC.getType("C");
2453
        IJavaSearchScope scope = SearchEngine.createHierarchyScope(null, type, true, true, null);
2453
        IJavaSearchScope scope = SearchEngine.createHierarchyScope(null, type, true, null);
2454
        
2454
        
2455
        // don't include super-classes:
2455
        // don't include super-classes:
2456
        assertFalse("a10.A should not be included in hierarchy scope", scope.encloses(cuB.getType("A")));
2456
        assertFalse("a10.A should not be included in hierarchy scope", scope.encloses(cuB.getType("A")));
Lines 2464-2470 Link Here
2464
public void testSearchScope07() throws CoreException {
2464
public void testSearchScope07() throws CoreException {
2465
    	ICompilationUnit cuC = this. getCompilationUnit("JavaSearch", "src", "a10", "C.java");
2465
    	ICompilationUnit cuC = this. getCompilationUnit("JavaSearch", "src", "a10", "C.java");
2466
        IType type = cuC.getType("C");
2466
        IType type = cuC.getType("C");
2467
        IJavaSearchScope scope = SearchEngine.createHierarchyScope(null, type, true, true, null);
2467
        IJavaSearchScope scope = SearchEngine.createHierarchyScope(null, type, true, null);
2468
        
2468
        
2469
        // don't include focus type:
2469
        // don't include focus type:
2470
        assertFalse("a10.C should be not included in hierarchy scope", scope.encloses(type));
2470
        assertFalse("a10.C should be not included in hierarchy scope", scope.encloses(type));
Lines 2479-2485 Link Here
2479
        ICompilationUnit cuD = this. getCompilationUnit("JavaSearch", "src", "a10", "D.java");
2479
        ICompilationUnit cuD = this. getCompilationUnit("JavaSearch", "src", "a10", "D.java");
2480
        ICompilationUnit cuE = this. getCompilationUnit("JavaSearch", "src", "a10", "E.java");
2480
        ICompilationUnit cuE = this. getCompilationUnit("JavaSearch", "src", "a10", "E.java");
2481
        IType type = cuC.getType("C");
2481
        IType type = cuC.getType("C");
2482
        IJavaSearchScope scope = SearchEngine.createHierarchyScope(null, type, true, true, null);
2482
        IJavaSearchScope scope = SearchEngine.createHierarchyScope(null, type, true, null);
2483
        
2483
        
2484
        // regular sub-types:
2484
        // regular sub-types:
2485
        assertTrue("a10.D should be included in hierarchy scope", scope.encloses(cuD.getType("D")));
2485
        assertTrue("a10.D should be included in hierarchy scope", scope.encloses(cuD.getType("D")));
Lines 2496-2502 Link Here
2496
    	ICompilationUnit cuC = this. getCompilationUnit("JavaSearch", "src", "a10", "C.java");
2496
    	ICompilationUnit cuC = this. getCompilationUnit("JavaSearch", "src", "a10", "C.java");
2497
        ICompilationUnit cuE = this. getCompilationUnit("JavaSearch", "src", "a10", "E.java");
2497
        ICompilationUnit cuE = this. getCompilationUnit("JavaSearch", "src", "a10", "E.java");
2498
        IType type = cuC.getType("C");
2498
        IType type = cuC.getType("C");
2499
        IJavaSearchScope scope = SearchEngine.createHierarchyScope(null, type, true, true, null);
2499
        IJavaSearchScope scope = SearchEngine.createHierarchyScope(null, type, true, null);
2500
        
2500
        
2501
        // sub-type is a nested type:
2501
        // sub-type is a nested type:
2502
        assertTrue("a10.H$I should be included in hierarchy scope", scope.encloses(cuE.getType("H").getType("I")));
2502
        assertTrue("a10.H$I should be included in hierarchy scope", scope.encloses(cuE.getType("H").getType("I")));
Lines 2509-2515 Link Here
2509
    	ICompilationUnit cuC = this. getCompilationUnit("JavaSearch", "src", "a10", "C.java");
2509
    	ICompilationUnit cuC = this. getCompilationUnit("JavaSearch", "src", "a10", "C.java");
2510
        ICompilationUnit cuE = this. getCompilationUnit("JavaSearch", "src", "a10", "E.java");
2510
        ICompilationUnit cuE = this. getCompilationUnit("JavaSearch", "src", "a10", "E.java");
2511
        IType type = cuC.getType("C");
2511
        IType type = cuC.getType("C");
2512
        IJavaSearchScope scope = SearchEngine.createHierarchyScope(null, type, true, true, null);
2512
        IJavaSearchScope scope = SearchEngine.createHierarchyScope(null, type, true, null);
2513
        
2513
        
2514
        // member of a sub-type:
2514
        // member of a sub-type:
2515
        assertFalse("a10.F$G should not be included in hierarchy scope", scope.encloses(cuE.getType("F").getType("G")));
2515
        assertFalse("a10.F$G should not be included in hierarchy scope", scope.encloses(cuE.getType("F").getType("G")));
Lines 2517-2528 Link Here
2517
/**
2517
/**
2518
 * Hierarchy scope test.
2518
 * Hierarchy scope test.
2519
 * (test for enhancement bug 215139 encloses(): find only subtypes and their member types).
2519
 * (test for enhancement bug 215139 encloses(): find only subtypes and their member types).
2520
 * Note: this combination of arguments is no longer supported after the change from bug 295894
2520
 */
2521
 */
2521
public void testSearchScope11() throws CoreException {
2522
public void _testSearchScope11() throws CoreException {
2522
    	ICompilationUnit cuC = this. getCompilationUnit("JavaSearch", "src", "a10", "C.java");
2523
    	ICompilationUnit cuC = this. getCompilationUnit("JavaSearch", "src", "a10", "C.java");
2523
        ICompilationUnit cuE = this. getCompilationUnit("JavaSearch", "src", "a10", "E.java");
2524
        ICompilationUnit cuE = this. getCompilationUnit("JavaSearch", "src", "a10", "E.java");
2524
        IType type = cuC.getType("C");
2525
        IType type = cuC.getType("C");
2525
        IJavaSearchScope scope = SearchEngine.createHierarchyScope(null, type, true, false, null);
2526
        IJavaSearchScope scope = SearchEngine.createHierarchyScope(null, type, true, null);
2526
        
2527
        
2527
        // member of a sub-type:
2528
        // member of a sub-type:
2528
        assertTrue("a10.F$G should be included in hierarchy scope", scope.encloses(cuE.getType("F").getType("G")));
2529
        assertTrue("a10.F$G should be included in hierarchy scope", scope.encloses(cuE.getType("F").getType("G")));
Lines 2535-2541 Link Here
2535
    	ICompilationUnit cuC = this. getCompilationUnit("JavaSearch", "src", "a10", "C.java");
2536
    	ICompilationUnit cuC = this. getCompilationUnit("JavaSearch", "src", "a10", "C.java");
2536
        ICompilationUnit cuE = this. getCompilationUnit("JavaSearch", "src", "a10", "E.java");
2537
        ICompilationUnit cuE = this. getCompilationUnit("JavaSearch", "src", "a10", "E.java");
2537
        IType type = cuC.getType("C");
2538
        IType type = cuC.getType("C");
2538
        IJavaSearchScope scope = SearchEngine.createHierarchyScope(null, type, true, true, null);
2539
        IJavaSearchScope scope = SearchEngine.createHierarchyScope(null, type, true, null);
2539
        
2540
        
2540
        // enclosing of a sub-type:
2541
        // enclosing of a sub-type:
2541
        assertFalse("a10.H should not be included in hierarchy scope", scope.encloses(cuE.getType("H")));
2542
        assertFalse("a10.H should not be included in hierarchy scope", scope.encloses(cuE.getType("H")));
Lines 2548-2554 Link Here
2548
public void testSearchScope13() throws CoreException {
2549
public void testSearchScope13() throws CoreException {
2549
        ICompilationUnit cuC = this. getCompilationUnit("JavaSearch", "src", "a10", "C.java");
2550
        ICompilationUnit cuC = this. getCompilationUnit("JavaSearch", "src", "a10", "C.java");
2550
        IType type = cuC.getType("C");
2551
        IType type = cuC.getType("C");
2551
        IJavaSearchScope scope = SearchEngine.createHierarchyScope(null, type, true, true, null);
2552
        IJavaSearchScope scope = SearchEngine.createHierarchyScope(null, type, true, null);
2552
        
2553
        
2553
        search("**", TYPE, DECLARATIONS, scope);
2554
        search("**", TYPE, DECLARATIONS, scope);
2554
        assertSearchResults(
2555
        assertSearchResults(
Lines 2565-2571 Link Here
2565
public void testSearchScope14() throws CoreException {
2566
public void testSearchScope14() throws CoreException {
2566
        ICompilationUnit cuC = this. getCompilationUnit("JavaSearch", "src", "a10", "C.java");
2567
        ICompilationUnit cuC = this. getCompilationUnit("JavaSearch", "src", "a10", "C.java");
2567
        IType type = cuC.getType("C");
2568
        IType type = cuC.getType("C");
2568
        IJavaSearchScope scope = SearchEngine.createHierarchyScope(null, type, /*onlySubTypes*/false, true, null);
2569
        IJavaSearchScope scope = SearchEngine.createHierarchyScope(null, type, /*onlySubTypes*/false, null);
2569
        
2570
        
2570
        search("**", TYPE, DECLARATIONS, scope);
2571
        search("**", TYPE, DECLARATIONS, scope);
2571
        assertSearchResults(
2572
        assertSearchResults(
Lines 2586-2592 Link Here
2586
public void testSearchScope15() throws CoreException {
2587
public void testSearchScope15() throws CoreException {
2587
        ICompilationUnit cuC = this. getCompilationUnit("JavaSearch", "src", "a10", "C.java");
2588
        ICompilationUnit cuC = this. getCompilationUnit("JavaSearch", "src", "a10", "C.java");
2588
        IType type = cuC.getType("C");
2589
        IType type = cuC.getType("C");
2589
        IJavaSearchScope scope = SearchEngine.createHierarchyScope(null, type, true, true, null);
2590
        IJavaSearchScope scope = SearchEngine.createHierarchyScope(null, type, true, null);
2590
    	TypeNameMatchCollector collector = new TypeNameMatchCollector() {
2591
    	TypeNameMatchCollector collector = new TypeNameMatchCollector() {
2591
    		public String toString(){
2592
    		public String toString(){
2592
    			return toFullyQualifiedNamesString();
2593
    			return toFullyQualifiedNamesString();
Lines 2610-2620 Link Here
2610
/**
2611
/**
2611
 * Hierarchy scope test.
2612
 * Hierarchy scope test.
2612
 * (test for enhancement bug 215139 search: find only subtypes plus member & enclosing types - different call chain).
2613
 * (test for enhancement bug 215139 search: find only subtypes plus member & enclosing types - different call chain).
2614
 * Note: this combination of arguments is no longer supported after the change from bug 295894
2613
 */
2615
 */
2614
public void testSearchScope16() throws CoreException {
2616
public void _testSearchScope16() throws CoreException {
2615
        ICompilationUnit cuC = this. getCompilationUnit("JavaSearch", "src", "a10", "C.java");
2617
        ICompilationUnit cuC = this. getCompilationUnit("JavaSearch", "src", "a10", "C.java");
2616
        IType type = cuC.getType("C");
2618
        IType type = cuC.getType("C");
2617
        IJavaSearchScope scope = SearchEngine.createHierarchyScope(null, type, true, false, null);
2619
        IJavaSearchScope scope = SearchEngine.createHierarchyScope(null, type, true, null);
2618
    	TypeNameMatchCollector collector = new TypeNameMatchCollector() {
2620
    	TypeNameMatchCollector collector = new TypeNameMatchCollector() {
2619
    		public String toString(){
2621
    		public String toString(){
2620
    			return toFullyQualifiedNamesString();
2622
    			return toFullyQualifiedNamesString();
Lines 2645-2651 Link Here
2645
    	ICompilationUnit cuC = this. getCompilationUnit("JavaSearch", "src", "a10", "C.java");
2647
    	ICompilationUnit cuC = this. getCompilationUnit("JavaSearch", "src", "a10", "C.java");
2646
        ICompilationUnit cuE = this. getCompilationUnit("JavaSearch", "src", "a10", "E.java");
2648
        ICompilationUnit cuE = this. getCompilationUnit("JavaSearch", "src", "a10", "E.java");
2647
        IType type = cuC.getType("C");
2649
        IType type = cuC.getType("C");
2648
        IJavaSearchScope scope = SearchEngine.createHierarchyScope(null, type, true, true, null);
2650
        IJavaSearchScope scope = SearchEngine.createHierarchyScope(null, type, true, null);
2649
        
2651
        
2650
        // method of a member of a sub-type:
2652
        // method of a member of a sub-type:
2651
        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
        assertFalse("a10.F$G.m() should not be included in hierarchy scope", scope.encloses(cuE.getType("F").getType("G").getMethod("m", new String[0])));
Lines 2653-2664 Link Here
2653
/**
2655
/**
2654
 * Hierarchy scope test.
2656
 * Hierarchy scope test.
2655
 * (test for enhancement bug 215139 encloses(method): find only subtypes but also member types).
2657
 * (test for enhancement bug 215139 encloses(method): find only subtypes but also member types).
2658
 * Note: this combination of arguments is no longer supported after the change from bug 295894
2656
 */
2659
 */
2657
public void testSearchScope18() throws CoreException {
2660
public void _testSearchScope18() throws CoreException {
2658
    	ICompilationUnit cuC = this. getCompilationUnit("JavaSearch", "src", "a10", "C.java");
2661
    	ICompilationUnit cuC = this. getCompilationUnit("JavaSearch", "src", "a10", "C.java");
2659
        ICompilationUnit cuE = this. getCompilationUnit("JavaSearch", "src", "a10", "E.java");
2662
        ICompilationUnit cuE = this. getCompilationUnit("JavaSearch", "src", "a10", "E.java");
2660
        IType type = cuC.getType("C");
2663
        IType type = cuC.getType("C");
2661
        IJavaSearchScope scope = SearchEngine.createHierarchyScope(null, type, true, false, null);
2664
        IJavaSearchScope scope = SearchEngine.createHierarchyScope(null, type, true, null);
2662
        
2665
        
2663
        // method of a member of a sub-type:
2666
        // method of a member of a sub-type:
2664
        assertTrue("a10.F$G.m() should be included in hierarchy scope", scope.encloses(cuE.getType("F").getType("G").getMethod("m", new String[0])));
2667
        assertTrue("a10.F$G.m() should be included in hierarchy scope", scope.encloses(cuE.getType("F").getType("G").getMethod("m", new String[0])));
Lines 3426-3434 Link Here
3426
		}),
3429
		}),
3427
		this.resultCollector);
3430
		this.resultCollector);
3428
	assertSearchResults(
3431
	assertSearchResults(
3429
			"src/b5/A.java b5.A.{} [    �|Zork|�[] zork = new Zork[0];] POTENTIAL_MATCH\n" +
3432
			"src/b5/A.java b5.A.{} [    �|Zork|�[] zork = new Zork[0];] POTENTIAL_MATCH\n" +
3430
			"src/b5/A.java b5.A.{} [    Zork[] zork = new �|Zork|�[0];] POTENTIAL_MATCH\n" +
3433
			"src/b5/A.java b5.A.{} [    Zork[] zork = new �|Zork|�[0];] POTENTIAL_MATCH\n" +
3431
			"src/b5/A.java b5.A.{} [    int i = �|Zork|�.foo;] POTENTIAL_MATCH",
3434
			"src/b5/A.java b5.A.{} [    int i = �|Zork|�.foo;] POTENTIAL_MATCH",
3432
		this.resultCollector);
3435
		this.resultCollector);
3433
}
3436
}
3434
/**
3437
/**
Lines 3613-3619 Link Here
3613
		scope,
3616
		scope,
3614
		this.resultCollector);
3617
		this.resultCollector);
3615
	assertSearchResults(
3618
	assertSearchResults(
3616
		"src/f2/X.java Object f2.X.foo1() [		return new �|Y|�();]",
3619
		"src/f2/X.java Object f2.X.foo1() [		return new �|Y|�();]",
3617
		this.resultCollector);
3620
		this.resultCollector);
3618
}
3621
}
3619
/*
3622
/*
Lines 3633-3639 Link Here
3633
		scope,
3636
		scope,
3634
		this.resultCollector);
3637
		this.resultCollector);
3635
	assertSearchResults(
3638
	assertSearchResults(
3636
		"src/f2/X.java Object f2.X.foo1() [		return new �|Y|�();]",
3639
		"src/f2/X.java Object f2.X.foo1() [		return new �|Y|�();]",
3637
		this.resultCollector);
3640
		this.resultCollector);
3638
}
3641
}
3639
/**
3642
/**

Return to bug 295894