Moritz Petersen
Moritz Petersen

Reputation: 13057

google-java-format IntelliJ IDEA not formatting (Java 19)

I have OpenJDK 19 installed and use the "google-java-format" plugin. I have configured IntelliJ IDEA as per instructions here. However, code formatting doesn't work.

If I uninstall the plugin, formatting works (i.e. the cmd-opt-L shortcut works). But when I enable the plugin, then the cmd-opt-L shortcut doesn't work and inserted code fragments look crap.

Also, the notifications window always reminds me to configure the IDE properly, following the instructions above. Well, I did configure the IDE accordingly. Still I see the notifications and formatting doesn't work.

What could be wrong?

Upvotes: 1

Views: 4552

Answers (1)

Moritz Petersen
Moritz Petersen

Reputation: 13057

It seems like I didn't copy all configs correctly; not sure what exactly was missing, but I think it was --add-exports=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED ; probably that wasn't needed in earlier versions of the plugin?

--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED
--add-exports=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED
--add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED
--add-exports=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED
--add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED
--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED

Upvotes: 2

Related Questions