Skip to content

Commit

Permalink
fix: Should recognize test classes with '$' in their names (#1366)
Browse files Browse the repository at this point in the history
Signed-off-by: sheche <[email protected]>
  • Loading branch information
jdneo authored Jan 25, 2022
1 parent 41e71f6 commit 49ea8ec
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -271,12 +272,12 @@ public static List<JavaTestItem> findDirectTestChildrenForClass(List<Object> 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;
}
Expand Down Expand Up @@ -344,12 +345,12 @@ public static List<JavaTestItem> findTestTypesAndMethods(List<Object> 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();
}
Expand Down

0 comments on commit 49ea8ec

Please sign in to comment.