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

Control static import placement #306

Closed
mkordas opened this issue Oct 3, 2018 · 10 comments
Closed

Control static import placement #306

mkordas opened this issue Oct 3, 2018 · 10 comments

Comments

@mkordas
Copy link

mkordas commented Oct 3, 2018

Is there a way to configure Spotless so that static imports in Java/Groovy are put below normal imports? That's IntelliJ default...
I cannot find anything about it in docs, but I think the behavior should be documented and configurable.

@nedtwigg
Copy link
Member

nedtwigg commented Oct 5, 2018

There is not, but that would be a great feature to have! Our import sorter has a few hairy bits.

#167 (minor bug that explains the background of import sorter, and how to do what you want to do)
#174 (really minor bug)

Possibly related, #232 is about incorporating the eclipse #include sorter for C/C++. Dunno if there's a common infrastructure, but if anyone wants to contribute a fix, I would start there.

@nedtwigg
Copy link
Member

nedtwigg commented Oct 5, 2018

Also looks like #305 can get lumped in to the ImportSorter mess :)

@fvgh
Copy link
Member

fvgh commented Oct 5, 2018

@nedtwigg I don't think that the import sorter is really suitable for C++. CDT provide a nice article about their rules. Gives a good reasoning why the topic in C++ is complex. As stated in #232, my aim is to get the CDT implementation in and provide it as an optional step.

@teur
Copy link

teur commented Mar 10, 2019

There are examples of configuration static imports in ImportOrderStepTest by using \#.
For example a configuration importOrder 'java', '\\#java', 'javax', '\\#javax', '', '\\#' may be used to put static imports below.

@fvgh
Copy link
Member

fvgh commented Mar 30, 2019

@nedtwigg I had another go on the IncludeOrganizer as it is provided by CDT. Unfortunately it is not an option as I described in my comment for #232. So maybe there can be a common code base for the Java/C++ import/include order.

@azizbekian
Copy link

This issue is still valid and needs to be resolved, because formatting file in IDE differs from spotless config.

@nedtwigg
Copy link
Member

Thanks for verifying. PR’s welcome!

@aljoscha
Copy link

@azizbekian Did you see @teur's comment? I have this config in a project and it puts static imports at the bottom:

<order>org.apache.flink,org.apache.flink.shaded,javax,java,scala,\#</order>

@matshou
Copy link

matshou commented Feb 4, 2021

Like @teur mentioned, adding '\\#' to the end of importOrder arranges static imports to be placed last.

@nedtwigg
Copy link
Member

nedtwigg commented Feb 4, 2021

Looks like this issue is solved. Thanks all!

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

No branches or pull requests

7 participants