Open sandersn opened 1 month ago
Thanks for the sample project. I'm able to reproduce as well. Interestingly, if I don't open BadCall.java
as the first file (open DatabaseMock.java
first) and then open BadCall.java
afterwards , the incorrect code action is not offered. Do you see the same behaviour ?
Update: I think this aspect of the bug is related to the fact that we now discover static import favourites when a file is opened and the configuration updates, but simply opening a file doesn't update the configuration.
The other aspect of this issue is that we calculate static imports by simulating code completion with the unqualified method (eg. connect
) in a file that lacks the imports.
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
Steps To Reproduce
import static java.fixes.DatabaseMock.connect
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.