diff options
author | Beth Cutler <bcutler@google.com> | 2022-04-13 08:17:20 -0700 |
---|---|---|
committer | Facebook GitHub Bot <facebook-github-bot@users.noreply.github.com> | 2022-04-13 08:17:20 -0700 |
commit | 1bebf0bc4677832a2b7004acf42a938baecd565a (patch) | |
tree | e27cc2ea9d6bb1365b1e18b5747047041a98ed1e /core/src/main/java/com/facebook | |
parent | d8bdf97ee409652671e22bb76dc7861c777792c2 (diff) | |
download | ktfmt-1bebf0bc4677832a2b7004acf42a938baecd565a.tar.gz |
Add trailing break before brace for Google Style (#308)
Summary:
Fix for https://github.com/facebookincubator/ktfmt/issues/245
Pull Request resolved: https://github.com/facebookincubator/ktfmt/pull/308
Reviewed By: cgrushko
Differential Revision: D35506462
Pulled By: strulovich
fbshipit-source-id: 5419130214152e6e083919935e5ae3be0cb47492
Diffstat (limited to 'core/src/main/java/com/facebook')
-rw-r--r-- | core/src/main/java/com/facebook/ktfmt/format/KotlinInputAstVisitor.kt | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/core/src/main/java/com/facebook/ktfmt/format/KotlinInputAstVisitor.kt b/core/src/main/java/com/facebook/ktfmt/format/KotlinInputAstVisitor.kt index b818145..c4633f2 100644 --- a/core/src/main/java/com/facebook/ktfmt/format/KotlinInputAstVisitor.kt +++ b/core/src/main/java/com/facebook/ktfmt/format/KotlinInputAstVisitor.kt @@ -907,7 +907,9 @@ class KotlinInputAstVisitor( return } - forEachCommaSeparated(list, hasTrailingComma, wrapInBlock) { visit(it) } + forEachCommaSeparated(list, hasTrailingComma, wrapInBlock, trailingBreak = isGoogleStyle) { + visit(it) + } if (hasTrailingComma) { builder.breakOp(Doc.FillMode.UNIFIED, "", expressionBreakNegativeIndent) } @@ -944,6 +946,7 @@ class KotlinInputAstVisitor( list: Iterable<T>, hasTrailingComma: Boolean = false, wrapInBlock: Boolean = true, + trailingBreak: Boolean = false, function: (T) -> Unit ) { if (hasTrailingComma) { @@ -971,6 +974,9 @@ class KotlinInputAstVisitor( function(value) } } + if (trailingBreak) { + builder.breakOp(Doc.FillMode.UNIFIED, "", expressionBreakNegativeIndent) + } } /** Example `a` in `foo(a)`, or `*a`, or `limit = 50` */ |