diff --git a/rewrite-java-test/src/test/java/org/openrewrite/java/style/AutodetectTest.java b/rewrite-java-test/src/test/java/org/openrewrite/java/style/AutodetectTest.java index 1241cea4fdc..b4504cc1280 100644 --- a/rewrite-java-test/src/test/java/org/openrewrite/java/style/AutodetectTest.java +++ b/rewrite-java-test/src/test/java/org/openrewrite/java/style/AutodetectTest.java @@ -57,6 +57,28 @@ boolean eq(){ assertThat(tabsAndIndents.getContinuationIndent()).isEqualTo(8); } + @Test + @Issue("https://github.com/openrewrite/rewrite/issues/3552") + void continuationIndentFromParameters() { + var cus = jp().parse( + """ + class Test { + void foo(String s1, + String s2, + String s3) { + } + } + """ + ); + + var detector = Autodetect.detector(); + cus.forEach(detector::sample); + var styles = detector.build(); + var tabsAndIndents = NamedStyles.merge(TabsAndIndentsStyle.class, singletonList(styles)); + + assertThat(tabsAndIndents.getContinuationIndent()).isEqualTo(5); + } + @Test @Issue("https://github.com/openrewrite/rewrite/issues/3550") void alignParametersWhenMultiple() { diff --git a/rewrite-java/src/main/java/org/openrewrite/java/style/Autodetect.java b/rewrite-java/src/main/java/org/openrewrite/java/style/Autodetect.java index 1bcde8d64a1..e68f2ce229b 100644 --- a/rewrite-java/src/main/java/org/openrewrite/java/style/Autodetect.java +++ b/rewrite-java/src/main/java/org/openrewrite/java/style/Autodetect.java @@ -347,6 +347,7 @@ public J.MethodDeclaration visitMethodDeclaration(J.MethodDeclaration method, In stats.multilineAlignedToFirstArgument++; } else { stats.multilineNotAlignedToFirstArgument++; + countIndents(parameters.get(i).getPrefix().getWhitespace(), true, stats); } } }