Do not indent and align initializer list in enums (KT-28070)

#KT-28070 Fixed
This commit is contained in:
Nikolay Krasko
2018-12-06 17:56:05 +03:00
parent bbf05eaaba
commit e0d3abc819
7 changed files with 57 additions and 2 deletions
@@ -367,7 +367,7 @@ abstract class KotlinCommonBlock(
parentType in BINARY_EXPRESSIONS && getOperationType(node) in ALIGN_FOR_BINARY_OPERATIONS ->
createAlignmentStrategy(kotlinCommonSettings.ALIGN_MULTILINE_BINARY_OPERATION, getAlignment())
parentType === KtNodeTypes.SUPER_TYPE_LIST || parentType === KtNodeTypes.INITIALIZER_LIST ->
parentType === KtNodeTypes.SUPER_TYPE_LIST ->
createAlignmentStrategy(kotlinCommonSettings.ALIGN_MULTILINE_EXTENDS_LIST, getAlignment())
parentType === KtNodeTypes.PARENTHESIZED ->
@@ -765,7 +765,7 @@ private val INDENT_RULES = arrayOf(
.set(Indent.getNormalIndent(false)),
strategy("Delegation list")
.within(KtNodeTypes.SUPER_TYPE_LIST, KtNodeTypes.INITIALIZER_LIST)
.within(KtNodeTypes.SUPER_TYPE_LIST)
.continuationIf(KotlinCodeStyleSettings::CONTINUATION_INDENT_IN_SUPERTYPE_LISTS, indentFirst = true),
strategy("Indices")
+8
View File
@@ -0,0 +1,8 @@
package test
enum class EnumTest(val value: Int) {
VALUE_1
(
value = 0
)
}
+8
View File
@@ -0,0 +1,8 @@
package test
enum class EnumTest(val value: Int) {
VALUE_1
(
value = 0
)
}
@@ -0,0 +1,8 @@
// SET_TRUE: ALIGN_MULTILINE_EXTENDS_LIST
enum class EnumTest(val value: Int) {
VALUE_1(
value = 0
)
}
+8
View File
@@ -0,0 +1,8 @@
// SET_TRUE: ALIGN_MULTILINE_EXTENDS_LIST
enum class EnumTest(val value: Int) {
VALUE_1(
value = 0
)
}
+8
View File
@@ -0,0 +1,8 @@
// SET_TRUE: ALIGN_MULTILINE_EXTENDS_LIST
enum class EnumTest(val value: Int) {
VALUE_1(
value = 0
)
}
@@ -291,6 +291,11 @@ public class FormatterTestGenerated extends AbstractFormatterTest {
runTest("idea/testData/formatter/EnumArguments.after.kt");
}
@TestMetadata("EnumInitializerList.after.kt")
public void testEnumInitializerList() throws Exception {
runTest("idea/testData/formatter/EnumInitializerList.after.kt");
}
@TestMetadata("EnumWrapping.after.kt")
public void testEnumWrapping() throws Exception {
runTest("idea/testData/formatter/EnumWrapping.after.kt");
@@ -301,6 +306,11 @@ public class FormatterTestGenerated extends AbstractFormatterTest {
runTest("idea/testData/formatter/ExpressionBodyWrap.after.kt");
}
@TestMetadata("ExtendsListAlignEnum.after.kt")
public void testExtendsListAlignEnum() throws Exception {
runTest("idea/testData/formatter/ExtendsListAlignEnum.after.kt");
}
@TestMetadata("ExtendsListWrap.after.kt")
public void testExtendsListWrap() throws Exception {
runTest("idea/testData/formatter/ExtendsListWrap.after.kt");
@@ -1186,6 +1196,11 @@ public class FormatterTestGenerated extends AbstractFormatterTest {
runTest("idea/testData/formatter/EmptyLineBetweenEnumEntries.after.inv.kt");
}
@TestMetadata("ExtendsListAlignEnum.after.inv.kt")
public void testExtendsListAlignEnum() throws Exception {
runTest("idea/testData/formatter/ExtendsListAlignEnum.after.inv.kt");
}
@TestMetadata("ForLineBreak.after.inv.kt")
public void testForLineBreak() throws Exception {
runTest("idea/testData/formatter/ForLineBreak.after.inv.kt");