Repository navigation
The IntelliJ IDEA plugin now formats inside the IDE and optimizes imports with open-java-format. The output differs from 21.0.2 in a few narrow cases, so take this release with one reformatting run, in a commit of its own.
IntelliJ IDEA plugin
Reformat Code and Optimize Imports run the formatter inside the IDE's own JVM, with no process to start, and take milliseconds where a file used to take up to a second. The IDE's Java then decides which syntax parses: Java 21 in IntelliJ IDEA 2024.2, Java 25 in 2026.3. For newer syntax, choose In a separate JVM with a newer JDK under Run the formatter in the plugin's settings, next to Native binary; a project that used the native binary keeps it.
Optimize Imports, and everything that runs it, such as Actions on Save, now removes and sorts imports as the command line does. Imports the IDE inserts follow the same layout.
Formatter
A line comment that starts with a no-break space or another Unicode space keeps it, and a long string literal under a cast, a qualified .new or a method reference no longer fails the whole file. A misplaced Unicode escape and a stray ; between imports fail with an error at their line. With the formatJavadoc option, a comment loses the <p> tags at its end, and a <div> gets no <p> in front of it.
Command line, build plugins and Eclipse
Formatting ranges leaves the imports alone and reflows long strings only in the code it rewrites, the same on the command line, in formatDiff, in Eclipse and in IntelliJ IDEA. The Maven plugin and the Spotless step now write what the command line writes, and formatDiff no longer fails on a diff larger than 64 KB.
Library
Formatter.getFormatReplacements, Input.getPositionTokenMap and SnippetFormatter.format return java.util.List and Guava's RangeMap instead of ImmutableList and ImmutableRangeMap, so code that calls them has to be compiled again.
Thanks
To Liam Miller-Cushon of google-java-format, whose three fixes are ported here, and to joaonsk203 and doomfrawen, whose pull requests to google-java-format, #1526 and #1534, proposed the two Javadoc changes.