[pretty][jdk25] Pretty printer now supports module imports; also: test that confirms this.

This commit is contained in:
Reinier Zwitserloot committed 2025-08-01 00:58:01 +02:00
1 parent c2ed29308d
commit 70ac222e64
3 files changed
+19

No files matched your search

@@ -514,6 +514,14 @@ public class PrettyPrinter extends JCTree.Visitor {
println(";", tree);
}
void printModuleImport(JCTree tree) {
JCExpression qualid = readObject(tree, "module", null);
aPrint("import module ");
print(qualid);
println(";", tree);
}
private Name currentTypeName;
@Override public void visitClassDef(JCClassDecl tree) {
println();
@@ -1710,6 +1718,8 @@ public class PrettyPrinter extends JCTree.Visitor {
printRecordPattern(tree);
} else if (className.endsWith("$JCAnyPattern")) { // Introduced in JDK22
print("_");
} else if (className.endsWith("$JCModuleImport")) { // Introduced in JDK25
printModuleImport(tree);
} else {
throw new AssertionError("Unhandled tree type: " + tree.getClass() + ": " + tree);
}
@@ -0,0 +1,4 @@
import module java.base;
public class ModuleImport {
}
@@ -0,0 +1,5 @@
// version 25:
import module java.base;
public class ModuleImport {}