Skip to content

Commit

Permalink
Fix #1132 Load services outside of constructors and class initializers
Browse files Browse the repository at this point in the history
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=#1138 from nrayburn-tech:fix/1132 5866980
PiperOrigin-RevId: 665849974
  • Loading branch information
nrayburn-tech authored and google-java-format Team committed Aug 21, 2024
1 parent ebf9b52 commit e7306c1
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@
final class InitialConfigurationStartupActivity implements StartupActivity.Background {

private static final String NOTIFICATION_TITLE = "Enable google-java-format";
private static final NotificationGroup NOTIFICATION_GROUP =
NotificationGroupManager.getInstance().getNotificationGroup(NOTIFICATION_TITLE);

@Override
public void runActivity(@NotNull Project project) {
Expand All @@ -43,9 +41,11 @@ public void runActivity(@NotNull Project project) {
}

private void displayNewUserNotification(Project project, GoogleJavaFormatSettings settings) {
NotificationGroupManager groupManager = NotificationGroupManager.getInstance();
NotificationGroup group = groupManager.getNotificationGroup(NOTIFICATION_TITLE);
Notification notification =
new Notification(
NOTIFICATION_GROUP.getDisplayId(),
group.getDisplayId(),
NOTIFICATION_TITLE,
"The google-java-format plugin is disabled by default. "
+ "<a href=\"enable\">Enable for this project</a>.",
Expand Down

0 comments on commit e7306c1

Please sign in to comment.