palantir-java-format icon indicating copy to clipboard operation
palantir-java-format copied to clipboard

[IntelliJ] Add note on Imports

Open koppor opened this issue 1 year ago • 5 comments

What happened?

I have activated palantir java format:

image

This does not change the code style configured in the IDE:

image

When executing "optimize imports", the configured style is followed.

  • [ ] I think, the plugin needs to change the code style to "Default" or - even better - to "palantir" in the IDE settings, to be really transparent, about the import statements

What did you want to happen?

When executing "optimize imports", the palantir-style is followed


General wishes:

  • [ ] Write down in README.md about the style rules for imports. Maybe a link to the Google Java Style (https://google.github.io/styleguide/javaguide.html#s3.3-import-statements) would be enough?
  • [ ] Advanced: Supply checkstyle rules to check for palantir's import rules (so that one can use the rules in the CI to check)

koppor avatar Nov 17 '23 07:11 koppor

I'm experiencing similar issues...

I'm curious whether the IntelliJ IDEA plugin could additionally optimize imports while reformatting code now?

jrchen-amzn avatar Jan 26 '24 01:01 jrchen-amzn

Any updates on this? Would be nice to not only format the code, but imports too, if IDEA supports this itself

okuzan avatar Feb 05 '24 20:02 okuzan

This is a nasty one. We turned off Intellij's "auto optimize imports" on-the-fly / on save.

Seems like Intellij is going above and beyond the call of duty and trying to reformat on optimize imports: https://youtrack.jetbrains.com/issue/IDEA-353203/Intellij-optimize-imports-action-changes-formatting-of-text-blocks

yotamshtosselfg avatar May 13 '24 20:05 yotamshtosselfg

We turned off Intellij's "auto optimize imports" on-the-fly / on save.

This is not helping me; first palantir reformats, then the imports are re-ordered, and spotless complains that the formatting is not correct.

mindhaq avatar Jul 13 '24 07:07 mindhaq

This is not helping me; first palantir reformats, then the imports are re-ordered, and spotless complains that the formatting is not correct.

I don't get the comment. On https://github.com/palantir/palantir-java-format/issues/954#issuecomment-2108761245 it is said that "Optimize imports" is off. At your side, it is off, too, but there is still a change by IntelliJ?

@mindhaq Could you double check our "Optimize imports" setting?

image

koppor avatar Jul 13 '24 07:07 koppor