Skip to content

Commit

Permalink
fixed multiple registrations
Browse files Browse the repository at this point in the history
  • Loading branch information
LeFrosch committed Sep 19, 2024
1 parent 757dde6 commit fbe6d89
Showing 1 changed file with 15 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
public class CLionNotificationProvider implements ProjectFixesProvider, WidgetStatusProvider,
EditorNotificationWarningProvider {

private static Boolean registered = false;

private static void unregisterGenericProvider(Project project) {
final var extensionPoint = EditorNotificationProvider.EP_NAME.getPoint(project);

Expand All @@ -53,18 +55,26 @@ private static void unregisterGenericProvider(Project project) {
}
}

public static void register(Project project) {
unregisterGenericProvider(project);

private static void registerSpecificProvider() {
final var projectFixes = ProjectFixesProvider.Companion.getEP_NAME().getPoint();
projectFixes.registerExtension(new CLionNotificationProvider());
final var projectNotifications = EditorNotificationWarningProvider.Companion.getEP_NAME()
.getPoint();

final var projectNotifications = EditorNotificationWarningProvider.Companion.getEP_NAME().getPoint();
projectNotifications.registerExtension(new CLionNotificationProvider());

final var widgetStatus = WidgetStatusProvider.Companion.getEP_NAME().getPoint();
widgetStatus.registerExtension(new CLionNotificationProvider());
}

public static void register(Project project) {
unregisterGenericProvider(project);

if (!registered) {
registerSpecificProvider();
}
registered = true;
}

@NotNull
@Override
public List<AnAction> collectFixes(@NotNull Project project, @Nullable VirtualFile file,
Expand Down

0 comments on commit fbe6d89

Please sign in to comment.