Skip to content

Commit

Permalink
Migrate off of ServiceManager.getService(..)
Browse files Browse the repository at this point in the history
  • Loading branch information
jwren committed Dec 4, 2024
1 parent dc1a47f commit 9f4929a
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 15 deletions.
7 changes: 6 additions & 1 deletion flutter-idea/src/io/flutter/FlutterUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,12 @@ public static EmbeddedBrowser embeddedBrowser(Project project) {
return null;
}

return FlutterSettings.getInstance().isEnableJcefBrowser()
FlutterSettings settings = FlutterSettings.getInstance();
if (settings == null) {
return null;
}

return settings.isEnableJcefBrowser()
? EmbeddedJcefBrowser.getInstance(project)
: EmbeddedJxBrowser.getInstance(project);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class EmbeddedBrowserEngine {
private final Engine engine;

public static EmbeddedBrowserEngine getInstance() {
return ServiceManager.getService(EmbeddedBrowserEngine.class);
return ApplicationManager.getApplication().getService(EmbeddedBrowserEngine.class);
}

public EmbeddedBrowserEngine() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
package io.flutter.module.settings;

import com.intellij.ide.browsers.BrowserLauncher;
import com.intellij.openapi.components.ServiceManager;
import com.intellij.ui.components.labels.LinkLabel;
import io.flutter.FlutterBundle;
import io.flutter.FlutterConstants;
Expand Down Expand Up @@ -36,10 +35,6 @@ public class SettingsHelpForm {
@SuppressWarnings("rawtypes")
private LinkLabel gettingStartedUrl;

public static SettingsHelpForm getInstance() {
return ServiceManager.getService(SettingsHelpForm.class);
}

public SettingsHelpForm() {
projectTypeLabel.setText(FlutterBundle.message("flutter.module.create.settings.help.project_type.label"));
projectTypeDescriptionForApp.setText(FlutterBundle.message("flutter.module.create.settings.help.project_type.description.app"));
Expand Down
4 changes: 3 additions & 1 deletion flutter-idea/src/io/flutter/settings/FlutterSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@

import com.google.common.annotations.VisibleForTesting;
import com.intellij.ide.util.PropertiesComponent;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.components.ServiceManager;
import com.intellij.openapi.util.registry.Registry;
import com.intellij.util.EventDispatcher;
import com.jetbrains.lang.dart.analyzer.DartClosingLabelManager;

import java.util.EventListener;
import java.util.Objects;

public class FlutterSettings {
private static final String reloadOnSaveKey = "io.flutter.reloadOnSave";
Expand Down Expand Up @@ -62,7 +64,7 @@ public static FlutterSettings getInstance() {
return testInstance;
}

return ServiceManager.getService(FlutterSettings.class);
return Objects.requireNonNull(ApplicationManager.getApplication()).getService(FlutterSettings.class);
}

protected static PropertiesComponent getPropertiesComponent() {
Expand Down
5 changes: 3 additions & 2 deletions flutter-idea/src/io/flutter/view/EmbeddedJcefBrowser.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

import javax.swing.*;
import java.awt.Dimension;
import java.util.Objects;

class EmbeddedJcefBrowserTab implements EmbeddedTab {
private JBCefBrowser browser;
Expand Down Expand Up @@ -48,8 +49,8 @@ public EmbeddedJcefBrowser(Project project) {
}

@NotNull
public static EmbeddedJcefBrowser getInstance(Project project) {
return ServiceManager.getService(project, EmbeddedJcefBrowser.class);
public static EmbeddedJcefBrowser getInstance(@NotNull Project project) {
return Objects.requireNonNull(project.getService(EmbeddedJcefBrowser.class));
}

public Logger logger() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,7 @@
import java.lang.reflect.Method;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.*;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.function.Function;
import java.util.stream.Collectors;
Expand Down Expand Up @@ -263,7 +260,7 @@ private static boolean shouldIncludeRoot(String path) {

@NotNull
public static AndroidModuleLibraryManager getInstance(@NotNull final Project project) {
return ServiceManager.getService(project, AndroidModuleLibraryManager.class);
return Objects.requireNonNull(project.getService(AndroidModuleLibraryManager.class));
}

public static void startWatching(@NotNull Project project) {
Expand Down

0 comments on commit 9f4929a

Please sign in to comment.