Skip to content
This repository was archived by the owner on May 12, 2025. It is now read-only.

Commit 4adb5a4

Browse files
committed
Fix formatting of generic type parameters
1 parent 68634ee commit 4adb5a4

File tree

3 files changed

+7
-9
lines changed

3 files changed

+7
-9
lines changed

src/main/java/org/openrewrite/kotlin/format/SpacesVisitor.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -212,12 +212,10 @@ public J.ClassDeclaration visitClassDeclaration(J.ClassDeclaration classDecl, P
212212
}
213213
}
214214
}
215-
// Defaulted to `true` in IntelliJ's Kotlin formatting.
216-
boolean beforeTypeParameterLeftAngleBracket = true;
217215
if (c.getPadding().getTypeParameters() != null) {
218216
c = c.getPadding().withTypeParameters(
219217
spaceBefore(c.getPadding().getTypeParameters(),
220-
beforeTypeParameterLeftAngleBracket, true)
218+
false, true)
221219
);
222220
}
223221
if (c.getPadding().getTypeParameters() != null) {

src/test/java/org/openrewrite/kotlin/format/AutoFormatVisitorTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ fun expressionBodyMethod() =
173173
"abc"
174174
}
175175
176-
class AnotherClass <T : Any> : Some()
176+
class AnotherClass<T : Any> : Some()
177177
"""
178178
)
179179
);

src/test/java/org/openrewrite/kotlin/format/SpacesTest.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ fun parseValue(input: Any) {
7575
}
7676

7777
@Nested
78-
class beforeParensTest {
78+
class BeforeParens {
7979
@DocumentExample
8080
@Test
8181
void beforeParensMethodDeclaration() {
@@ -405,7 +405,7 @@ fun foo() {
405405
}
406406

407407
@Nested
408-
class aroundOperatorsTest {
408+
class AroundOperators {
409409
@Test
410410
void aroundOperatorsAssignmentFalse() {
411411
rewriteRun(
@@ -1292,7 +1292,7 @@ void whereClause() {
12921292
class Test<T> where T: Comparable<T>, T: CharSequence
12931293
""",
12941294
"""
1295-
class Test <T> where T : Comparable<T>, T : CharSequence
1295+
class Test<T> where T : Comparable<T>, T : CharSequence
12961296
"""
12971297
)
12981298
);
@@ -2638,7 +2638,7 @@ class Test< T, U > {
26382638
"""
26392639
import java.util.ArrayList
26402640
2641-
class Test <T, U> {
2641+
class Test<T, U> {
26422642
fun <T2 : T> foo(): T2? {
26432643
val myList: List<T2> = ArrayList()
26442644
return null
@@ -2713,7 +2713,7 @@ class Test <T> {
27132713
}
27142714
""",
27152715
"""
2716-
class Test <T> {
2716+
class Test<T> {
27172717
}
27182718
"""
27192719
)

0 commit comments

Comments
 (0)