google / google-java-format

Reformats Java source code to comply with Google Java Style.
Other
5.58k stars 855 forks source link

Fix #1132 Load services outside of constructors and class initializers #1142

Closed copybara-service[bot] closed 1 month ago

copybara-service[bot] commented 1 month ago

Fix #1132 Load services outside of constructors and class initializers

Fixes the error on startup by loading the service when needed and not when the class is initializing. IntelliJ docs on this, https://plugins.jetbrains.com/docs/intellij/plugin-services.html#retrieving-a-service.

Tested locally with IntelliJ versions 2021.3 and 2024.2.

1134 has bug #1132 tagged, but I don't think it does anything to resolve the issue in it's current state. (I do agree that getting on the newer IntelliJ tooling is beneficial though, it offers inspections that catches issues like this.)

Fixes #1132.

Fixes #1138

FUTURE_COPYBARA_INTEGRATE_REVIEW=https://github.com/google/google-java-format/pull/1138 from nrayburn-tech:fix/1132 5866980075b52167834dfd9d2e25a739b3f06760