From 7cbfac2605d19cc8d2b112da5a7e15c001b476fb Mon Sep 17 00:00:00 2001 From: Knut Wannheden Date: Mon, 2 Oct 2023 15:30:25 +0200 Subject: [PATCH] Use regular indent for property accessors --- .../kotlin/format/TabsAndIndentsVisitor.java | 1 + .../kotlin/format/AutoFormatVisitorTest.java | 2 +- .../kotlin/format/TabsAndIndentsTest.java | 14 ++++++++++++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/openrewrite/kotlin/format/TabsAndIndentsVisitor.java b/src/main/java/org/openrewrite/kotlin/format/TabsAndIndentsVisitor.java index 34a36c194..ea0579a36 100644 --- a/src/main/java/org/openrewrite/kotlin/format/TabsAndIndentsVisitor.java +++ b/src/main/java/org/openrewrite/kotlin/format/TabsAndIndentsVisitor.java @@ -98,6 +98,7 @@ public J preVisit(@Nullable J tree, P p) { } else if (tree instanceof J.Block && tree.getMarkers().findFirst(SingleExpressionBlock.class).isPresent()) { getCursor().putMessage("indentType", wrappingStyle.getExpressionBodyFunctions().getUseContinuationIndent() ? IndentType.CONTINUATION_INDENT : IndentType.INDENT); } else if (tree instanceof J.Block || + tree instanceof K.Property || tree instanceof J.If || tree instanceof J.If.Else || tree instanceof J.ForLoop || diff --git a/src/test/java/org/openrewrite/kotlin/format/AutoFormatVisitorTest.java b/src/test/java/org/openrewrite/kotlin/format/AutoFormatVisitorTest.java index babd26a35..1b68fb5cc 100644 --- a/src/test/java/org/openrewrite/kotlin/format/AutoFormatVisitorTest.java +++ b/src/test/java/org/openrewrite/kotlin/format/AutoFormatVisitorTest.java @@ -238,7 +238,7 @@ void extensionProperty() { kotlin( """ val String.extension: Any - get() = "" + get() = "" """ ) ); diff --git a/src/test/java/org/openrewrite/kotlin/format/TabsAndIndentsTest.java b/src/test/java/org/openrewrite/kotlin/format/TabsAndIndentsTest.java index e462ccbc6..f1aace181 100644 --- a/src/test/java/org/openrewrite/kotlin/format/TabsAndIndentsTest.java +++ b/src/test/java/org/openrewrite/kotlin/format/TabsAndIndentsTest.java @@ -2168,4 +2168,18 @@ fun foo( ) ); } + + @Test + void propertyGetter() { + rewriteRun( + kotlin( + """ + class JavaLocation { + val bootClasspath: String + get() = "" + } + """ + ) + ); + } }