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

Collapse All | Expand All

(-)src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java (-1 / +94 lines)
Lines 11135-11141 Link Here
11135
		"src/Test.java void Test$Sub.foo() [foo] EXACT_MATCH"
11135
		"src/Test.java void Test$Sub.foo() [foo] EXACT_MATCH"
11136
	);
11136
	);
11137
}
11137
}
11138
11138
/**
11139
 * @bug 295894: Search shows focus type implementation for nested types even though the scope is restricted to subtypes.
11140
 * @test explicitly including the focus type, which has no subtypes.
11141
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=295894"
11142
 */
11143
public void testBug295894c() throws Exception {
11144
	this.workingCopies = new ICompilationUnit[1];
11145
	this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/A.java",
11146
		"public class A {\n" + 
11147
		"    void test() {\n" + 
11148
		"        A a= new A();\n" + 
11149
		"        a.toString();\n" + 
11150
		"    }\n" + 
11151
		"    @Override\n" +
11152
		"    public String toString() {\n" +
11153
		"        return \"\";\n" + 
11154
		"    }\n" + 
11155
		"}\n" + 
11156
		""
11157
	);
11158
	search(
11159
		"toString",
11160
		METHOD,
11161
		DECLARATIONS,
11162
		SearchEngine.createStrictHierarchyScope(null, this.workingCopies[0].findPrimaryType(), true, true, null),
11163
		this.resultCollector);
11164
	assertSearchResults(
11165
		"src/A.java String A.toString() [toString] EXACT_MATCH"
11166
	);
11167
}
11168
// Failing test while working with a compilation unit instead of working copy
11169
public void testBug295894c2() throws Exception {
11170
	try {
11171
		createJavaProject("P");
11172
		createFile(
11173
			"/P/A.java",
11174
			"public class A {\n" + 
11175
			"    void test() {\n" + 
11176
			"        A a= new A();\n" + 
11177
			"        a.toString();\n" + 
11178
			"    }\n" + 
11179
			"    @Override\n" +
11180
			"    public String toString() {\n" +
11181
			"        return \"\";\n" + 
11182
			"    }\n" + 
11183
			"}\n"
11184
		);
11185
		final ICompilationUnit cu = getCompilationUnit("/P/A.java");
11186
		IMethod method = selectMethod(cu, "toString");
11187
		search(method,
11188
			DECLARATIONS|IGNORE_RETURN_TYPE,
11189
			SearchEngine.createStrictHierarchyScope(null, cu.findPrimaryType(), true, true, null),
11190
			this.resultCollector);
11191
		assertSearchResults(
11192
			"A.java String A.toString() [toString] EXACT_MATCH"
11193
		);
11194
	}
11195
	finally {
11196
		deleteProject("P");
11197
	}
11198
}
11199
// Similar test passing when the focus type has a subclass
11200
public void testBug295894c3() throws Exception {
11201
	try {
11202
		createJavaProject("P");
11203
		createFile(
11204
			"/P/A.java",
11205
			"public class A {\n" + 
11206
			"    void test() {\n" + 
11207
			"        A a= new A();\n" + 
11208
			"        a.toString();\n" + 
11209
			"    }\n" + 
11210
			"    @Override\n" +
11211
			"    public String toString() {\n" +
11212
			"        return \"\";\n" + 
11213
			"    }\n" + 
11214
			"}\n" + 
11215
			"class B extends A {\n" + 
11216
			"}\n"
11217
		);
11218
		final ICompilationUnit cu = getCompilationUnit("/P/A.java");
11219
		IMethod method = selectMethod(cu, "toString");
11220
		search(method,
11221
			DECLARATIONS|IGNORE_RETURN_TYPE,
11222
			SearchEngine.createStrictHierarchyScope(null, cu.findPrimaryType(), true, true, null),
11223
			this.resultCollector);
11224
		assertSearchResults(
11225
			"A.java String A.toString() [toString] EXACT_MATCH"
11226
		);
11227
	}
11228
	finally {
11229
		deleteProject("P");
11230
	}
11231
}
11139
/**
11232
/**
11140
 * @bug 288174: NullPointerException when searching for type references
11233
 * @bug 288174: NullPointerException when searching for type references
11141
 * @test Ensure that no NPE occurs when searching for type references
11234
 * @test Ensure that no NPE occurs when searching for type references

Return to bug 295894