Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Organize imports generates static import statement, even if already imported #2012

Closed
fvclaus opened this issue Jul 5, 2021 · 0 comments · Fixed by eclipse-jdtls/eclipse.jdt.ls#1814
Assignees

Comments

@fvclaus
Copy link
Contributor

fvclaus commented Jul 5, 2021

Organize imports always generates a static import statement, if the current static import is not part of java.completion.favoriteStaticMembers.

settings.json

  "java.completion.favoriteStaticMembers": [
      "org.assertj.core.api.Assertions.*"
    ],

import_java

Environment
  • Operating System: Ubuntu 18.04.5 LTS (Bionic Beaver)
  • JDK version: 11.0.6.hs-adpt
  • Visual Studio Code version: 1.57.1
  • Java extension version: 0.80.0
Steps To Reproduce
  1. Configure static imports as explained above
  2. Checkout https://github.com/fvclaus/vscode-java-import-bug. Import project. Open AppTest.java. Execute Organize Imports

Developer console contained no error messages.
Java log file contained the following:


!ENTRY org.eclipse.jdt.ls.core 1 0 2021-07-05 17:33:48.321
!MESSAGE >> document/codeAction

!ENTRY org.eclipse.jdt.ls.core 1 0 2021-07-05 17:33:48.324
!MESSAGE >> document/documentSymbol

!ENTRY org.eclipse.jdt.ls.core 1 0 2021-07-05 17:33:48.345
!MESSAGE >> workspace/executeCommand java.project.provideSemanticTokens

!ENTRY org.eclipse.jdt.ls.core 1 0 2021-07-05 17:33:48.504
!MESSAGE Reconciled 1. Took 3 ms

!ENTRY org.eclipse.jdt.ls.core 1 0 2021-07-05 17:33:48.988
!MESSAGE begin problem for /AppTest.java

!ENTRY org.eclipse.jdt.ls.core 1 0 2021-07-05 17:33:48.988
!MESSAGE 1 problems reported for /AppTest.java

!ENTRY org.eclipse.jdt.ls.core 1 0 2021-07-05 17:33:48.989
!MESSAGE Validated 1. Took 83 ms
Current Result

Organize imports always generates a static import statement, even if the symbol is already imported.

Expected Result

Organize import will not generate static imports for symbols that are already imported.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants