From c436bdaefe640abf507a0b76c922d3a2072d7b63 Mon Sep 17 00:00:00 2001 From: Jaime Wren Date: Tue, 17 Dec 2024 14:02:14 -0800 Subject: [PATCH] Migrate from deprecated method: ProjectTopics.X to ModuleListener.X (#7869) https://github.com/flutter/flutter-intellij/issues/7718 https://github.com/JetBrains/intellij-community/blob/ab4c7fdf3cc2887d44d081681ec642843adfff6d/platform/projectModel-api/src/com/intellij/ProjectTopics.java#L12 --- flutter-idea/src/io/flutter/FlutterInitializer.java | 3 +-- flutter-idea/src/io/flutter/project/ProjectWatch.java | 3 +-- .../src/io/flutter/sdk/FlutterPluginsLibraryManager.java | 3 +-- .../src/io/flutter/android/AndroidModuleLibraryManager.java | 4 +--- flutter-studio/src/io/flutter/utils/AddToAppUtils.java | 3 +-- 5 files changed, 5 insertions(+), 11 deletions(-) diff --git a/flutter-idea/src/io/flutter/FlutterInitializer.java b/flutter-idea/src/io/flutter/FlutterInitializer.java index 73c609bb8e..ede9c45678 100644 --- a/flutter-idea/src/io/flutter/FlutterInitializer.java +++ b/flutter-idea/src/io/flutter/FlutterInitializer.java @@ -7,7 +7,6 @@ import com.google.gson.JsonObject; import com.google.gson.JsonPrimitive; -import com.intellij.ProjectTopics; import com.intellij.ide.plugins.PluginManagerCore; import com.intellij.ide.ui.UISettingsListener; import com.intellij.notification.*; @@ -122,7 +121,7 @@ public void runActivity(@NotNull Project project) { initializeToolWindows(project); } else { - project.getMessageBus().connect().subscribe(ProjectTopics.MODULES, new ModuleListener() { + project.getMessageBus().connect().subscribe(ModuleListener.TOPIC, new ModuleListener() { @Override public void moduleAdded(@NotNull Project project, @NotNull Module module) { if (!toolWindowsInitialized && FlutterModuleUtils.isFlutterModule(module)) { diff --git a/flutter-idea/src/io/flutter/project/ProjectWatch.java b/flutter-idea/src/io/flutter/project/ProjectWatch.java index 7e977f87ed..a091c229ff 100644 --- a/flutter-idea/src/io/flutter/project/ProjectWatch.java +++ b/flutter-idea/src/io/flutter/project/ProjectWatch.java @@ -5,7 +5,6 @@ */ package io.flutter.project; -import com.intellij.ProjectTopics; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.project.Project; import com.intellij.openapi.project.ProjectManager; @@ -44,7 +43,7 @@ public void projectClosed(@NotNull Project project) { manager.addProjectManagerListener(project, listener); final MessageBusConnection bus = project.getMessageBus().connect(); - bus.subscribe(ProjectTopics.PROJECT_ROOTS, new ModuleRootListener() { + bus.subscribe(ModuleRootListener.TOPIC, new ModuleRootListener() { @Override public void rootsChanged(@NotNull ModuleRootEvent event) { fireEvent(); diff --git a/flutter-idea/src/io/flutter/sdk/FlutterPluginsLibraryManager.java b/flutter-idea/src/io/flutter/sdk/FlutterPluginsLibraryManager.java index e6c7c64269..6b9758767b 100644 --- a/flutter-idea/src/io/flutter/sdk/FlutterPluginsLibraryManager.java +++ b/flutter-idea/src/io/flutter/sdk/FlutterPluginsLibraryManager.java @@ -5,7 +5,6 @@ */ package io.flutter.sdk; -import com.intellij.ProjectTopics; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.application.ModalityState; import com.intellij.openapi.project.DumbService; @@ -51,7 +50,7 @@ protected void onBeforeFileChange(@NotNull VirtualFile file) { } }, getProject()); - getProject().getMessageBus().connect().subscribe(ProjectTopics.PROJECT_ROOTS, new ModuleRootListener() { + getProject().getMessageBus().connect().subscribe(ModuleRootListener.TOPIC, new ModuleRootListener() { @Override public void rootsChanged(@NotNull ModuleRootEvent event) { scheduleUpdate(); diff --git a/flutter-studio/src/io/flutter/android/AndroidModuleLibraryManager.java b/flutter-studio/src/io/flutter/android/AndroidModuleLibraryManager.java index 4e710bb4db..a28ee71a9d 100644 --- a/flutter-studio/src/io/flutter/android/AndroidModuleLibraryManager.java +++ b/flutter-studio/src/io/flutter/android/AndroidModuleLibraryManager.java @@ -12,7 +12,6 @@ import com.android.tools.idea.gradle.project.sync.GradleSyncInvoker; import com.android.tools.idea.gradle.project.sync.GradleSyncListener; -import com.intellij.ProjectTopics; import com.intellij.facet.FacetManager; import com.intellij.notification.Notification; import com.intellij.notification.NotificationType; @@ -27,7 +26,6 @@ import com.intellij.openapi.progress.ProgressIndicator; import com.intellij.openapi.project.DumbService; import com.intellij.openapi.project.Project; -//import com.intellij.openapi.project.impl.ProjectExImpl; import com.intellij.openapi.project.impl.ProjectImpl; import com.intellij.openapi.project.impl.ProjectManagerImpl; import com.intellij.openapi.projectRoots.Sdk; @@ -280,7 +278,7 @@ protected void onBeforeFileChange(@NotNull VirtualFile file) { } }, project); - project.getMessageBus().connect().subscribe(ProjectTopics.PROJECT_ROOTS, new ModuleRootListener() { + project.getMessageBus().connect().subscribe(ModuleRootListener.TOPIC, new ModuleRootListener() { @Override public void rootsChanged(@NotNull ModuleRootEvent event) { manager.scheduleUpdate(); diff --git a/flutter-studio/src/io/flutter/utils/AddToAppUtils.java b/flutter-studio/src/io/flutter/utils/AddToAppUtils.java index 95e4f541e5..86d9750f00 100644 --- a/flutter-studio/src/io/flutter/utils/AddToAppUtils.java +++ b/flutter-studio/src/io/flutter/utils/AddToAppUtils.java @@ -13,7 +13,6 @@ import com.android.tools.idea.gradle.project.sync.GradleSyncListener; import com.android.tools.idea.gradle.project.sync.GradleSyncState; -import com.intellij.ProjectTopics; import com.intellij.debugger.engine.DebugProcess; import com.intellij.debugger.engine.DebugProcessListener; import com.intellij.debugger.impl.DebuggerManagerListener; @@ -57,7 +56,7 @@ public static boolean initializeAndDetectFlutter(@NotNull Project project) { } if (!FlutterModuleUtils.hasFlutterModule(project)) { - connection.subscribe(ProjectTopics.MODULES, new ModuleListener() { + connection.subscribe(ModuleListener.TOPIC, new ModuleListener() { @Override public void moduleAdded(@NotNull Project proj, @NotNull Module mod) { if (AndroidUtils.FLUTTER_MODULE_NAME.equals(mod.getName()) ||