diff --git a/idea/formatter/src/org/jetbrains/kotlin/idea/formatter/KotlinCommonBlock.kt b/idea/formatter/src/org/jetbrains/kotlin/idea/formatter/KotlinCommonBlock.kt index cfc9be3d252..d5da6fc3654 100644 --- a/idea/formatter/src/org/jetbrains/kotlin/idea/formatter/KotlinCommonBlock.kt +++ b/idea/formatter/src/org/jetbrains/kotlin/idea/formatter/KotlinCommonBlock.kt @@ -126,7 +126,9 @@ abstract class KotlinCommonBlock( var currentNode: ASTNode? = this while (currentNode != null) { if (currentNode.elementType in QUALIFIED_EXPRESSIONS) return true - if (currentNode.elementType != PARENTHESIZED && currentNode.psi?.safeAs()?.operationToken != EXCLEXCL) return false + if (currentNode.elementType != PARENTHESIZED && currentNode.psi?.safeAs() + ?.operationToken != EXCLEXCL + ) return false currentNode = currentNode.treeParent } @@ -149,6 +151,7 @@ abstract class KotlinCommonBlock( private fun ASTBlock.processBlock(indent: Indent, wrap: Wrap?): ASTBlock { val currentNode = requireNode() + @Suppress("UNCHECKED_CAST") val subBlocks = subBlocks as List val elementType = currentNode.elementType @@ -681,7 +684,9 @@ abstract class KotlinCommonBlock( } if (nodePsi.operationToken == ELVIS && nodePsi.getStrictParentOfType() == null) { return { childElement -> - if (childElement.elementType == OPERATION_REFERENCE && (childElement.psi as? KtOperationReferenceExpression)?.operationSignTokenType == ELVIS) { + if (childElement.elementType == OPERATION_REFERENCE && (childElement.psi as? KtOperationReferenceExpression) + ?.operationSignTokenType == ELVIS + ) { Wrap.createWrap(settings.kotlinCustomSettings.WRAP_ELVIS_EXPRESSIONS, true) } else { null diff --git a/idea/formatter/src/org/jetbrains/kotlin/idea/formatter/KotlinSpacingBuilder.kt b/idea/formatter/src/org/jetbrains/kotlin/idea/formatter/KotlinSpacingBuilder.kt index b5b8ff2d544..927276388e5 100644 --- a/idea/formatter/src/org/jetbrains/kotlin/idea/formatter/KotlinSpacingBuilder.kt +++ b/idea/formatter/src/org/jetbrains/kotlin/idea/formatter/KotlinSpacingBuilder.kt @@ -149,7 +149,8 @@ class KotlinSpacingBuilder(val commonCodeStyleSettings: CommonCodeStyleSettings, // TODO: it's a severe hack but I don't know how to implement it in other way if (child1.requireNode().elementType == KtTokens.EOL_COMMENT && spacing.toString().contains("minLineFeeds=0")) { val isBeforeBlock = - child2.requireNode().elementType == KtNodeTypes.BLOCK || child2.requireNode().firstChildNode?.elementType == KtNodeTypes.BLOCK + child2.requireNode().elementType == KtNodeTypes.BLOCK || child2.requireNode().firstChildNode + ?.elementType == KtNodeTypes.BLOCK val keepBlankLines = if (isBeforeBlock) 0 else commonCodeStyleSettings.KEEP_BLANK_LINES_IN_CODE return createSpacing(0, minLineFeeds = 1, keepLineBreaks = true, keepBlankLines = keepBlankLines) } diff --git a/idea/formatter/src/org/jetbrains/kotlin/idea/formatter/kotlinSpacingRules.kt b/idea/formatter/src/org/jetbrains/kotlin/idea/formatter/kotlinSpacingRules.kt index 772f03d270f..5a238432116 100644 --- a/idea/formatter/src/org/jetbrains/kotlin/idea/formatter/kotlinSpacingRules.kt +++ b/idea/formatter/src/org/jetbrains/kotlin/idea/formatter/kotlinSpacingRules.kt @@ -612,7 +612,9 @@ fun createSpacingBuilder(settings: CodeStyleSettings, builderUtil: KotlinSpacing val prevSibling = rightParenthesis?.prevSibling val spaces = if (kotlinCustomSettings.SPACE_BEFORE_EXTEND_COLON) 1 else 0 // TODO This should use DependentSpacingRule, but it doesn't set keepLineBreaks to false if max LFs is 0 - if ((prevSibling as? PsiWhiteSpace)?.textContains('\n') == true || kotlinCommonSettings.METHOD_PARAMETERS_RPAREN_ON_NEXT_LINE) { + if ((prevSibling as? PsiWhiteSpace)?.textContains('\n') == true || kotlinCommonSettings + .METHOD_PARAMETERS_RPAREN_ON_NEXT_LINE + ) { createSpacing(spaces, keepLineBreaks = false) } else { createSpacing(spaces)