Skip to content

Commit b560aab

Browse files
cypressiousgoodwinnk
authored andcommitted
Format spaces before enum arguments
Fixes #KT-12714
1 parent a520be5 commit b560aab

File tree

4 files changed

+18
-0
lines changed

4 files changed

+18
-0
lines changed

idea/formatter/src/org/jetbrains/kotlin/idea/formatter/kotlinSpacingRules.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,8 @@ fun createSpacingBuilder(settings: CodeStyleSettings, builderUtil: KotlinSpacing
222222
before(SEMICOLON).spaces(0)
223223
after(SEMICOLON).spaces(1)
224224

225+
beforeInside(INITIALIZER_LIST, ENUM_ENTRY).spaces(0)
226+
225227
val TYPE_COLON_ELEMENTS = TokenSet.create(PROPERTY, FUN, VALUE_PARAMETER, DESTRUCTURING_DECLARATION_ENTRY, FUNCTION_LITERAL)
226228
beforeInside(COLON, TYPE_COLON_ELEMENTS) { spaceIf(kotlinSettings.SPACE_BEFORE_TYPE_COLON) }
227229
afterInside(COLON, TYPE_COLON_ELEMENTS) { spaceIf(kotlinSettings.SPACE_AFTER_TYPE_COLON) }
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
enum class Test(val foo: Int) {
2+
One(1),
3+
Two(2),
4+
Three(3)
5+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
enum class Test(val foo: Int) {
2+
One(1),
3+
Two (2),
4+
Three (3)
5+
}

idea/tests/org/jetbrains/kotlin/formatter/FormatterTestGenerated.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,12 @@ public void testEmptyLineBetweenProperties() throws Exception {
253253
doTest(fileName);
254254
}
255255

256+
@TestMetadata("EnumArguments.after.kt")
257+
public void testEnumArguments() throws Exception {
258+
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/formatter/EnumArguments.after.kt");
259+
doTest(fileName);
260+
}
261+
256262
@TestMetadata("ForLineBreak.after.kt")
257263
public void testForLineBreak() throws Exception {
258264
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/formatter/ForLineBreak.after.kt");

0 commit comments

Comments
 (0)