diff --git a/idea/formatter/src/org/jetbrains/kotlin/idea/core/formatter/KotlinCodeStyleSettings.java b/idea/formatter/src/org/jetbrains/kotlin/idea/core/formatter/KotlinCodeStyleSettings.java index 1e3002fdb6e..8cf64f1f74e 100644 --- a/idea/formatter/src/org/jetbrains/kotlin/idea/core/formatter/KotlinCodeStyleSettings.java +++ b/idea/formatter/src/org/jetbrains/kotlin/idea/core/formatter/KotlinCodeStyleSettings.java @@ -43,6 +43,7 @@ public class KotlinCodeStyleSettings extends CustomCodeStyleSettings { public boolean CONTINUATION_INDENT_IN_PARAMETER_LISTS = true; public boolean CONTINUATION_INDENT_FOR_EXPRESSION_BODIES = true; public boolean CONTINUATION_INDENT_FOR_CHAINED_CALLS = true; + public boolean CONTINUATION_INDENT_IN_SUPERTYPE_LISTS = true; public int BLANK_LINES_AROUND_BLOCK_WHEN_BRANCHES = 0; public KotlinCodeStyleSettings(CodeStyleSettings container) { 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 f134116c2b9..ec226f7c4fb 100644 --- a/idea/formatter/src/org/jetbrains/kotlin/idea/formatter/KotlinCommonBlock.kt +++ b/idea/formatter/src/org/jetbrains/kotlin/idea/formatter/KotlinCommonBlock.kt @@ -494,7 +494,12 @@ private val INDENT_RULES = arrayOf( strategy("Delegation list") .within(KtNodeTypes.SUPER_TYPE_LIST, KtNodeTypes.INITIALIZER_LIST) - .set(Indent.getContinuationIndent(false)), + .set { settings -> + if (settings.kotlinSettings.CONTINUATION_INDENT_IN_SUPERTYPE_LISTS) + Indent.getContinuationIndent(false) + else + Indent.getNormalIndent() + }, strategy("Indices") .within(KtNodeTypes.INDICES) diff --git a/idea/src/org/jetbrains/kotlin/idea/formatter/KotlinLanguageCodeStyleSettingsProvider.kt b/idea/src/org/jetbrains/kotlin/idea/formatter/KotlinLanguageCodeStyleSettingsProvider.kt index 3e69b397f4a..9399a36922c 100644 --- a/idea/src/org/jetbrains/kotlin/idea/formatter/KotlinLanguageCodeStyleSettingsProvider.kt +++ b/idea/src/org/jetbrains/kotlin/idea/formatter/KotlinLanguageCodeStyleSettingsProvider.kt @@ -258,6 +258,11 @@ class KotlinLanguageCodeStyleSettingsProvider : LanguageCodeStyleSettingsProvide showCustomOption(KotlinCodeStyleSettings::LBRACE_ON_NEXT_LINE, "Put left brace on new line", CodeStyleSettingsCustomizable.WRAPPING_BRACES) + + showCustomOption( + KotlinCodeStyleSettings::CONTINUATION_INDENT_IN_SUPERTYPE_LISTS, + "Use continuation indent", + CodeStyleSettingsCustomizable.WRAPPING_EXTENDS_LIST) } LanguageCodeStyleSettingsProvider.SettingsType.BLANK_LINES_SETTINGS -> { consumer.showStandardOptions( diff --git a/idea/testData/formatter/ContinuationIndentInSupertypeLists.after.kt b/idea/testData/formatter/ContinuationIndentInSupertypeLists.after.kt new file mode 100644 index 00000000000..726639ca3f1 --- /dev/null +++ b/idea/testData/formatter/ContinuationIndentInSupertypeLists.after.kt @@ -0,0 +1,5 @@ +class Foo : + Bar, + Baz + +// SET_TRUE: CONTINUATION_INDENT_IN_SUPERTYPE_LISTS diff --git a/idea/testData/formatter/ContinuationIndentInSupertypeLists.inv.kt b/idea/testData/formatter/ContinuationIndentInSupertypeLists.inv.kt new file mode 100644 index 00000000000..732a072fcd3 --- /dev/null +++ b/idea/testData/formatter/ContinuationIndentInSupertypeLists.inv.kt @@ -0,0 +1,5 @@ +class Foo : + Bar, + Baz + +// SET_TRUE: CONTINUATION_INDENT_IN_SUPERTYPE_LISTS diff --git a/idea/testData/formatter/ContinuationIndentInSupertypeLists.kt b/idea/testData/formatter/ContinuationIndentInSupertypeLists.kt new file mode 100644 index 00000000000..7b33344fd0d --- /dev/null +++ b/idea/testData/formatter/ContinuationIndentInSupertypeLists.kt @@ -0,0 +1,5 @@ +class Foo : +Bar, +Baz + +// SET_TRUE: CONTINUATION_INDENT_IN_SUPERTYPE_LISTS diff --git a/idea/tests/org/jetbrains/kotlin/formatter/FormatterTestGenerated.java b/idea/tests/org/jetbrains/kotlin/formatter/FormatterTestGenerated.java index 23e62d8fad5..d6d95443524 100644 --- a/idea/tests/org/jetbrains/kotlin/formatter/FormatterTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/formatter/FormatterTestGenerated.java @@ -218,6 +218,12 @@ public class FormatterTestGenerated extends AbstractFormatterTest { doTest(fileName); } + @TestMetadata("ContinuationIndentInSupertypeLists.after.kt") + public void testContinuationIndentInSupertypeLists() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/formatter/ContinuationIndentInSupertypeLists.after.kt"); + doTest(fileName); + } + @TestMetadata("CurlyBraceStringInterpolation.after.kt") public void testCurlyBraceStringInterpolation() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("idea/testData/formatter/CurlyBraceStringInterpolation.after.kt");