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

Static imports order #711

Closed
fbn-roussel opened this issue Nov 9, 2018 · 4 comments · Fixed by #2685
Closed

Static imports order #711

fbn-roussel opened this issue Nov 9, 2018 · 4 comments · Fixed by #2685

Comments

@fbn-roussel
Copy link

The organize imports feature puts the static imports at the beginning of the imports block (just after package).
It would be nice to have an option that gives you the choice to put it either at the beginning or at the end.

Environment
  • Operating System: Fedora 29
  • JDK version: 1.8.0_191
  • Visual Studio Code version: 1.28.2
  • Java extension version: 0.33.0
Steps To Reproduce
  1. Add some static imports before the class definition
  2. Fire organize imports
@fbricon
Copy link
Collaborator

fbricon commented Nov 9, 2018

Hey Fabien, long time no see :-)

If JDT has the option, then we can expose it.

@fbricon
Copy link
Collaborator

fbricon commented Nov 14, 2018

Matching issue in upstream JDT: https://bugs.eclipse.org/bugs/show_bug.cgi?id=304415

It's been opened since 2010. Fixing it in vscode-java requires fixing it upstream 1st. Probably not gonna happen anytime soon, unless people massively vote for that feature.

@kusnier
Copy link

kusnier commented Mar 3, 2020

Hi, I have configured my vscode with working ordering of static imports.

    "java.completion.importOrder": [
        "",
        "java",
        "javax",
        "org",
        "com",
        "de.mycompany",
        "#",
        "#de.mycompany"
    ],

All unknown imports will be added first. Then java, javax, org, and com.
After that, I see all my import from my company.

As of last I want to have static imports. The most important imports are again from my company so I will have them as last. (You have to use # for the ordering of the static imports.)

@rgrunber
Copy link
Member

Nice discovery here! Yes, according to https://github.com/eclipse-jdt/eclipse.jdt.ui/blob/cb1093315376859558a838c6934880f87921d816/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/ImportOrganizeConfigurationBlock.java#L96 , static imports are prepended by a #. I think this is definitely something we should mention in the settings description.

rgrunber added a commit to rgrunber/vscode-java that referenced this issue Sep 20, 2022
- Fixes redhat-developer#711

Signed-off-by: Roland Grunberg <rgrunber@redhat.com>
rgrunber added a commit to rgrunber/vscode-java that referenced this issue Sep 21, 2022
- Fixes redhat-developer#711
- Add 'io' to java.completion.importOrder
- Make the default of "" & "#" explicit (change is no-op) so the
  behaviour is understood

Signed-off-by: Roland Grunberg <rgrunber@redhat.com>
rgrunber added a commit to rgrunber/vscode-java that referenced this issue Sep 22, 2022
- Fixes redhat-developer#711
- Make the default of "" & "#" explicit (change is no-op) so the
  behaviour is understood

Signed-off-by: Roland Grunberg <rgrunber@redhat.com>
rgrunber added a commit that referenced this issue Sep 22, 2022
- Fixes #711
- Make the default of "" & "#" explicit (change is no-op) so the
  behaviour is understood

Signed-off-by: Roland Grunberg <rgrunber@redhat.com>
@rgrunber rgrunber added this to the End September milestone Sep 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants