Skip to content

Commit a520be5

Browse files
cypressiousgoodwinnk
authored andcommitted
Format spaces around semicolon
Fixes #KT-12689
1 parent db387bd commit a520be5

File tree

4 files changed

+15
-0
lines changed

4 files changed

+15
-0
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,9 @@ fun createSpacingBuilder(settings: CodeStyleSettings, builderUtil: KotlinSpacing
219219

220220
afterInside(ANNOTATION_ENTRY, ANNOTATED_EXPRESSION).spaces(1)
221221

222+
before(SEMICOLON).spaces(0)
223+
after(SEMICOLON).spaces(1)
224+
222225
val TYPE_COLON_ELEMENTS = TokenSet.create(PROPERTY, FUN, VALUE_PARAMETER, DESTRUCTURING_DECLARATION_ENTRY, FUNCTION_LITERAL)
223226
beforeInside(COLON, TYPE_COLON_ELEMENTS) { spaceIf(kotlinSettings.SPACE_BEFORE_TYPE_COLON) }
224227
afterInside(COLON, TYPE_COLON_ELEMENTS) { spaceIf(kotlinSettings.SPACE_AFTER_TYPE_COLON) }
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
fun foo() {
2+
""; ""
3+
}

idea/testData/formatter/Semicolon.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
fun foo() {
2+
"" ; ""
3+
}

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -517,6 +517,12 @@ public void testSecondaryCtorLineBreak() throws Exception {
517517
doTest(fileName);
518518
}
519519

520+
@TestMetadata("Semicolon.after.kt")
521+
public void testSemicolon() throws Exception {
522+
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/formatter/Semicolon.after.kt");
523+
doTest(fileName);
524+
}
525+
520526
@TestMetadata("SingleLineFunctionLiteral.after.kt")
521527
public void testSingleLineFunctionLiteral() throws Exception {
522528
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/formatter/SingleLineFunctionLiteral.after.kt");

0 commit comments

Comments
 (0)