-
-
Notifications
You must be signed in to change notification settings - Fork 118
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
Plugin + Intellij optimize Import for static imports out of order #200
Comments
Hmm, spotless uses my old implementation for import sorting. Are you sure you configured it properly? What is your config for import order? |
My settings are. My spotless configuration points to my resource/myTeam.importOrder |
I am starting to remember that there is some kind of hack in sorting static imports.... I think this is not supported:
I don't even know what that is, is this some new language feature? Could you post the whole compilable code? This would work fine:
|
Here's what I wrote locally
Sorry I missed the imports including the top level class. It's suppose to be |
It is probably simplified too much, Eclipse converts it to this:
|
If I do this:
then Eclipse 2019-03 and 2019-12 sorts SomeZClass as first. |
Just to confirm the expected behavior is that we have
? |
Have you actually tried it in Eclipse?
|
Yes I just ran it in eclipse and see the behavior you mention. But the plugin for Intellij has a different behavior than what is in eclipse. And spotless has a third behavior. So is your goal to align with the behavior as much in eclipse? Personally I feel the ordering that spotless does is what I'd expect, but I can understand if you want 1-1 parity with eclipse and I can reach out to spotless' organization. |
where?
yes |
For clarity the three behaviors I observe from my given import above
Eclipse running "Organize Import" produces:
Eclipse Plugin for Intellij running "Optimize Import" produces:
Spotless plugin running "mvn spotless:apply" produces:
To further show that Eclipse Plugin behavior is not expected we can add
Eclipse Plugin will order imports:
Eclipse will order imports:
and spotless will order imports
So I expect the behavior of the Eclipse Plugin to respect alphabetical ordering for static imports, SomeZClass should be imported after SomeEnum. |
Ok, I see. The problem is that Intellij does not convert You could workaround it by fixing the import manually or not writing such code in the first place :) Not sure how you ended up with it, my IntelliJ makes Spotless is missing this fix: #105 so its order is wrong. |
Thank you for the response. I statically import SomeZcClass to avoid the FQN in the argument. The other option is if I manually format it like Eclipse than spotless and EclipseFormatter won't change it. I've filed an issue to Spotless as well to get #105. Is it possible to have the plugin change the contents or is there a limitation that makes this difficult? |
This plugin could change the imports in the same way IntelliJ does it, using PSI, that should be easy. |
Define this class,
Run optimize import in the IDE.
Intellij Version: 193.6015.39
Using Plugin with Eclipse Format: 4.5.1+
Note:
mvn spotless:apply
uses the expected behavior, and turning off the eclipse formatter plugin then Intellij will optimize the import with the expected behavior.The text was updated successfully, but these errors were encountered: