Skip to content

Commit

Permalink
Pass all tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kunli2 committed Nov 5, 2023
1 parent dd5fc3b commit 9c4fdb8
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -2145,7 +2145,8 @@ public J visitClassBody(KtClassBody classBody, ExecutionContext data) {
if (d instanceof KtEnumEntry) {
continue;
}
list.add(padRight(convertToStatement(d.accept(this, data)), Space.EMPTY));
Statement statement = convertToStatement(d.accept(this, data));
list.add(maybeFollowingSemicolon(statement, d));
}

return new J.Block(
Expand Down Expand Up @@ -3359,6 +3360,14 @@ private <J2 extends J> JRightPadded<J2> maybeSemicolon(J2 j, KtElement element)
return padRight(j, Space.EMPTY);
}

private <J2 extends J> JRightPadded<J2> maybeFollowingSemicolon(J2 j, KtElement element) {
PsiElement maybeSemicolon = findFirstNonSpaceNextSibling(element);
if (maybeSemicolon instanceof LeafPsiElement && ((LeafPsiElement) maybeSemicolon).getElementType() == KtTokens.SEMICOLON) {
return new JRightPadded<>(j, prefix(maybeSemicolon), Markers.EMPTY.add(new Semicolon(randomId())));
}
return padRight(j, Space.EMPTY);
}

private <T> JLeftPadded<T> padLeft(Space left, T tree) {
return new JLeftPadded<>(left, tree, Markers.EMPTY);
}
Expand Down

0 comments on commit 9c4fdb8

Please sign in to comment.