Skip to content

Commit c24960f

Browse files
cypressiousyole
authored andcommitted
Formatter: handle spaces between class name and type parameters (JetBrains#875)
Fixes #KT-12446
1 parent 33b6780 commit c24960f

File tree

4 files changed

+11
-0
lines changed

4 files changed

+11
-0
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ fun createSpacingBuilder(settings: CodeStyleSettings, builderUtil: KotlinSpacing
182182
}
183183

184184
afterInside(CONSTRUCTOR_KEYWORD, PRIMARY_CONSTRUCTOR).spaces(0)
185+
betweenInside(IDENTIFIER, TYPE_PARAMETER_LIST, CLASS).spaces(0)
185186

186187
aroundInside(DOT, DOT_QUALIFIED_EXPRESSION).spaces(0)
187188
aroundInside(SAFE_ACCESS, SAFE_ACCESS_EXPRESSION).spaces(0)
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
class TypeParameter<T> {}
2+
class TypeParameter<T>()
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
class TypeParameter < T > {}
2+
class TypeParameter < T > ()

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,12 @@ public void testClassLineBreak() throws Exception {
121121
doTest(fileName);
122122
}
123123

124+
@TestMetadata("ClassTypeParam.after.kt")
125+
public void testClassTypeParam() throws Exception {
126+
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/formatter/ClassTypeParam.after.kt");
127+
doTest(fileName);
128+
}
129+
124130
@TestMetadata("ColonSpaces.after.kt")
125131
public void testColonSpaces() throws Exception {
126132
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/formatter/ColonSpaces.after.kt");

0 commit comments

Comments
 (0)