Skip to content

Commit 954d79b

Browse files
Add dedicated JavaPrinter#printStatementTerminator() (#4271)
`visitStatement()` now also calls `visitMarkers()` for the markers on the `JRightPadded` object.
1 parent 4df7f3a commit 954d79b

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

rewrite-java/src/main/java/org/openrewrite/java/JavaPrinter.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -387,8 +387,11 @@ protected void visitStatement(@Nullable JRightPadded<Statement> paddedStat, JRig
387387

388388
visit(paddedStat.getElement(), p);
389389
visitSpace(paddedStat.getAfter(), location.getAfterLocation(), p);
390+
printStatementTerminator(paddedStat.getElement(), p);
391+
visitMarkers(paddedStat.getMarkers(), p);
392+
}
390393

391-
Statement s = paddedStat.getElement();
394+
protected void printStatementTerminator(Statement s, PrintOutputCapture<P> p) {
392395
while (true) {
393396
if (s instanceof Assert ||
394397
s instanceof Assignment ||
@@ -427,9 +430,9 @@ protected void visitStatement(@Nullable JRightPadded<Statement> paddedStat, JRig
427430
c == Cursor.ROOT_VALUE
428431
)
429432
.getValue();
430-
if (aSwitch instanceof J.SwitchExpression) {
433+
if (aSwitch instanceof SwitchExpression) {
431434
Case aCase = getCursor().getValue();
432-
if (!(aCase.getBody() instanceof J.Block)) {
435+
if (!(aCase.getBody() instanceof Block)) {
433436
p.append(';');
434437
}
435438
return;

0 commit comments

Comments
 (0)