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
Default to preserving lambda line breaks (Kotlin#614)
Summary:
This is a continuation of Kotlin#574 with the updated option control to orient around the requested `--preserve-lambda-breaks` simple option. With this, lambda block line breaks are simply just respected rather than have ktfmt impose anything.
Aside from finishing up the previous PR, this also adds a setting to the IJ plugin.
I cherrypicked the original commits to preserve authorship history (CC loganj)
ResolvesKotlin#547
**Edit**
After chatting on slack I updated the PR with a couple things:
- Added a builder API for CLI tools to use in the future to avoid ABI breakages
- Flipped the semantics to enable this by default, but can revert if you want to keep the old setup. I do think enabled by default is good
Pull Request resolved: Kotlin#614
Reviewed By: ermattt
Differential Revision: D105690093
Pulled By: hick209
fbshipit-source-id: 8a2a3232329a796a8f777d7bf7ef96016651ef61
- Remove forced breaking of `context` function types (https://github.com/facebook/ktfmt/pull/613)
20
+
- Preserve user-authored line breaks inside lambda bodies by default, rather than have ktfmt impose anything. This can be particularly useful for DSL syntax like Compose UI or Kotlin Gradle script. The behavior follows the `FormattingOptions.preserveLambdaBreaks` setting of the chosen style. (https://github.com/facebook/ktfmt/pull/614)
21
+
- Add a `FormattingOptions.Builder` API for tools to avoid breaking ABI changes with new options. (https://github.com/facebook/ktfmt/pull/614)
Copy file name to clipboardExpand all lines: core/api/ktfmt.api
+21-3Lines changed: 21 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -122,9 +122,12 @@ public final class com/facebook/ktfmt/format/Formatter {
122
122
123
123
public final class com/facebook/ktfmt/format/FormattingOptions {
124
124
public static final field Companion Lcom/facebook/ktfmt/format/FormattingOptions$Companion;
125
+
public static final field DEFAULT_BLOCK_INDENT I
126
+
public static final field DEFAULT_CONTINUATION_INDENT I
125
127
public static final field DEFAULT_MAX_WIDTH I
126
128
public fun <init> (IIILcom/facebook/ktfmt/format/TrailingCommaManagementStrategy;ZZ)V
127
-
public synthetic fun <init> (IIILcom/facebook/ktfmt/format/TrailingCommaManagementStrategy;ZZILkotlin/jvm/internal/DefaultConstructorMarker;)V
129
+
public fun <init> (IIILcom/facebook/ktfmt/format/TrailingCommaManagementStrategy;ZZZ)V
130
+
public synthetic fun <init> (IIILcom/facebook/ktfmt/format/TrailingCommaManagementStrategy;ZZZILkotlin/jvm/internal/DefaultConstructorMarker;)V
128
131
public fun <init> (IIIZZZ)V
129
132
public synthetic fun <init> (IIIZZZILkotlin/jvm/internal/DefaultConstructorMarker;)V
130
133
public final fun component1 ()I
@@ -133,19 +136,34 @@ public final class com/facebook/ktfmt/format/FormattingOptions {
133
136
public final fun component4 ()Lcom/facebook/ktfmt/format/TrailingCommaManagementStrategy;
134
137
public final fun component5 ()Z
135
138
public final fun component6 ()Z
136
-
public final fun copy (IIILcom/facebook/ktfmt/format/TrailingCommaManagementStrategy;ZZ)Lcom/facebook/ktfmt/format/FormattingOptions;
137
-
public static synthetic fun copy$default (Lcom/facebook/ktfmt/format/FormattingOptions;IIILcom/facebook/ktfmt/format/TrailingCommaManagementStrategy;ZZILjava/lang/Object;)Lcom/facebook/ktfmt/format/FormattingOptions;
139
+
public final fun component7 ()Z
140
+
public final fun copy (IIILcom/facebook/ktfmt/format/TrailingCommaManagementStrategy;ZZZ)Lcom/facebook/ktfmt/format/FormattingOptions;
141
+
public static synthetic fun copy$default (Lcom/facebook/ktfmt/format/FormattingOptions;IIILcom/facebook/ktfmt/format/TrailingCommaManagementStrategy;ZZZILjava/lang/Object;)Lcom/facebook/ktfmt/format/FormattingOptions;
138
142
public fun equals (Ljava/lang/Object;)Z
139
143
public final fun getBlockIndent ()I
140
144
public final fun getContinuationIndent ()I
141
145
public final fun getDebuggingPrintOpsAfterFormatting ()Z
142
146
public final fun getMaxWidth ()I
147
+
public final fun getPreserveLambdaBreaks ()Z
143
148
public final fun getRemoveUnusedImports ()Z
144
149
public final fun getTrailingCommaManagementStrategy ()Lcom/facebook/ktfmt/format/TrailingCommaManagementStrategy;
145
150
public fun hashCode ()I
151
+
public final fun toBuilder ()Lcom/facebook/ktfmt/format/FormattingOptions$Builder;
146
152
public fun toString ()Ljava/lang/String;
147
153
}
148
154
155
+
public final class com/facebook/ktfmt/format/FormattingOptions$Builder {
156
+
public fun <init> ()V
157
+
public final fun blockIndent (I)Lcom/facebook/ktfmt/format/FormattingOptions$Builder;
158
+
public final fun build ()Lcom/facebook/ktfmt/format/FormattingOptions;
159
+
public final fun continuationIndent (I)Lcom/facebook/ktfmt/format/FormattingOptions$Builder;
160
+
public final fun debuggingPrintOpsAfterFormatting (Z)Lcom/facebook/ktfmt/format/FormattingOptions$Builder;
161
+
public final fun maxWidth (I)Lcom/facebook/ktfmt/format/FormattingOptions$Builder;
162
+
public final fun preserveLambdaBreaks (Z)Lcom/facebook/ktfmt/format/FormattingOptions$Builder;
163
+
public final fun removeUnusedImports (Z)Lcom/facebook/ktfmt/format/FormattingOptions$Builder;
164
+
public final fun trailingCommaManagementStrategy (Lcom/facebook/ktfmt/format/TrailingCommaManagementStrategy;)Lcom/facebook/ktfmt/format/FormattingOptions$Builder;
165
+
}
166
+
149
167
public final class com/facebook/ktfmt/format/FormattingOptions$Companion {
0 commit comments