-
Notifications
You must be signed in to change notification settings - Fork 460
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
Support for group of imports without blank lines between groups #1401
Support for group of imports without blank lines between groups #1401
Conversation
To keep compatibility with existing configuration, a special delimiter `|` is introduced to separate subgroup of imports inside a group. For example "java|javax" will not generate a blank line between the java group and the javax group. The notion of ImportsGroup has been introduced for clarification, allowing code has been simplification. Fixes diffplug#1375
f4ebaad
to
35a56ea
Compare
private final List<String> subGroups; | ||
|
||
public ImportsGroup(String importOrder) { | ||
this.subGroups = Stream.of(importOrder.split("\\" + SUBGROUP_SEPARATOR)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line has a bug that only |\\#
can be split as { "", "\\#" }
, but \\#|
will be split as { "\\#" }
so configure static
subgroup before catch all subgroup is impossible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this.subGroups = Stream.of(importOrder.split("\\" + SUBGROUP_SEPARATOR)) | |
this.subGroups = Stream.of(importOrder.split("\\" + SUBGROUP_SEPARATOR, -1)) |
... can help.
Published in |
…1.0 (mulk/mulkcms2!12) This MR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [com.diffplug.spotless:spotless-maven-plugin](https://github.com/diffplug/spotless) | build | minor | `2.30.0` -> `2.31.0` | --- ### Release Notes <details> <summary>diffplug/spotless</summary> ### [`v2.31.0`](https://github.com/diffplug/spotless/blob/HEAD/CHANGES.md#​2310---2022-11-24) ##### Added - `importOrder` now support groups of imports without blank lines ([#​1401](diffplug/spotless#1401)) ##### Fixed - Don't treat `@Value` as a type annotation [#​1367](diffplug/spotless#1367) - Support `ktlint_disabled_rules` in `ktlint` 0.47.x [#​1378](diffplug/spotless#1378) - Share git repositories across projects when using ratchet ([#​1426](diffplug/spotless#1426)) ##### Changes - Bump default `ktfmt` version to latest `0.40` -> `0.41` ([#​1340](diffplug/spotless#1340)) - Bump default `scalafmt` version to latest `3.5.9` -> `3.6.1` ([#​1373](diffplug/spotless#1373)) - Bump default `diktat` version to latest `1.2.3` -> `1.2.4.2` ([#​1393](diffplug/spotless#1393)) - Bump default `palantir-java-format` version to latest `2.10` -> `2.28` ([#​1393](diffplug/spotless#1393)) </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever MR is behind base branch, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this MR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box --- This MR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNC4yNC4wIiwidXBkYXRlZEluVmVyIjoiMzQuMjQuMCJ9-->
To keep compatibility with existing configuration, a special delimiter
|
is introduced to separate subgroup of imports inside a group. For example "java|javax" will not generate a blank line between the java group and the javax group.The notion of ImportsGroup has been introduced for clarification, allowing a significant code simplification.
Fixes #1375
Example of usage: defining order as
java|javax,org,com
will reorder imports as follow:Before:
After: