diff --git a/CHANGELOG.md b/CHANGELOG.md index f0b5d3a8..2fb814a8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ### Changed - The `@Test` method will be selected by default when using `Generating Tests...` source action. [#1350](https://github.com/microsoft/vscode-java-test/issues/1350) +### Fixed +- [Bugs fixed](https://github.com/microsoft/vscode-java-test/issues?q=is%3Aissue+is%3Aclosed+label%3Abug+milestone%3A0.34.0) + ## 0.33.1 ### Fixed - Reduce the line spacing in test messages [PR#1345](https://github.com/microsoft/vscode-java-test/pull/1345) diff --git a/java-extension/com.microsoft.java.test.plugin/src/main/java/com/microsoft/java/test/plugin/util/TestSearchUtils.java b/java-extension/com.microsoft.java.test.plugin/src/main/java/com/microsoft/java/test/plugin/util/TestSearchUtils.java index 1bc18608..31586055 100644 --- a/java-extension/com.microsoft.java.test.plugin/src/main/java/com/microsoft/java/test/plugin/util/TestSearchUtils.java +++ b/java-extension/com.microsoft.java.test.plugin/src/main/java/com/microsoft/java/test/plugin/util/TestSearchUtils.java @@ -48,6 +48,7 @@ import org.eclipse.jdt.core.search.SearchPattern; import org.eclipse.jdt.core.search.TypeNameMatch; import org.eclipse.jdt.core.search.TypeNameMatchRequestor; +import org.eclipse.jdt.internal.corext.refactoring.structure.ASTNodeSearchUtil; import org.eclipse.jdt.internal.junit.util.CoreTestSearchEngine; import org.eclipse.jdt.ls.core.internal.JDTUtils; import org.eclipse.jdt.ls.core.internal.JavaLanguageServerPlugin; @@ -271,12 +272,12 @@ public static List findDirectTestChildrenForClass(List arg continue; } - final ASTNode node = root.findDeclaringNode(type.getKey()); - if (!(node instanceof TypeDeclaration)) { + final TypeDeclaration typeDeclaration = ASTNodeSearchUtil.getTypeDeclarationNode(type, root); + if (typeDeclaration == null) { continue; } - final ITypeBinding binding = ((TypeDeclaration) node).resolveBinding(); + final ITypeBinding binding = typeDeclaration.resolveBinding(); if (binding == null) { continue; } @@ -344,12 +345,12 @@ public static List findTestTypesAndMethods(List arguments, Collections.emptyList(); } - final ASTNode node = root.findDeclaringNode(primaryType.getKey()); - if (!(node instanceof TypeDeclaration)) { + final TypeDeclaration typeDeclaration = ASTNodeSearchUtil.getTypeDeclarationNode(primaryType, root); + if (typeDeclaration == null) { return Collections.emptyList(); } - final ITypeBinding binding = ((TypeDeclaration) node).resolveBinding(); + final ITypeBinding binding = typeDeclaration.resolveBinding(); if (binding == null) { return Collections.emptyList(); }