Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -453,8 +453,15 @@ protected void dropEmptyDeclarations() {
}
}

// Replace with Flags.IMPLICIT_CLASS once JDK 25 is the minimum supported version
private static final int IMPLICIT_CLASS = 1 << 19;

@Override
public Void visitClass(ClassTree tree, Void unused) {
if ((TreeInfo.flags((JCTree) tree) & IMPLICIT_CLASS) == IMPLICIT_CLASS) {
visitImplicitClass(tree);
return null;
}
switch (tree.getKind()) {
case ANNOTATION_TYPE -> visitAnnotationType(tree);
case CLASS, INTERFACE -> visitClassDeclaration(tree);
Expand All @@ -465,6 +472,12 @@ public Void visitClass(ClassTree tree, Void unused) {
return null;
}

private void visitImplicitClass(ClassTree node) {
builder.open(minusTwo);
addBodyDeclarations(node.getMembers(), BracesOrNot.NO, FirstDeclarationsOrNot.YES);
builder.close();
}

public void visitAnnotationType(ClassTree node) {
sync(node);
builder.open(ZERO);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public class FormatterIntegrationTest {
"I981",
"I1020",
"I1037")
.putAll(25, "ModuleImport")
.putAll(25, "ModuleImport", "InstanceMain")
.build();

@Parameters(name = "{index}: {0}")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
String greeting = "Hello, World!";

void main() {
System.out.println(greeting);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
String greeting = "Hello, World!";

void main() {
System.out.println(greeting);
}