redhat-developer / redhat-developer/vscode-java

Static import quick fix offered on unrelated error

Open
#3,656 1 comment 0 reactions 1 assignee View on GitHub

@rgrunber is already working on this.

Since Jun 7, 2024.

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

Description

A quick fix offerering to static import a static method is offered even when the method is already static imported. This happens when the method is called with incorrect arguments.
 

Environment
  • Operating System: Ubuntu 22.04
  • JDK version: whatever installs by default when installing Extension Pack for Java
  • Visual Studio Code version: 1.90.0-insiders
  • Java extension version: Published 2024-05-18, 01:26:55 (installed 2024-05-20, 08:24:11)
Steps To Reproduce
  1. Create a class with a static method, eg DatabaseMock.connect
  2. import static java.fixes.DatabaseMock.connect
  3. Call connect incorrectly.

https://github.com/sandersn/ai-fix-examples/tree/main/java/fixes

I haven't used Java in almost 20 years, I was just experimenting with AI quick fixes in different languages. It's possible that my scrabbled-together project in the linked repo is required for the error to show up.

Expected Result

Only "Create method ..." fix should be offered.

Current Result

In addition, "Add static import for ..." fix is offered.

Additional Information

Clicking on the fix does nothing. The method is already static imported.

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.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.