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 a930dbf9ca6..7efcb927745 100644 --- a/idea/formatter/src/org/jetbrains/kotlin/idea/formatter/KotlinCommonBlock.kt +++ b/idea/formatter/src/org/jetbrains/kotlin/idea/formatter/KotlinCommonBlock.kt @@ -47,8 +47,11 @@ private val CODE_BLOCKS = TokenSet.create(KtNodeTypes.BLOCK, KtNodeTypes.CLASS_B private val ALIGN_FOR_BINARY_OPERATIONS = TokenSet.create(MUL, DIV, PERC, PLUS, MINUS, ELVIS, LT, GT, LTEQ, GTEQ, ANDAND, OROR) private val ANNOTATIONS = TokenSet.create(KtNodeTypes.ANNOTATION_ENTRY, KtNodeTypes.ANNOTATION) -val CodeStyleSettings.kotlinSettings - get() = getCustomSettings(KotlinCodeStyleSettings::class.java) +val CodeStyleSettings.kotlinCommonSettings: CommonCodeStyleSettings + get() = getCommonSettings(KotlinLanguage.INSTANCE) + +val CodeStyleSettings.kotlinCustomSettings: KotlinCodeStyleSettings + get() = getCustomSettings(KotlinCodeStyleSettings::class.java)!! abstract class KotlinCommonBlock( private val node: ASTNode, @@ -96,7 +99,7 @@ abstract class KotlinCommonBlock( // relative to it when it starts from new line (see Indent javadoc). val operationBlock = nodeSubBlocks[operationBlockIndex] - val indent = if (settings.kotlinSettings.CONTINUATION_INDENT_FOR_CHAINED_CALLS) + val indent = if (settings.kotlinCustomSettings.CONTINUATION_INDENT_FOR_CHAINED_CALLS) Indent.getContinuationWithoutFirstIndent() else Indent.getNormalIndent() @@ -188,7 +191,7 @@ abstract class KotlinCommonBlock( ChildAttributes(block.indent, block.alignment) } else { - val indent = if (type == KtNodeTypes.VALUE_PARAMETER_LIST && !settings.kotlinSettings.CONTINUATION_INDENT_IN_PARAMETER_LISTS) + val indent = if (type == KtNodeTypes.VALUE_PARAMETER_LIST && !settings.kotlinCustomSettings.CONTINUATION_INDENT_IN_PARAMETER_LISTS) Indent.getNormalIndent() else Indent.getContinuationIndent() @@ -220,35 +223,35 @@ abstract class KotlinCommonBlock( } private fun getChildrenAlignmentStrategy(): CommonAlignmentStrategy { - val jetCommonSettings = settings.getCommonSettings(KotlinLanguage.INSTANCE) - val kotlinSettings = settings.kotlinSettings + val kotlinCommonSettings = settings.kotlinCommonSettings + val kotlinCustomSettings = settings.kotlinCustomSettings val parentType = node.elementType return when { parentType === KtNodeTypes.VALUE_PARAMETER_LIST -> getAlignmentForChildInParenthesis( - jetCommonSettings.ALIGN_MULTILINE_PARAMETERS, KtNodeTypes.VALUE_PARAMETER, COMMA, - jetCommonSettings.ALIGN_MULTILINE_METHOD_BRACKETS, LPAR, RPAR) + kotlinCommonSettings.ALIGN_MULTILINE_PARAMETERS, KtNodeTypes.VALUE_PARAMETER, COMMA, + kotlinCommonSettings.ALIGN_MULTILINE_METHOD_BRACKETS, LPAR, RPAR) parentType === KtNodeTypes.VALUE_ARGUMENT_LIST -> getAlignmentForChildInParenthesis( - jetCommonSettings.ALIGN_MULTILINE_PARAMETERS_IN_CALLS, KtNodeTypes.VALUE_ARGUMENT, COMMA, - jetCommonSettings.ALIGN_MULTILINE_METHOD_BRACKETS, LPAR, RPAR) + kotlinCommonSettings.ALIGN_MULTILINE_PARAMETERS_IN_CALLS, KtNodeTypes.VALUE_ARGUMENT, COMMA, + kotlinCommonSettings.ALIGN_MULTILINE_METHOD_BRACKETS, LPAR, RPAR) parentType === KtNodeTypes.WHEN -> - getAlignmentForCaseBranch(kotlinSettings.ALIGN_IN_COLUMNS_CASE_BRANCH) + getAlignmentForCaseBranch(kotlinCustomSettings.ALIGN_IN_COLUMNS_CASE_BRANCH) parentType === KtNodeTypes.WHEN_ENTRY -> alignmentStrategy parentType in BINARY_EXPRESSIONS && getOperationType(node) in ALIGN_FOR_BINARY_OPERATIONS -> - createAlignmentStrategy(jetCommonSettings.ALIGN_MULTILINE_BINARY_OPERATION, getAlignment()) + createAlignmentStrategy(kotlinCommonSettings.ALIGN_MULTILINE_BINARY_OPERATION, getAlignment()) parentType === KtNodeTypes.SUPER_TYPE_LIST || parentType === KtNodeTypes.INITIALIZER_LIST -> - createAlignmentStrategy(jetCommonSettings.ALIGN_MULTILINE_EXTENDS_LIST, getAlignment()) + createAlignmentStrategy(kotlinCommonSettings.ALIGN_MULTILINE_EXTENDS_LIST, getAlignment()) parentType === KtNodeTypes.PARENTHESIZED -> object : CommonAlignmentStrategy() { - private var bracketsAlignment: Alignment? = if (jetCommonSettings.ALIGN_MULTILINE_BINARY_OPERATION) Alignment.createAlignment() else null + private var bracketsAlignment: Alignment? = if (kotlinCommonSettings.ALIGN_MULTILINE_BINARY_OPERATION) Alignment.createAlignment() else null override fun getAlignment(node: ASTNode): Alignment? { val childNodeType = node.elementType @@ -306,7 +309,7 @@ abstract class KotlinCommonBlock( } private fun getWrappingStrategy(): WrappingStrategy { - val commonSettings = settings.getCommonSettings(KotlinLanguage.INSTANCE) + val commonSettings = settings.kotlinCommonSettings val elementType = node.elementType val nodePsi = node.psi @@ -441,7 +444,7 @@ private val INDENT_RULES = arrayOf( it.psi is KtExpression && it.psi !is KtBlockExpression } .set { settings -> - if (settings.kotlinSettings.CONTINUATION_INDENT_FOR_EXPRESSION_BODIES) + if (settings.kotlinCustomSettings.CONTINUATION_INDENT_FOR_EXPRESSION_BODIES) Indent.getContinuationIndent() else Indent.getNormalIndent() @@ -464,7 +467,7 @@ private val INDENT_RULES = arrayOf( .notForType(KtTokens.DOT, KtTokens.SAFE_ACCESS) .forElement { it.treeParent.firstChildNode != it } .set { settings -> - if (settings.kotlinSettings.CONTINUATION_INDENT_FOR_CHAINED_CALLS) + if (settings.kotlinCustomSettings.CONTINUATION_INDENT_FOR_CHAINED_CALLS) Indent.getContinuationWithoutFirstIndent() else Indent.getNormalIndent() @@ -478,7 +481,7 @@ private val INDENT_RULES = arrayOf( strategy("Delegation list") .within(KtNodeTypes.SUPER_TYPE_LIST, KtNodeTypes.INITIALIZER_LIST) .set { settings -> - if (settings.kotlinSettings.CONTINUATION_INDENT_IN_SUPERTYPE_LISTS) + if (settings.kotlinCustomSettings.CONTINUATION_INDENT_IN_SUPERTYPE_LISTS) Indent.getContinuationIndent(false) else Indent.getNormalIndent() @@ -527,7 +530,7 @@ private val INDENT_RULES = arrayOf( .within(KtNodeTypes.VALUE_PARAMETER_LIST) .forElement { it.elementType == KtNodeTypes.VALUE_PARAMETER && it.psi.prevSibling != null } .set { settings -> - if (settings.kotlinSettings.CONTINUATION_INDENT_IN_PARAMETER_LISTS) + if (settings.kotlinCustomSettings.CONTINUATION_INDENT_IN_PARAMETER_LISTS) Indent.getContinuationIndent() else Indent.getNormalIndent() 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 a5caeea5aa1..4585528addd 100644 --- a/idea/formatter/src/org/jetbrains/kotlin/idea/formatter/kotlinSpacingRules.kt +++ b/idea/formatter/src/org/jetbrains/kotlin/idea/formatter/kotlinSpacingRules.kt @@ -29,8 +29,6 @@ import com.intellij.psi.codeStyle.CodeStyleSettings import com.intellij.psi.tree.IElementType import com.intellij.psi.tree.TokenSet import org.jetbrains.kotlin.KtNodeTypes.* -import org.jetbrains.kotlin.idea.KotlinLanguage -import org.jetbrains.kotlin.idea.core.formatter.KotlinCodeStyleSettings import org.jetbrains.kotlin.idea.formatter.KotlinSpacingBuilder.CustomSpacingBuilder import org.jetbrains.kotlin.lexer.KtTokens import org.jetbrains.kotlin.lexer.KtTokens.* @@ -53,9 +51,8 @@ fun SpacingBuilder.afterInside(element: IElementType, tokenSet: TokenSet, spacin } fun createSpacingBuilder(settings: CodeStyleSettings, builderUtil: KotlinSpacingBuilderUtil): KotlinSpacingBuilder { - val kotlinSettings = settings.getCustomSettings(KotlinCodeStyleSettings::class.java)!! - val kotlinCommonSettings = settings.getCommonSettings(KotlinLanguage.INSTANCE)!! - + val kotlinCommonSettings = settings.kotlinCommonSettings + val kotlinCustomSettings = settings.kotlinCustomSettings return rules(kotlinCommonSettings, builderUtil) { val DECLARATIONS = TokenSet.create(PROPERTY, FUN, CLASS, OBJECT_DECLARATION, ENUM_ENTRY, SECONDARY_CONSTRUCTOR, CLASS_INITIALIZER) @@ -71,10 +68,10 @@ fun createSpacingBuilder(settings: CodeStyleSettings, builderUtil: KotlinSpacing custom { fun commentSpacing(minSpaces: Int): Spacing { - if (commonCodeStyleSettings.KEEP_FIRST_COLUMN_COMMENT) { - return Spacing.createKeepingFirstColumnSpacing(minSpaces, Int.MAX_VALUE, settings.KEEP_LINE_BREAKS, commonCodeStyleSettings.KEEP_BLANK_LINES_IN_CODE) + if (kotlinCommonSettings.KEEP_FIRST_COLUMN_COMMENT) { + return Spacing.createKeepingFirstColumnSpacing(minSpaces, Int.MAX_VALUE, settings.KEEP_LINE_BREAKS, kotlinCommonSettings.KEEP_BLANK_LINES_IN_CODE) } - return Spacing.createSpacing(minSpaces, Int.MAX_VALUE, 0, settings.KEEP_LINE_BREAKS, commonCodeStyleSettings.KEEP_BLANK_LINES_IN_CODE) + return Spacing.createSpacing(minSpaces, Int.MAX_VALUE, 0, settings.KEEP_LINE_BREAKS, kotlinCommonSettings.KEEP_BLANK_LINES_IN_CODE) } // Several line comments happened to be generated in one line @@ -120,7 +117,7 @@ fun createSpacingBuilder(settings: CodeStyleSettings, builderUtil: KotlinSpacing } val classBody = parent.node.psi as KtClassBody val parentPsi = classBody.parent as? KtClassOrObject ?: return@customRule null - if (commonCodeStyleSettings.BLANK_LINES_AFTER_CLASS_HEADER == 0 || parentPsi.isObjectLiteral()) { + if (kotlinCommonSettings.BLANK_LINES_AFTER_CLASS_HEADER == 0 || parentPsi.isObjectLiteral()) { null } else { @@ -134,7 +131,7 @@ fun createSpacingBuilder(settings: CodeStyleSettings, builderUtil: KotlinSpacing settings.KEEP_LINE_BREAKS, settings.KEEP_BLANK_LINES_IN_DECLARATIONS, TextRange(parentPsi.textRange.startOffset, left.node.psi.textRange.startOffset), DependentSpacingRule(DependentSpacingRule.Trigger.HAS_LINE_FEEDS) - .registerData(DependentSpacingRule.Anchor.MIN_LINE_FEEDS, commonCodeStyleSettings.BLANK_LINES_AFTER_CLASS_HEADER + 1) + .registerData(DependentSpacingRule.Anchor.MIN_LINE_FEEDS, kotlinCommonSettings.BLANK_LINES_AFTER_CLASS_HEADER + 1) ) } } @@ -208,7 +205,7 @@ fun createSpacingBuilder(settings: CodeStyleSettings, builderUtil: KotlinSpacing aroundInside(TokenSet.create(MUL, DIV, PERC), BINARY_EXPRESSION).spaceIf(kotlinCommonSettings.SPACE_AROUND_MULTIPLICATIVE_OPERATORS) around(TokenSet.create(PLUSPLUS, MINUSMINUS, EXCLEXCL, MINUS, PLUS, EXCL)).spaceIf(kotlinCommonSettings.SPACE_AROUND_UNARY_OPERATOR) around(ELVIS).spaces(1) - around(RANGE).spaceIf(kotlinSettings.SPACE_AROUND_RANGE) + around(RANGE).spaceIf(kotlinCustomSettings.SPACE_AROUND_RANGE) after(MODIFIER_LIST).spaces(1) @@ -224,8 +221,8 @@ fun createSpacingBuilder(settings: CodeStyleSettings, builderUtil: KotlinSpacing betweenInside(RETURN_KEYWORD, LABEL_QUALIFIER, RETURN).spaces(0) afterInside(RETURN_KEYWORD, RETURN).spaces(1) afterInside(LABEL_QUALIFIER, RETURN).spaces(1) - betweenInside(LABEL_QUALIFIER, EOL_COMMENT, LABELED_EXPRESSION).spacing(0, Int.MAX_VALUE, 0, true, commonCodeStyleSettings.KEEP_BLANK_LINES_IN_CODE) - betweenInside(LABEL_QUALIFIER, BLOCK_COMMENT, LABELED_EXPRESSION).spacing(0, Int.MAX_VALUE, 0, true, commonCodeStyleSettings.KEEP_BLANK_LINES_IN_CODE) + betweenInside(LABEL_QUALIFIER, EOL_COMMENT, LABELED_EXPRESSION).spacing(0, Int.MAX_VALUE, 0, true, kotlinCommonSettings.KEEP_BLANK_LINES_IN_CODE) + betweenInside(LABEL_QUALIFIER, BLOCK_COMMENT, LABELED_EXPRESSION).spacing(0, Int.MAX_VALUE, 0, true, kotlinCommonSettings.KEEP_BLANK_LINES_IN_CODE) afterInside(LABEL_QUALIFIER, LABELED_EXPRESSION).spaces(1) betweenInside(FUN_KEYWORD, VALUE_PARAMETER_LIST, FUN).spacing(0, 0, 0, false, 0) @@ -284,7 +281,7 @@ fun createSpacingBuilder(settings: CodeStyleSettings, builderUtil: KotlinSpacing betweenInside(IF_KEYWORD, LPAR, IF).spaceIf(kotlinCommonSettings.SPACE_BEFORE_IF_PARENTHESES) betweenInside(WHILE_KEYWORD, LPAR, WHILE).spaceIf(kotlinCommonSettings.SPACE_BEFORE_WHILE_PARENTHESES) betweenInside(WHILE_KEYWORD, LPAR, DO_WHILE).spaceIf(kotlinCommonSettings.SPACE_BEFORE_WHILE_PARENTHESES) - betweenInside(WHEN_KEYWORD, LPAR, WHEN).spaceIf(kotlinSettings.SPACE_BEFORE_WHEN_PARENTHESES) + betweenInside(WHEN_KEYWORD, LPAR, WHEN).spaceIf(kotlinCustomSettings.SPACE_BEFORE_WHEN_PARENTHESES) betweenInside(CATCH_KEYWORD, VALUE_PARAMETER_LIST, CATCH).spaceIf(kotlinCommonSettings.SPACE_BEFORE_CATCH_PARENTHESES) betweenInside(LPAR, VALUE_PARAMETER, FOR).spaces(0) @@ -303,14 +300,14 @@ fun createSpacingBuilder(settings: CodeStyleSettings, builderUtil: KotlinSpacing beforeInside(QUEST, NULLABLE_TYPE).spaces(0) val TYPE_COLON_ELEMENTS = TokenSet.create(PROPERTY, FUN, VALUE_PARAMETER, DESTRUCTURING_DECLARATION_ENTRY, FUNCTION_LITERAL) - beforeInside(COLON, TYPE_COLON_ELEMENTS) { spaceIf(kotlinSettings.SPACE_BEFORE_TYPE_COLON) } - afterInside(COLON, TYPE_COLON_ELEMENTS) { spaceIf(kotlinSettings.SPACE_AFTER_TYPE_COLON) } + beforeInside(COLON, TYPE_COLON_ELEMENTS) { spaceIf(kotlinCustomSettings.SPACE_BEFORE_TYPE_COLON) } + afterInside(COLON, TYPE_COLON_ELEMENTS) { spaceIf(kotlinCustomSettings.SPACE_AFTER_TYPE_COLON) } - afterInside(COLON, EXTEND_COLON_ELEMENTS) { spaceIf(kotlinSettings.SPACE_AFTER_EXTEND_COLON) } + afterInside(COLON, EXTEND_COLON_ELEMENTS) { spaceIf(kotlinCustomSettings.SPACE_AFTER_EXTEND_COLON) } - beforeInside(ARROW, FUNCTION_LITERAL).spaceIf(kotlinSettings.SPACE_BEFORE_LAMBDA_ARROW) + beforeInside(ARROW, FUNCTION_LITERAL).spaceIf(kotlinCustomSettings.SPACE_BEFORE_LAMBDA_ARROW) - aroundInside(ARROW, FUNCTION_TYPE).spaceIf(kotlinSettings.SPACE_AROUND_FUNCTION_TYPE_ARROW) + aroundInside(ARROW, FUNCTION_TYPE).spaceIf(kotlinCustomSettings.SPACE_AROUND_FUNCTION_TYPE_ARROW) before(VALUE_ARGUMENT_LIST).spaces(0) between(VALUE_ARGUMENT_LIST, LAMBDA_ARGUMENT).spaces(1) @@ -370,8 +367,8 @@ fun createSpacingBuilder(settings: CodeStyleSettings, builderUtil: KotlinSpacing if (leftBrace != null) { val previousLeaf = builderUtil.getPreviousNonWhitespaceLeaf(leftBrace) val isAfterEolComment = previousLeaf != null && (previousLeaf.elementType == EOL_COMMENT) - val keepLineBreaks = kotlinSettings.LBRACE_ON_NEXT_LINE || isAfterEolComment - val minimumLF = if (kotlinSettings.LBRACE_ON_NEXT_LINE) 1 else 0 + val keepLineBreaks = kotlinCustomSettings.LBRACE_ON_NEXT_LINE || isAfterEolComment + val minimumLF = if (kotlinCustomSettings.LBRACE_ON_NEXT_LINE) 1 else 0 return createSpacing(1, minLineFeeds = minimumLF, keepLineBreaks = keepLineBreaks, keepBlankLines = 0) } } @@ -421,7 +418,7 @@ fun createSpacingBuilder(settings: CodeStyleSettings, builderUtil: KotlinSpacing val leftEntry = left.node.psi as KtWhenEntry val rightEntry = right.node.psi as KtWhenEntry val blankLines = if (leftEntry.expression is KtBlockExpression || rightEntry.expression is KtBlockExpression) - settings.kotlinSettings.BLANK_LINES_AROUND_BLOCK_WHEN_BRANCHES + settings.kotlinCustomSettings.BLANK_LINES_AROUND_BLOCK_WHEN_BRANCHES else 0 @@ -434,7 +431,7 @@ fun createSpacingBuilder(settings: CodeStyleSettings, builderUtil: KotlinSpacing spacingForLeftBrace(block = parent.node, blockType = WHEN) } - val spacesInSimpleFunction = if (kotlinSettings.INSERT_WHITESPACES_IN_SIMPLE_ONE_LINE_METHOD) 1 else 0 + val spacesInSimpleFunction = if (kotlinCustomSettings.INSERT_WHITESPACES_IN_SIMPLE_ONE_LINE_METHOD) 1 else 0 inPosition(parent = FUNCTION_LITERAL, left = LBRACE, right = BLOCK) @@ -468,7 +465,7 @@ fun createSpacingBuilder(settings: CodeStyleSettings, builderUtil: KotlinSpacing } inPosition(parent = CLASS_BODY, right = RBRACE).customRule { parent, _, _ -> - commonCodeStyleSettings.createSpaceBeforeRBrace(1, parent.textRange) + kotlinCommonSettings.createSpaceBeforeRBrace(1, parent.textRange) } inPosition(parent = BLOCK, right = RBRACE).customRule { block, left, _ -> @@ -487,7 +484,7 @@ fun createSpacingBuilder(settings: CodeStyleSettings, builderUtil: KotlinSpacing } val spaces = if (empty) 0 else spacesInSimpleFunction - commonCodeStyleSettings.createSpaceBeforeRBrace(spaces, psiElement.textRangeWithoutComments) + kotlinCommonSettings.createSpaceBeforeRBrace(spaces, psiElement.textRangeWithoutComments) } inPosition(parent = BLOCK, left = LBRACE).customRule { parent, _, _ -> @@ -498,17 +495,17 @@ fun createSpacingBuilder(settings: CodeStyleSettings, builderUtil: KotlinSpacing // Empty block is covered in above rule Spacing.createDependentLFSpacing(spacesInSimpleFunction, spacesInSimpleFunction, funNode.textRangeWithoutComments, - commonCodeStyleSettings.KEEP_LINE_BREAKS, - commonCodeStyleSettings.KEEP_BLANK_LINES_IN_CODE) + kotlinCommonSettings.KEEP_LINE_BREAKS, + kotlinCommonSettings.KEEP_BLANK_LINES_IN_CODE) } inPosition(parentSet = EXTEND_COLON_ELEMENTS, left = PRIMARY_CONSTRUCTOR, right = COLON).customRule { parent, left, _ -> val primaryConstructor = left.node.psi as KtPrimaryConstructor val rightParenthesis = primaryConstructor.valueParameterList?.rightParenthesis val prevSibling = rightParenthesis?.prevSibling - val spaces = if (kotlinSettings.SPACE_BEFORE_EXTEND_COLON) 1 else 0 + 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 || commonCodeStyleSettings.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 { @@ -520,16 +517,16 @@ fun createSpacingBuilder(settings: CodeStyleSettings, builderUtil: KotlinSpacing simple { afterInside(LBRACE, BLOCK).lineBreakInCode() beforeInside(RBRACE, BLOCK).spacing(1, 0, 1, - commonCodeStyleSettings.KEEP_LINE_BREAKS, - commonCodeStyleSettings.KEEP_BLANK_LINES_BEFORE_RBRACE) - between(LBRACE, ENUM_ENTRY).spacing(1, 0, 0, true, commonCodeStyleSettings.KEEP_BLANK_LINES_IN_CODE) + kotlinCommonSettings.KEEP_LINE_BREAKS, + kotlinCommonSettings.KEEP_BLANK_LINES_BEFORE_RBRACE) + between(LBRACE, ENUM_ENTRY).spacing(1, 0, 0, true, kotlinCommonSettings.KEEP_BLANK_LINES_IN_CODE) beforeInside(RBRACE, WHEN).lineBreakInCode() between(RPAR, BODY).spaces(1) // if when entry has block, spacing after arrow should be set by lbrace rule - aroundInside(ARROW, WHEN_ENTRY).spaceIf(kotlinSettings.SPACE_AROUND_WHEN_ARROW) + aroundInside(ARROW, WHEN_ENTRY).spaceIf(kotlinCustomSettings.SPACE_AROUND_WHEN_ARROW) - beforeInside(COLON, EXTEND_COLON_ELEMENTS) { spaceIf(kotlinSettings.SPACE_BEFORE_EXTEND_COLON) } + beforeInside(COLON, EXTEND_COLON_ELEMENTS) { spaceIf(kotlinCustomSettings.SPACE_BEFORE_EXTEND_COLON) } after(EOL_COMMENT).lineBreakInCode() } diff --git a/idea/src/org/jetbrains/kotlin/idea/formatter/KotlinIndentOptionsEditor.kt b/idea/src/org/jetbrains/kotlin/idea/formatter/KotlinIndentOptionsEditor.kt index 0f2f9ed30c8..1a1c0094a2e 100644 --- a/idea/src/org/jetbrains/kotlin/idea/formatter/KotlinIndentOptionsEditor.kt +++ b/idea/src/org/jetbrains/kotlin/idea/formatter/KotlinIndentOptionsEditor.kt @@ -37,7 +37,7 @@ class KotlinIndentOptionsEditor : SmartIndentOptionsEditor() { override fun isModified(settings: CodeStyleSettings, options: CommonCodeStyleSettings.IndentOptions): Boolean { var isModified = super.isModified(settings, options) - val kotlinSettings = settings.getCustomSettings(KotlinCodeStyleSettings::class.java) + val kotlinSettings = settings.kotlinCustomSettings isModified = isModified || IndentOptionsEditor.isFieldModified(useContinuationIndentInParameterList, kotlinSettings.CONTINUATION_INDENT_IN_PARAMETER_LISTS) isModified = isModified || IndentOptionsEditor.isFieldModified(useContinuationIndentForExpressionBodies,