Skip to content

Commit

Permalink
Add dedicated JavaPrinter#printStatementTerminator() (openrewrite#4271
Browse files Browse the repository at this point in the history
)

`visitStatement()` now also calls `visitMarkers()` for the markers on the `JRightPadded` object.
  • Loading branch information
knutwannheden authored and Samuel Cox committed Jun 29, 2024
1 parent 241eba4 commit c7f09af
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -387,8 +387,11 @@ protected void visitStatement(@Nullable JRightPadded<Statement> paddedStat, JRig

visit(paddedStat.getElement(), p);
visitSpace(paddedStat.getAfter(), location.getAfterLocation(), p);
printStatementTerminator(paddedStat.getElement(), p);
visitMarkers(paddedStat.getMarkers(), p);
}

Statement s = paddedStat.getElement();
protected void printStatementTerminator(Statement s, PrintOutputCapture<P> p) {
while (true) {
if (s instanceof Assert ||
s instanceof Assignment ||
Expand Down Expand Up @@ -427,9 +430,9 @@ protected void visitStatement(@Nullable JRightPadded<Statement> paddedStat, JRig
c == Cursor.ROOT_VALUE
)
.getValue();
if (aSwitch instanceof J.SwitchExpression) {
if (aSwitch instanceof SwitchExpression) {
Case aCase = getCursor().getValue();
if (!(aCase.getBody() instanceof J.Block)) {
if (!(aCase.getBody() instanceof Block)) {
p.append(';');
}
return;
Expand Down

0 comments on commit c7f09af

Please sign in to comment.