-
Notifications
You must be signed in to change notification settings - Fork 466
Java 25: Compact source files #6011
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
rewrite-java/src/main/java/org/openrewrite/java/JavaPrinter.java
Outdated
Show resolved
Hide resolved
rewrite-java/src/main/java/org/openrewrite/java/JavaPrinter.java
Outdated
Show resolved
Hide resolved
rewrite-java/src/main/java/org/openrewrite/java/JavaPrinter.java
Outdated
Show resolved
Hide resolved
public class CompactSourceFile implements Marker { | ||
UUID id; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Had a brief look at Kotlin (perhaps you did as well); for context there we seem to use an OmitBraces
marker:
rewrite/rewrite-kotlin/src/main/java/org/openrewrite/kotlin/internal/KotlinPrinter.java
Lines 602 to 605 in a76af30
boolean omitBraces = block.getMarkers().findFirst(OmitBraces.class).isPresent(); | |
if (!omitBraces) { | |
p.append("{"); | |
} |
I wonder if it makes sense to copy that marker here and deprecate the old one, as opposed to using CompactSourceFile
in both printing the compilation unit as well as printing the class declaration.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that makes a whole lot of sense, in retrospect I knew this existed but hadn't considered using this concept separately from the CompactSourceFile
marker. I applied this to the PR instead of overloading the visitBlock
in the Java printer!
rewrite-java/src/main/java/org/openrewrite/java/JavaPrinter.java
Outdated
Show resolved
Hide resolved
rewrite-java/src/main/java/org/openrewrite/java/JavaPrinter.java
Outdated
Show resolved
Hide resolved
rewrite-kotlin/src/main/java/org/openrewrite/kotlin/marker/OmitBraces.java
Show resolved
Hide resolved
rewrite-java/src/main/java/org/openrewrite/java/marker/PackageOnCompactSourceFile.java
Outdated
Show resolved
Hide resolved
…itors to consider both java and kotlin version of `OmitBraces`
What's changed?
Allow parser to parse compact source files
What's your motivation?
Java 25 coming out next week
Any additional context
https://openjdk.org/jeps/512
Checklist