redhat-developer / redhat-developer/vscode-java

Code action for static import doesn't work well in a specific case

Open
#3,835 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
TypeScript
Stars
2.3k
Forks
546
Avg merge
20h 1m
Merged PRs (30d)
11

Description

Environment
  • Operating System: Windows
  • JDK version: 17.0.8
  • Visual Studio Code version: 1.95.0
  • Java extension version: 1.36.0
Steps To Reproduce
  1. Open https://github.com/junit-team/junit5-samples/tree/master/junit5-migration-maven
  2. Open FirstTest.java file
  3. Comment out import static org.junit.jupiter.api.Assertions.assertEquals;
  4. Add import static org.junit.Assert.*;
  5. Click quick fix before assertEquals
Current Result
  • It shouldn't show the option Add static import for 'Assert.assertEquals' as it has been included in import static org.junit.Assert.*;. And this option doesn't work if clicking it.
  • Without import static org.junit.Assert.*;, code action Add static import for 'Assert.assertEquals works only at first time. After first clicking, it still shows this option even the import has been added.

image

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the quick-fix behavior in FirstTest.java from the junit5-migration-maven sample, using the listed VS Code and Java extension versions if available. Compare the suggestions after adding import static org.junit.Assert.*; and after applying the static-import action once. Done means the action is not offered when the wildcard import already covers assertEquals and no longer remains after the import is added.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, typescript, vscode
Domain
developer-experience, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.