|
48 | 48 | import org.eclipse.jdt.core.search.SearchPattern; |
49 | 49 | import org.eclipse.jdt.core.search.TypeNameMatch; |
50 | 50 | import org.eclipse.jdt.core.search.TypeNameMatchRequestor; |
| 51 | +import org.eclipse.jdt.internal.corext.refactoring.structure.ASTNodeSearchUtil; |
51 | 52 | import org.eclipse.jdt.internal.junit.util.CoreTestSearchEngine; |
52 | 53 | import org.eclipse.jdt.ls.core.internal.JDTUtils; |
53 | 54 | import org.eclipse.jdt.ls.core.internal.JavaLanguageServerPlugin; |
@@ -271,12 +272,12 @@ public static List<JavaTestItem> findDirectTestChildrenForClass(List<Object> arg |
271 | 272 | continue; |
272 | 273 | } |
273 | 274 |
|
274 | | - final ASTNode node = root.findDeclaringNode(type.getKey()); |
275 | | - if (!(node instanceof TypeDeclaration)) { |
| 275 | + final TypeDeclaration typeDeclaration = ASTNodeSearchUtil.getTypeDeclarationNode(type, root); |
| 276 | + if (typeDeclaration == null) { |
276 | 277 | continue; |
277 | 278 | } |
278 | 279 |
|
279 | | - final ITypeBinding binding = ((TypeDeclaration) node).resolveBinding(); |
| 280 | + final ITypeBinding binding = typeDeclaration.resolveBinding(); |
280 | 281 | if (binding == null) { |
281 | 282 | continue; |
282 | 283 | } |
@@ -344,12 +345,12 @@ public static List<JavaTestItem> findTestTypesAndMethods(List<Object> arguments, |
344 | 345 | Collections.emptyList(); |
345 | 346 | } |
346 | 347 |
|
347 | | - final ASTNode node = root.findDeclaringNode(primaryType.getKey()); |
348 | | - if (!(node instanceof TypeDeclaration)) { |
| 348 | + final TypeDeclaration typeDeclaration = ASTNodeSearchUtil.getTypeDeclarationNode(primaryType, root); |
| 349 | + if (typeDeclaration == null) { |
349 | 350 | return Collections.emptyList(); |
350 | 351 | } |
351 | 352 |
|
352 | | - final ITypeBinding binding = ((TypeDeclaration) node).resolveBinding(); |
| 353 | + final ITypeBinding binding = typeDeclaration.resolveBinding(); |
353 | 354 | if (binding == null) { |
354 | 355 | return Collections.emptyList(); |
355 | 356 | } |
|
0 commit comments