Skip to content

Commit 4bb23d8

Browse files
knutwannhedentimtebeekgithub-actions[bot]
authored
Java: Fix formatting of try-with-resources (#5649)
* Java: Fix formatting of try-with-resources Issues: - openrewrite/rewrite-static-analysis#599 * Update rewrite-java/src/main/java/org/openrewrite/java/format/ColumnPositionCalculator.java Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --------- Co-authored-by: Tim te Beek <[email protected]> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
1 parent b1971ff commit 4bb23d8

File tree

6 files changed

+256
-91
lines changed

6 files changed

+256
-91
lines changed

rewrite-groovy/src/main/java/org/openrewrite/groovy/format/AutoFormatVisitor.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
import org.openrewrite.style.Style;
2828

2929
import java.util.Optional;
30-
import java.util.function.Supplier;
3130

3231
import static org.openrewrite.java.format.AutodetectGeneralFormatStyle.autodetectGeneralFormatStyle;
3332

@@ -58,17 +57,20 @@ public J visit(@Nullable Tree tree, P p, Cursor cursor) {
5857
t = new WrappingAndBracesVisitor<>(Style.from(WrappingAndBracesStyle.class, cu, IntelliJ::wrappingAndBraces), stopAfter)
5958
.visit(t, p, cursor.fork());
6059

60+
TabsAndIndentsStyle tabsAndIndentsStyle = Style.from(TabsAndIndentsStyle.class, cu, IntelliJ::tabsAndIndents);
61+
SpacesStyle spacesStyle = Style.from(SpacesStyle.class, cu, IntelliJ::spaces);
62+
6163
t = new SpacesVisitor<>(
62-
Style.from(SpacesStyle.class, cu, IntelliJ::spaces),
64+
spacesStyle,
6365
cu.getStyle(EmptyForInitializerPadStyle.class),
6466
Style.from(EmptyForIteratorPadStyle.class, cu),
6567
stopAfter
6668
).visit(t, p, cursor.fork());
6769

68-
t = new NormalizeTabsOrSpacesVisitor<>(Style.from(TabsAndIndentsStyle.class, cu, IntelliJ::tabsAndIndents), stopAfter)
70+
t = new NormalizeTabsOrSpacesVisitor<>(tabsAndIndentsStyle, stopAfter)
6971
.visit(t, p, cursor.fork());
7072

71-
t = new TabsAndIndentsVisitor<>(Style.from(TabsAndIndentsStyle.class, cu, IntelliJ::tabsAndIndents), stopAfter)
73+
t = new TabsAndIndentsVisitor<>(tabsAndIndentsStyle, spacesStyle, stopAfter)
7274
.visit(t, p, cursor.fork());
7375

7476
t = new NormalizeLineBreaksVisitor<>(Optional.ofNullable(Style.from(GeneralFormatStyle.class, cu))

0 commit comments

Comments
 (0)