Lines 11137-11142
Link Here
|
11137 |
} |
11137 |
} |
11138 |
|
11138 |
|
11139 |
/** |
11139 |
/** |
|
|
11140 |
* @bug 295894: Search shows focus type implementation for nested types even though the scope is restricted to subtypes. |
11141 |
* @test explicitly including the focus type, which has no subtypes. |
11142 |
* @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=295894" |
11143 |
*/ |
11144 |
public void testBug295894c() throws Exception { |
11145 |
this.workingCopies = new ICompilationUnit[1]; |
11146 |
this.workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/A.java", |
11147 |
"public class A {\n" + |
11148 |
" void test() {\n" + |
11149 |
" A a= new A();\n" + |
11150 |
" a.toString();\n" + |
11151 |
" }\n" + |
11152 |
" @Override\n" + |
11153 |
" public String toString() {\n" + |
11154 |
" return \"\";\n" + |
11155 |
" }\n" + |
11156 |
"}\n" + |
11157 |
"" |
11158 |
); |
11159 |
search( |
11160 |
"toString", |
11161 |
METHOD, |
11162 |
DECLARATIONS, |
11163 |
SearchEngine.createStrictHierarchyScope(null, this.workingCopies[0].findPrimaryType(), true, true, null), |
11164 |
this.resultCollector); |
11165 |
assertSearchResults( |
11166 |
"src/A.java String A.toString() [toString] EXACT_MATCH" |
11167 |
); |
11168 |
} |
11169 |
//Failing test while working with a compilation unit instead of working copy |
11170 |
public void testBug295894c2() throws Exception { |
11171 |
try { |
11172 |
createJavaProject("P"); |
11173 |
createFile( |
11174 |
"/P/A.java", |
11175 |
"public class A {\n" + |
11176 |
" void test() {\n" + |
11177 |
" A a= new A();\n" + |
11178 |
" a.toString();\n" + |
11179 |
" }\n" + |
11180 |
" @Override\n" + |
11181 |
" public String toString() {\n" + |
11182 |
" return \"\";\n" + |
11183 |
" }\n" + |
11184 |
"}\n" |
11185 |
); |
11186 |
final ICompilationUnit cu = getCompilationUnit("/P/A.java"); |
11187 |
IMethod method = selectMethod(cu, "toString"); |
11188 |
search(method, |
11189 |
DECLARATIONS|IGNORE_RETURN_TYPE, |
11190 |
SearchEngine.createStrictHierarchyScope(null, cu.findPrimaryType(), true, true, null), |
11191 |
this.resultCollector); |
11192 |
assertSearchResults( |
11193 |
"A.java String A.toString() [toString] EXACT_MATCH" |
11194 |
); |
11195 |
} |
11196 |
finally { |
11197 |
deleteProject("P"); |
11198 |
} |
11199 |
} |
11200 |
// Similar test passing when the focus type has a subclass |
11201 |
public void testBug295894c3() throws Exception { |
11202 |
try { |
11203 |
createJavaProject("P"); |
11204 |
createFile( |
11205 |
"/P/A.java", |
11206 |
"public class A {\n" + |
11207 |
" void test() {\n" + |
11208 |
" A a= new A();\n" + |
11209 |
" a.toString();\n" + |
11210 |
" }\n" + |
11211 |
" @Override\n" + |
11212 |
" public String toString() {\n" + |
11213 |
" return \"\";\n" + |
11214 |
" }\n" + |
11215 |
"}\n" + |
11216 |
"class B extends A {\n" + |
11217 |
"}\n" |
11218 |
); |
11219 |
final ICompilationUnit cu = getCompilationUnit("/P/A.java"); |
11220 |
IMethod method = selectMethod(cu, "toString"); |
11221 |
search(method, |
11222 |
DECLARATIONS|IGNORE_RETURN_TYPE, |
11223 |
SearchEngine.createStrictHierarchyScope(null, cu.findPrimaryType(), true, true, null), |
11224 |
this.resultCollector); |
11225 |
assertSearchResults( |
11226 |
"A.java String A.toString() [toString] EXACT_MATCH" |
11227 |
); |
11228 |
} |
11229 |
finally { |
11230 |
deleteProject("P"); |
11231 |
} |
11232 |
} |
11233 |
// similar test using older API in SearchEngine: |
11234 |
public void testBug295894c4() throws Exception { |
11235 |
try { |
11236 |
createJavaProject("P"); |
11237 |
createFile( |
11238 |
"/P/A.java", |
11239 |
"public class A {\n" + |
11240 |
" void test() {\n" + |
11241 |
" A a= new A();\n" + |
11242 |
" a.toString();\n" + |
11243 |
" }\n" + |
11244 |
" @Override\n" + |
11245 |
" public String toString() {\n" + |
11246 |
" return \"\";\n" + |
11247 |
" }\n" + |
11248 |
"}\n" |
11249 |
); |
11250 |
final ICompilationUnit cu = getCompilationUnit("/P/A.java"); |
11251 |
IMethod method = selectMethod(cu, "toString"); |
11252 |
search(method, |
11253 |
DECLARATIONS|IGNORE_RETURN_TYPE, |
11254 |
SearchEngine.createHierarchyScope(cu.findPrimaryType(), null), |
11255 |
this.resultCollector); |
11256 |
assertSearchResults( |
11257 |
"A.java String A.toString() [toString] EXACT_MATCH" |
11258 |
); |
11259 |
} |
11260 |
finally { |
11261 |
deleteProject("P"); |
11262 |
} |
11263 |
} |
11264 |
//Similar test to testBug295894c3 but using separate files for types |
11265 |
public void testBug295894c5() throws Exception { |
11266 |
try { |
11267 |
createJavaProject("P"); |
11268 |
createFile( |
11269 |
"/P/A.java", |
11270 |
"public class A {\n" + |
11271 |
" void test() {\n" + |
11272 |
" A a= new A();\n" + |
11273 |
" a.toString();\n" + |
11274 |
" }\n" + |
11275 |
" @Override\n" + |
11276 |
" public String toString() {\n" + |
11277 |
" return \"\";\n" + |
11278 |
" }\n" + |
11279 |
"}" |
11280 |
); |
11281 |
createFile( |
11282 |
"/P/B.java", |
11283 |
"class B extends A {\n" + |
11284 |
"}\n" |
11285 |
); |
11286 |
final ICompilationUnit cu = getCompilationUnit("/P/A.java"); |
11287 |
IMethod method = selectMethod(cu, "toString"); |
11288 |
search(method, |
11289 |
DECLARATIONS|IGNORE_RETURN_TYPE, |
11290 |
SearchEngine.createStrictHierarchyScope(null, cu.findPrimaryType(), true, true, null), |
11291 |
this.resultCollector); |
11292 |
assertSearchResults( |
11293 |
"A.java String A.toString() [toString] EXACT_MATCH" |
11294 |
); |
11295 |
} |
11296 |
finally { |
11297 |
deleteProject("P"); |
11298 |
} |
11299 |
} |
11300 |
/** |
11140 |
* @bug 288174: NullPointerException when searching for type references |
11301 |
* @bug 288174: NullPointerException when searching for type references |
11141 |
* @test Ensure that no NPE occurs when searching for type references |
11302 |
* @test Ensure that no NPE occurs when searching for type references |
11142 |
* when a binary type has matches in several member or anonymous types |
11303 |
* when a binary type has matches in several member or anonymous types |