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
| type | const | A constant: `specs.openrewrite.org/v1beta/style`|
46
46
| name | string | A fully qualified, unique name for this style |
47
47
| displayName | string | A human-readable name for this style (does not end with a period) |
@@ -66,6 +66,83 @@ styleConfigs:
66
66
67
67
To see how you would use this style in your project, please jump to [using styles](#using-styles).
68
68
69
+
#### Style configs
70
+
71
+
The `styleConfigs` array is where you define the specific formatting rules for your style. Each entry references a style config class and its configuration options.
72
+
73
+
You can find all available Java style configs in the [rewrite-java style package](https://github.com/openrewrite/rewrite/tree/main/rewrite-java/src/main/java/org/openrewrite/java/style). Some of the most commonly used ones include:
| `WrappingAndBracesStyle` | Line wrapping and brace placement |
82
+
83
+
When creating your own style, you can combine multiple style configs to fully define your formatting preferences. If you don't configure a particular style config, OpenRewrite will do its best to detect the settings from your existing code.
84
+
85
+
#### ImportLayoutStyle
86
+
87
+
Let's take a look at one of the more complicated style configs: `ImportLayoutStyle`. This style config controls how imports are grouped, ordered, and when star imports should be used. You can adjust the following properties on it:
| `classCountToUseStarImport` | int | 5 | How many imports from the same package must be present before collapsing into a star import |
92
+
| `nameCountToUseStarImport` | int | 3 | How many static imports from the same type must be present before collapsing into a static star import |
93
+
| `layout` | array of strings | [IntelliJ default](https://github.com/openrewrite/rewrite/blob/main/rewrite-java/src/main/java/org/openrewrite/java/style/IntelliJ.java#L62-L71) | An ordered list defining how imports should be grouped and ordered |
94
+
| `packagesToFold` | array of strings | empty | Packages that should always use star imports when 1 or more types are in use |
95
+
96
+
**Layout syntax**
97
+
98
+
The `layout` property in `ImportLayoutStyle` accepts an array of strings that define import groupings. Each string must use one of the following formats:
0 commit comments