You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
Reacted by Andranik Azizbekian, Brice Dutheil, jochenberger, venkateswaris and Dennis Neufeld
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 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.
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.
@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.
Activity
nedtwigg commentedon 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
#includesorter for C/C++. Dunno if there's a common infrastructure, but if anyone wants to contribute a fix, I would start there.nedtwigg commentedon Oct 5, 2018
Also looks like #305 can get lumped in to the ImportSorter mess :)
fvgh commentedon 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 commentedon 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 commentedon 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 commentedon Jan 15, 2020
This issue is still valid and needs to be resolved, because formatting file in IDE differs from spotless config.
nedtwigg commentedon Jan 15, 2020
Thanks for verifying. PR’s welcome!
aljoscha commentedon Dec 16, 2020
@azizbekian Did you see @teur's comment? I have this config in a project and it puts static imports at the bottom:
matshou commentedon Feb 4, 2021
Like @teur mentioned, adding
'\\#'to the end ofimportOrderarranges static imports to be placed last.nedtwigg commentedon Feb 4, 2021
Looks like this issue is solved. Thanks all!
NathanQingyangXu commentedon Nov 6, 2024
I tried many times, but seems the issue is still there.