From 8c7f57ca8370338d14d7d092a3eac6f7a2d595a3 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Mon, 8 Jan 2018 17:23:25 +0100 Subject: [PATCH] Honor "Use continuation indent in argument lists" for indent by Enter #KT-22121 Fixed --- .../idea/formatter/KotlinCommonBlock.kt | 7 +++++-- .../ArgumentListNormalIndent.after.kt | 7 +++++++ .../ArgumentListNormalIndent.kt | 5 +++++ .../TypingIndentationTestBaseGenerated.java | 21 +++++++------------ 4 files changed, 25 insertions(+), 15 deletions(-) create mode 100644 idea/testData/indentationOnNewline/ArgumentListNormalIndent.after.kt create mode 100644 idea/testData/indentationOnNewline/ArgumentListNormalIndent.kt 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 8a1bf60b2dc..492961c4200 100644 --- a/idea/formatter/src/org/jetbrains/kotlin/idea/formatter/KotlinCommonBlock.kt +++ b/idea/formatter/src/org/jetbrains/kotlin/idea/formatter/KotlinCommonBlock.kt @@ -262,10 +262,13 @@ abstract class KotlinCommonBlock( ChildAttributes(block.indent, block.alignment) } else { val indent = - if (type == KtNodeTypes.VALUE_PARAMETER_LIST && !settings.kotlinCustomSettings.CONTINUATION_INDENT_IN_PARAMETER_LISTS) + if ((type == KtNodeTypes.VALUE_PARAMETER_LIST && !settings.kotlinCustomSettings.CONTINUATION_INDENT_IN_PARAMETER_LISTS) || + (type == KtNodeTypes.VALUE_ARGUMENT_LIST && !settings.kotlinCustomSettings.CONTINUATION_INDENT_IN_ARGUMENT_LISTS) + ) { Indent.getNormalIndent() - else + } else { Indent.getContinuationIndent() + } ChildAttributes(indent, null) } } diff --git a/idea/testData/indentationOnNewline/ArgumentListNormalIndent.after.kt b/idea/testData/indentationOnNewline/ArgumentListNormalIndent.after.kt new file mode 100644 index 00000000000..da79d7642b7 --- /dev/null +++ b/idea/testData/indentationOnNewline/ArgumentListNormalIndent.after.kt @@ -0,0 +1,7 @@ +fun test(i: Int) { + test( + + ) +} + +// SET_FALSE: CONTINUATION_INDENT_IN_ARGUMENT_LISTS diff --git a/idea/testData/indentationOnNewline/ArgumentListNormalIndent.kt b/idea/testData/indentationOnNewline/ArgumentListNormalIndent.kt new file mode 100644 index 00000000000..f52759dab3b --- /dev/null +++ b/idea/testData/indentationOnNewline/ArgumentListNormalIndent.kt @@ -0,0 +1,5 @@ +fun test(i: Int) { + test() +} + +// SET_FALSE: CONTINUATION_INDENT_IN_ARGUMENT_LISTS diff --git a/idea/tests/org/jetbrains/kotlin/formatter/TypingIndentationTestBaseGenerated.java b/idea/tests/org/jetbrains/kotlin/formatter/TypingIndentationTestBaseGenerated.java index 7715db450a9..dbb565e8b7a 100644 --- a/idea/tests/org/jetbrains/kotlin/formatter/TypingIndentationTestBaseGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/formatter/TypingIndentationTestBaseGenerated.java @@ -1,17 +1,6 @@ /* - * Copyright 2010-2017 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license + * that can be found in the license/LICENSE.txt file. */ package org.jetbrains.kotlin.formatter; @@ -74,6 +63,12 @@ public class TypingIndentationTestBaseGenerated extends AbstractTypingIndentatio doNewlineTest(fileName); } + @TestMetadata("ArgumentListNormalIndent.after.kt") + public void testArgumentListNormalIndent() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/indentationOnNewline/ArgumentListNormalIndent.after.kt"); + doNewlineTest(fileName); + } + @TestMetadata("AssignmentAfterEq.after.kt") public void testAssignmentAfterEq() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("idea/testData/indentationOnNewline/AssignmentAfterEq.after.kt");