@@ -664,8 +664,10 @@ class KotlinInputAstVisitor(
664664 (receiverExpression as ? KtQualifiedExpression )?.selectorExpression
665665 ? : receiverExpression
666666 val current = checkNotNull(part.selectorExpression)
667- if (lastIndexToOpen == 0 &&
668- shouldGroupPartWithPrevious(parts, part, index, previous, current)) {
667+ if (
668+ lastIndexToOpen == 0 &&
669+ shouldGroupPartWithPrevious(parts, part, index, previous, current)
670+ ) {
669671 // this and the previous items should be grouped for better style
670672 // we add another group to open in index 0
671673 groupingInfos[0 ].groupOpenCount++
@@ -709,21 +711,27 @@ class KotlinInputAstVisitor(
709711 return true
710712 }
711713 // this and the previous part are a package name, type name, or property
712- if (previous is KtSimpleNameExpression &&
713- current is KtSimpleNameExpression &&
714- part is KtDotQualifiedExpression ) {
714+ if (
715+ previous is KtSimpleNameExpression &&
716+ current is KtSimpleNameExpression &&
717+ part is KtDotQualifiedExpression
718+ ) {
715719 return true
716720 }
717721 // this is `Foo` in `com.facebook.Foo`, so everything before it is a package name
718- if (current.text.first().isUpperCase() &&
719- current is KtSimpleNameExpression &&
720- part is KtDotQualifiedExpression ) {
722+ if (
723+ current.text.first().isUpperCase() &&
724+ current is KtSimpleNameExpression &&
725+ part is KtDotQualifiedExpression
726+ ) {
721727 return true
722728 }
723729 // this is the `foo()` in `com.facebook.Foo.foo()` or in `Foo.foo()`
724- if (current is KtCallExpression &&
725- (previous !is KtCallExpression ) &&
726- previous.text?.firstOrNull()?.isUpperCase() == true ) {
730+ if (
731+ current is KtCallExpression &&
732+ (previous !is KtCallExpression ) &&
733+ previous.text?.firstOrNull()?.isUpperCase() == true
734+ ) {
727735 return true
728736 }
729737 // this is an invocation and the last item, and the previous it not, i.e. `a.b.c()`
@@ -926,10 +934,12 @@ class KotlinInputAstVisitor(
926934 val shouldForceMultiline =
927935 options.preserveLambdaBreaks && hasSourceNewlineInLambdaBody(lambdaExpression)
928936
929- if (! shouldForceMultiline &&
930- expressionStatements.size == 1 &&
931- expressionStatements.first() !is KtReturnExpression &&
932- ! bodyExpression.startsWithComment()) {
937+ if (
938+ ! shouldForceMultiline &&
939+ expressionStatements.size == 1 &&
940+ expressionStatements.first() !is KtReturnExpression &&
941+ ! bodyExpression.startsWithComment()
942+ ) {
933943 visitStatement(expressionStatements[0 ])
934944 } else {
935945 visitStatements(expressionStatements)
@@ -1304,8 +1314,10 @@ class KotlinInputAstVisitor(
13041314 val operator = expression.operationReference.text
13051315
13061316 visit(baseExpression)
1307- if (baseExpression is KtPostfixExpression &&
1308- baseExpression.operationReference.text.last() == operator .first()) {
1317+ if (
1318+ baseExpression is KtPostfixExpression &&
1319+ baseExpression.operationReference.text.last() == operator .first()
1320+ ) {
13091321 builder.space()
13101322 }
13111323 builder.token(operator )
@@ -1319,8 +1331,10 @@ class KotlinInputAstVisitor(
13191331 val operator = expression.operationReference.text
13201332
13211333 builder.token(operator )
1322- if (baseExpression is KtPrefixExpression &&
1323- operator .last() == baseExpression.operationReference.text.first()) {
1334+ if (
1335+ baseExpression is KtPrefixExpression &&
1336+ operator .last() == baseExpression.operationReference.text.first()
1337+ ) {
13241338 builder.space()
13251339 }
13261340 visit(baseExpression)
@@ -1576,9 +1590,11 @@ class KotlinInputAstVisitor(
15761590 carry = carry.selectorExpression
15771591 }
15781592 if (carry is KtCallExpression ) {
1579- if (carry.valueArgumentList?.leftParenthesis == null &&
1580- carry.lambdaArguments.isNotEmpty() &&
1581- carry.typeArgumentList?.arguments.isNullOrEmpty()) {
1593+ if (
1594+ carry.valueArgumentList?.leftParenthesis == null &&
1595+ carry.lambdaArguments.isNotEmpty() &&
1596+ carry.typeArgumentList?.arguments.isNullOrEmpty()
1597+ ) {
15821598 carry = carry.lambdaArguments[0 ].getArgumentExpression()
15831599 } else {
15841600 return false
@@ -2507,9 +2523,11 @@ class KotlinInputAstVisitor(
25072523 visit(expression.leftHandSide)
25082524 if (! openGroupBeforeLeft) builder.open(ZERO )
25092525 val parent = expression.parent
2510- if (parent is KtValueArgument ||
2511- parent is KtParenthesizedExpression ||
2512- parent is KtContainerNode ) {
2526+ if (
2527+ parent is KtValueArgument ||
2528+ parent is KtParenthesizedExpression ||
2529+ parent is KtContainerNode
2530+ ) {
25132531 builder.breakOp(Doc .FillMode .UNIFIED , " " , expressionBreakIndent)
25142532 } else {
25152533 builder.space()
@@ -2672,7 +2690,8 @@ class KotlinInputAstVisitor(
26722690 child is PsiComment -> continue
26732691 child is KtScript && importListEmpty -> OpsBuilder .BlankLineWanted .PRESERVE
26742692 else -> OpsBuilder .BlankLineWanted .YES
2675- })
2693+ }
2694+ )
26762695
26772696 visit(child)
26782697 isFirst = false
@@ -2695,8 +2714,9 @@ class KotlinInputAstVisitor(
26952714 builder.blankLineWanted(OpsBuilder .BlankLineWanted .PRESERVE )
26962715 } else if (lastChildIsContextReceiver) {
26972716 builder.blankLineWanted(OpsBuilder .BlankLineWanted .NO )
2698- } else if (child !is PsiComment &&
2699- (childGetsBlankLineBefore || lastChildHadBlankLineBefore)) {
2717+ } else if (
2718+ child !is PsiComment && (childGetsBlankLineBefore || lastChildHadBlankLineBefore)
2719+ ) {
27002720 builder.blankLineWanted(OpsBuilder .BlankLineWanted .YES )
27012721 }
27022722 visit(child)
0 commit comments