@@ -665,8 +665,10 @@ class KotlinInputAstVisitor(
665665 (receiverExpression as ? KtQualifiedExpression )?.selectorExpression
666666 ? : receiverExpression
667667 val current = checkNotNull(part.selectorExpression)
668- if (lastIndexToOpen == 0 &&
669- shouldGroupPartWithPrevious(parts, part, index, previous, current)) {
668+ if (
669+ lastIndexToOpen == 0 &&
670+ shouldGroupPartWithPrevious(parts, part, index, previous, current)
671+ ) {
670672 // this and the previous items should be grouped for better style
671673 // we add another group to open in index 0
672674 groupingInfos[0 ].groupOpenCount++
@@ -710,21 +712,27 @@ class KotlinInputAstVisitor(
710712 return true
711713 }
712714 // this and the previous part are a package name, type name, or property
713- if (previous is KtSimpleNameExpression &&
714- current is KtSimpleNameExpression &&
715- part is KtDotQualifiedExpression ) {
715+ if (
716+ previous is KtSimpleNameExpression &&
717+ current is KtSimpleNameExpression &&
718+ part is KtDotQualifiedExpression
719+ ) {
716720 return true
717721 }
718722 // this is `Foo` in `com.facebook.Foo`, so everything before it is a package name
719- if (current.text.first().isUpperCase() &&
720- current is KtSimpleNameExpression &&
721- part is KtDotQualifiedExpression ) {
723+ if (
724+ current.text.first().isUpperCase() &&
725+ current is KtSimpleNameExpression &&
726+ part is KtDotQualifiedExpression
727+ ) {
722728 return true
723729 }
724730 // this is the `foo()` in `com.facebook.Foo.foo()` or in `Foo.foo()`
725- if (current is KtCallExpression &&
726- (previous !is KtCallExpression ) &&
727- previous.text?.firstOrNull()?.isUpperCase() == true ) {
731+ if (
732+ current is KtCallExpression &&
733+ (previous !is KtCallExpression ) &&
734+ previous.text?.firstOrNull()?.isUpperCase() == true
735+ ) {
728736 return true
729737 }
730738 // this is an invocation and the last item, and the previous it not, i.e. `a.b.c()`
@@ -927,10 +935,12 @@ class KotlinInputAstVisitor(
927935 val shouldForceMultiline =
928936 options.preserveLambdaBreaks && hasSourceNewlineInLambdaBody(lambdaExpression)
929937
930- if (! shouldForceMultiline &&
931- expressionStatements.size == 1 &&
932- expressionStatements.first() !is KtReturnExpression &&
933- ! bodyExpression.startsWithComment()) {
938+ if (
939+ ! shouldForceMultiline &&
940+ expressionStatements.size == 1 &&
941+ expressionStatements.first() !is KtReturnExpression &&
942+ ! bodyExpression.startsWithComment()
943+ ) {
934944 visitStatement(expressionStatements[0 ])
935945 } else {
936946 visitStatements(expressionStatements)
@@ -1305,8 +1315,10 @@ class KotlinInputAstVisitor(
13051315 val operator = expression.operationReference.text
13061316
13071317 visit(baseExpression)
1308- if (baseExpression is KtPostfixExpression &&
1309- baseExpression.operationReference.text.last() == operator .first()) {
1318+ if (
1319+ baseExpression is KtPostfixExpression &&
1320+ baseExpression.operationReference.text.last() == operator .first()
1321+ ) {
13101322 builder.space()
13111323 }
13121324 builder.token(operator )
@@ -1320,8 +1332,10 @@ class KotlinInputAstVisitor(
13201332 val operator = expression.operationReference.text
13211333
13221334 builder.token(operator )
1323- if (baseExpression is KtPrefixExpression &&
1324- operator .last() == baseExpression.operationReference.text.first()) {
1335+ if (
1336+ baseExpression is KtPrefixExpression &&
1337+ operator .last() == baseExpression.operationReference.text.first()
1338+ ) {
13251339 builder.space()
13261340 }
13271341 visit(baseExpression)
@@ -1577,9 +1591,11 @@ class KotlinInputAstVisitor(
15771591 carry = carry.selectorExpression
15781592 }
15791593 if (carry is KtCallExpression ) {
1580- if (carry.valueArgumentList?.leftParenthesis == null &&
1581- carry.lambdaArguments.isNotEmpty() &&
1582- carry.typeArgumentList?.arguments.isNullOrEmpty()) {
1594+ if (
1595+ carry.valueArgumentList?.leftParenthesis == null &&
1596+ carry.lambdaArguments.isNotEmpty() &&
1597+ carry.typeArgumentList?.arguments.isNullOrEmpty()
1598+ ) {
15831599 carry = carry.lambdaArguments[0 ].getArgumentExpression()
15841600 } else {
15851601 return false
@@ -2510,9 +2526,11 @@ class KotlinInputAstVisitor(
25102526 visit(expression.leftHandSide)
25112527 if (! openGroupBeforeLeft) builder.open(ZERO )
25122528 val parent = expression.parent
2513- if (parent is KtValueArgument ||
2514- parent is KtParenthesizedExpression ||
2515- parent is KtContainerNode ) {
2529+ if (
2530+ parent is KtValueArgument ||
2531+ parent is KtParenthesizedExpression ||
2532+ parent is KtContainerNode
2533+ ) {
25162534 builder.breakOp(Doc .FillMode .UNIFIED , " " , expressionBreakIndent)
25172535 } else {
25182536 builder.space()
@@ -2675,7 +2693,8 @@ class KotlinInputAstVisitor(
26752693 child is PsiComment -> continue
26762694 child is KtScript && importListEmpty -> OpsBuilder .BlankLineWanted .PRESERVE
26772695 else -> OpsBuilder .BlankLineWanted .YES
2678- })
2696+ }
2697+ )
26792698
26802699 visit(child)
26812700 isFirst = false
@@ -2698,8 +2717,9 @@ class KotlinInputAstVisitor(
26982717 builder.blankLineWanted(OpsBuilder .BlankLineWanted .PRESERVE )
26992718 } else if (lastChildIsContextReceiver) {
27002719 builder.blankLineWanted(OpsBuilder .BlankLineWanted .NO )
2701- } else if (child !is PsiComment &&
2702- (childGetsBlankLineBefore || lastChildHadBlankLineBefore)) {
2720+ } else if (
2721+ child !is PsiComment && (childGetsBlankLineBefore || lastChildHadBlankLineBefore)
2722+ ) {
27032723 builder.blankLineWanted(OpsBuilder .BlankLineWanted .YES )
27042724 }
27052725 visit(child)
0 commit comments