Skip to content

Commit

Permalink
Inline options.manageTrailingCommas
Browse files Browse the repository at this point in the history
Summary: `isGoogleStyle` was introduced a while ago, before we had trailing commas support. Now that trailing support is around we don't need to call this `isGoogleStyle`. Instead of renaming it though, I decided to inline it.

Reviewed By: cortinico

Differential Revision: D58395568

fbshipit-source-id: 510044b5212a8d0d4ce2129f27b876e5cfedc887
  • Loading branch information
Nivaldo Bondança authored and facebook-github-bot committed Jun 11, 2024
1 parent 7edeff1 commit 88c4961
Showing 1 changed file with 7 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,6 @@ class KotlinInputAstVisitor(
private val builder: OpsBuilder
) : KtTreeVisitorVoid() {

private val isGoogleStyle = options.manageTrailingCommas

/** Standard indentation for a block */
private val blockIndent: Indent.Const = Indent.Const.make(options.blockIndent, 1)

Expand Down Expand Up @@ -257,7 +255,7 @@ class KotlinInputAstVisitor(
visitEachCommaSeparated(
typeArgumentList.arguments,
typeArgumentList.trailingComma != null,
wrapInBlock = !isGoogleStyle,
wrapInBlock = !options.manageTrailingCommas,
prefix = "<",
postfix = ">",
)
Expand Down Expand Up @@ -817,8 +815,8 @@ class KotlinInputAstVisitor(
leadingBreak = !hasEmptyParens && hasTrailingComma
breakAfterPrefix = false
} else {
wrapInBlock = !isGoogleStyle
breakBeforePostfix = isGoogleStyle && !hasEmptyParens
wrapInBlock = !options.manageTrailingCommas
breakBeforePostfix = options.manageTrailingCommas && !hasEmptyParens
leadingBreak = !hasEmptyParens
breakAfterPrefix = !hasEmptyParens
}
Expand Down Expand Up @@ -1053,7 +1051,7 @@ class KotlinInputAstVisitor(
prefix: String? = null,
postfix: String? = null,
breakAfterPrefix: Boolean = true,
breakBeforePostfix: Boolean = isGoogleStyle,
breakBeforePostfix: Boolean = options.manageTrailingCommas,
): BreakTag? {
val breakAfterLastElement = hasTrailingComma || (postfix != null && breakBeforePostfix)
val nameTag = if (breakAfterLastElement) null else genSym()
Expand Down Expand Up @@ -2138,7 +2136,7 @@ class KotlinInputAstVisitor(
hasTrailingComma = list.trailingComma != null,
prefix = "<",
postfix = ">",
wrapInBlock = !isGoogleStyle,
wrapInBlock = !options.manageTrailingCommas,
)
}
}
Expand Down Expand Up @@ -2370,7 +2368,7 @@ class KotlinInputAstVisitor(
expression.trailingComma != null,
prefix = "[",
postfix = "]",
wrapInBlock = !isGoogleStyle)
wrapInBlock = !options.manageTrailingCommas)
}
}

Expand Down Expand Up @@ -2611,7 +2609,7 @@ class KotlinInputAstVisitor(
builder.token(keyword)
builder.space()
builder.token("(")
if (isGoogleStyle) {
if (options.manageTrailingCommas) {
builder.block(expressionBreakIndent) {
builder.breakOp(Doc.FillMode.UNIFIED, "", ZERO)
visit(condition)
Expand Down

0 comments on commit 88c4961

Please sign in to comment.