diff --git a/flutter-idea/src/io/flutter/FlutterUtils.java b/flutter-idea/src/io/flutter/FlutterUtils.java index a345593157..46104f0a57 100644 --- a/flutter-idea/src/io/flutter/FlutterUtils.java +++ b/flutter-idea/src/io/flutter/FlutterUtils.java @@ -222,7 +222,7 @@ private static boolean isInTestOrSourceRoot(@Nullable Module module, @NotNull Da } public static boolean isIntegrationTestingMode() { - return System.getProperty("idea.required.plugins.id", "").equals("io.flutter.tests.gui.flutter-gui-tests"); + return Objects.equals(System.getProperty("idea.required.plugins.id", ""), "io.flutter.tests.gui.flutter-gui-tests"); } @Nullable @@ -561,7 +561,7 @@ public static EmbeddedBrowser embeddedBrowser(Project project) { } public static boolean embeddedBrowserAvailable(JxBrowserStatus status) { - return status.equals(JxBrowserStatus.INSTALLED) || status.equals(JxBrowserStatus.INSTALLATION_SKIPPED) && FlutterSettings.getInstance() + return Objects.equals(status, JxBrowserStatus.INSTALLED) || status.equals(JxBrowserStatus.INSTALLATION_SKIPPED) && FlutterSettings.getInstance() .isEnableJcefBrowser(); } } diff --git a/flutter-idea/src/io/flutter/android/IntelliJAndroidSdk.java b/flutter-idea/src/io/flutter/android/IntelliJAndroidSdk.java index faecc9f206..0d427ea77f 100644 --- a/flutter-idea/src/io/flutter/android/IntelliJAndroidSdk.java +++ b/flutter-idea/src/io/flutter/android/IntelliJAndroidSdk.java @@ -20,6 +20,7 @@ import java.util.ArrayList; import java.util.List; +import java.util.Objects; /** * An Android SDK and its home directory; this references an IntelliJ @{@link Sdk} instance. @@ -90,7 +91,7 @@ public static IntelliJAndroidSdk fromEnvironment() { @Nullable public static IntelliJAndroidSdk fromHome(VirtualFile file) { for (IntelliJAndroidSdk candidate : findAll()) { - if (file.equals(candidate.getHome())) { + if (Objects.equals(file, candidate.getHome())) { return candidate; } } diff --git a/flutter-idea/src/io/flutter/console/FlutterConsoleFilter.java b/flutter-idea/src/io/flutter/console/FlutterConsoleFilter.java index 15379fe440..5baab54f40 100644 --- a/flutter-idea/src/io/flutter/console/FlutterConsoleFilter.java +++ b/flutter-idea/src/io/flutter/console/FlutterConsoleFilter.java @@ -30,6 +30,7 @@ import org.jetbrains.annotations.Nullable; import java.awt.*; +import java.util.Objects; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -170,7 +171,7 @@ public Result applyFilter(final String line, final int entireLength) { highlightLength = pathPart.length(); break; } - else if (split.length == 4 && split[0].equals("file")) { + else if (split.length == 4 && Objects.equals(split[0], "file")) { // part = file:///Users/user/AndroidStudioProjects/flutter_app/test/widget_test.dart:23:18 try { // Reconcile line number indexing. diff --git a/flutter-idea/src/io/flutter/dart/FlutterDartAnalysisServer.java b/flutter-idea/src/io/flutter/dart/FlutterDartAnalysisServer.java index 0ffa5185d8..d24293bf33 100644 --- a/flutter-idea/src/io/flutter/dart/FlutterDartAnalysisServer.java +++ b/flutter-idea/src/io/flutter/dart/FlutterDartAnalysisServer.java @@ -287,7 +287,7 @@ private void processResponse(JsonObject response) { private void processNotification(JsonObject response, @NotNull JsonElement eventName) { // If we add code to handle more event types below, update the filter in processString(). final String event = eventName.getAsString(); - if (event.equals(FLUTTER_NOTIFICATION_OUTLINE)) { + if (Objects.equals(event, FLUTTER_NOTIFICATION_OUTLINE)) { final JsonObject paramsObject = response.get("params").getAsJsonObject(); final String file = paramsObject.get("file").getAsString(); diff --git a/flutter-idea/src/io/flutter/editor/FlutterColorProvider.java b/flutter-idea/src/io/flutter/editor/FlutterColorProvider.java index 8382a74354..c705c81c72 100644 --- a/flutter-idea/src/io/flutter/editor/FlutterColorProvider.java +++ b/flutter-idea/src/io/flutter/editor/FlutterColorProvider.java @@ -22,6 +22,7 @@ import java.awt.*; import java.util.Arrays; import java.util.List; +import java.util.Objects; import static io.flutter.dart.DartPsiUtil.getNewExprFromType; import static io.flutter.dart.DartPsiUtil.topmostReferenceExpression; @@ -136,7 +137,7 @@ else if (parent.getNode().getElementType() == DartTokenTypes.SIMPLE_TYPE) { @Nullable private PsiElement resolveReferencedElement(@NotNull PsiElement element) { - if (element instanceof DartCallExpression && element.getFirstChild().getText().equals("Color")) { + if (element instanceof DartCallExpression && Objects.equals(element.getFirstChild().getText(), "Color")) { return element; } final PsiElement symbol = element.getLastChild(); @@ -216,7 +217,7 @@ private Color parseColorText(@NotNull String text, @NotNull String platform) { public void setColorTo(@NotNull PsiElement element, @NotNull Color color) { // Not trying to look up Material or Cupertino colors. // Unfortunately, there is no way to prevent the color picker from showing (if clicked) for those expressions. - if (!element.getText().equals("Color")) return; + if (!Objects.equals(element.getText(), "Color")) return; final Document document = PsiDocumentManager.getInstance(element.getProject()).getDocument(element.getContainingFile()); final Runnable command = () -> { final PsiElement refExpr = topmostReferenceExpression(element); diff --git a/flutter-idea/src/io/flutter/editor/OutlineLocation.java b/flutter-idea/src/io/flutter/editor/OutlineLocation.java index 6925563f88..a61b080313 100644 --- a/flutter-idea/src/io/flutter/editor/OutlineLocation.java +++ b/flutter-idea/src/io/flutter/editor/OutlineLocation.java @@ -12,6 +12,8 @@ import org.dartlang.analysis.server.protocol.FlutterOutline; import org.jetbrains.annotations.Nullable; +import java.util.Objects; + class TextRangeTracker { private final TextRange rawRange; private RangeMarker marker; @@ -96,7 +98,7 @@ public boolean isConsistentEndingWord() { // to update marker locations has hit a bad edge case as sometimes // happens when there is a large document edit due to running a // code formatter. - endingWord.equals(TextRangeTracker.getCurrentWord(marker.getDocument(), marker.getEndOffset() - 1)); + Objects.equals(endingWord, TextRangeTracker.getCurrentWord(marker.getDocument(), marker.getEndOffset() - 1)); } } diff --git a/flutter-idea/src/io/flutter/jxbrowser/EmbeddedJxBrowser.java b/flutter-idea/src/io/flutter/jxbrowser/EmbeddedJxBrowser.java index 4e07d0f6c2..3d0f292dee 100644 --- a/flutter-idea/src/io/flutter/jxbrowser/EmbeddedJxBrowser.java +++ b/flutter-idea/src/io/flutter/jxbrowser/EmbeddedJxBrowser.java @@ -160,7 +160,7 @@ private EmbeddedJxBrowser(@NotNull Project project) { } JxBrowserManager.installation.thenAccept((JxBrowserStatus status) -> { - if (status.equals(JxBrowserStatus.INSTALLED)) { + if (Objects.equals(status, JxBrowserStatus.INSTALLED)) { engineRef.compareAndSet(null, EmbeddedBrowserEngine.getInstance().getEngine()); } }); @@ -268,7 +268,7 @@ protected void handleUpdatedJxBrowserStatusOnEventThread(JxBrowserStatus jxBrows } protected void handleUpdatedJxBrowserStatus(JxBrowserStatus jxBrowserStatus, ContentManager contentManager) { - if (jxBrowserStatus.equals(JxBrowserStatus.INSTALLED)) { + if (Objects.equals(jxBrowserStatus, JxBrowserStatus.INSTALLED)) { return; } else if (jxBrowserStatus.equals(JxBrowserStatus.INSTALLATION_FAILED)) { handleJxBrowserInstallationFailed(contentManager); @@ -286,7 +286,7 @@ protected void handleJxBrowserInstallationFailed(ContentManager contentManager) if (!jxBrowserUtils.licenseIsSet()) { // If the license isn't available, allow the user to open the equivalent page in a non-embedded browser window. inputs.add(new LabelInput("The JxBrowser license could not be found.")); - } else if (latestFailureReason != null && latestFailureReason.failureType.equals(FailureType.SYSTEM_INCOMPATIBLE)) { + } else if (latestFailureReason != null && Objects.equals(latestFailureReason.failureType, FailureType.SYSTEM_INCOMPATIBLE)) { // If we know the system is incompatible, skip retry link and offer to open in browser. inputs.add(new LabelInput(latestFailureReason.detail)); } diff --git a/flutter-idea/src/io/flutter/jxbrowser/JxBrowserManager.java b/flutter-idea/src/io/flutter/jxbrowser/JxBrowserManager.java index 77f1e288be..c38a391c60 100644 --- a/flutter-idea/src/io/flutter/jxbrowser/JxBrowserManager.java +++ b/flutter-idea/src/io/flutter/jxbrowser/JxBrowserManager.java @@ -198,7 +198,7 @@ public void setUp(@NotNull String projectName) { return; } - if (!jxBrowserUtils.skipInstallation() && status.get().equals(JxBrowserStatus.INSTALLATION_SKIPPED)) { + if (!jxBrowserUtils.skipInstallation() && Objects.equals(status.get(), JxBrowserStatus.INSTALLATION_SKIPPED)) { // This check returns status to NOT_INSTALLED so that JxBrowser can be downloaded and installed in cases where it is enabled after being disabled. status.compareAndSet(JxBrowserStatus.INSTALLATION_SKIPPED, JxBrowserStatus.NOT_INSTALLED); } diff --git a/flutter-idea/src/io/flutter/logging/DiagnosticsNode.java b/flutter-idea/src/io/flutter/logging/DiagnosticsNode.java index 44ff7d7eda..b4fcbb4ed7 100644 --- a/flutter-idea/src/io/flutter/logging/DiagnosticsNode.java +++ b/flutter-idea/src/io/flutter/logging/DiagnosticsNode.java @@ -26,10 +26,7 @@ import org.jetbrains.annotations.Nullable; import javax.swing.*; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.Set; +import java.util.*; import java.util.concurrent.CompletableFuture; import java.util.function.BiConsumer; @@ -81,7 +78,7 @@ public DiagnosticsNode(JsonObject json, @Override public boolean equals(Object other) { if (other instanceof DiagnosticsNode otherNode) { - return getDartDiagnosticRef().equals(otherNode.getDartDiagnosticRef()); + return Objects.equals(getDartDiagnosticRef(), otherNode.getDartDiagnosticRef()); } return false; } @@ -653,10 +650,10 @@ public boolean identicalDisplay(DiagnosticsNode node) { } for (Map.Entry entry : entries) { final String key = entry.getKey(); - if (key.equals("objectId") || key.equals("valueId")) { + if (Objects.equals(key, "objectId") || key.equals("valueId")) { continue; } - if (!entry.getValue().equals(node.json.get(key))) { + if (!Objects.equals(entry.getValue(), node.json.get(key))) { return false; } } diff --git a/flutter-idea/src/io/flutter/pub/PubRoot.java b/flutter-idea/src/io/flutter/pub/PubRoot.java index ef3e304eb3..c80dcd300c 100644 --- a/flutter-idea/src/io/flutter/pub/PubRoot.java +++ b/flutter-idea/src/io/flutter/pub/PubRoot.java @@ -26,6 +26,7 @@ import java.io.File; import java.util.List; import java.util.Map; +import java.util.Objects; /** * A snapshot of the root directory of a pub package. @@ -427,7 +428,7 @@ public boolean hasAndroidModule(Project project) { for (Module module : ModuleManager.getInstance(project).getModules()) { for (VirtualFile contentRoot : ModuleRootManager.getInstance(module).getContentRoots()) { - if (contentRoot.equals(androidDir)) { + if (Objects.equals(contentRoot, androidDir)) { return true; } } diff --git a/flutter-idea/src/io/flutter/run/bazel/FlutterBazelRunConfigurationType.java b/flutter-idea/src/io/flutter/run/bazel/FlutterBazelRunConfigurationType.java index f1ce3f0370..1598a58f9b 100644 --- a/flutter-idea/src/io/flutter/run/bazel/FlutterBazelRunConfigurationType.java +++ b/flutter-idea/src/io/flutter/run/bazel/FlutterBazelRunConfigurationType.java @@ -20,6 +20,8 @@ import io.flutter.utils.FlutterModuleUtils; import org.jetbrains.annotations.NotNull; +import java.util.Objects; + public class FlutterBazelRunConfigurationType extends ConfigurationTypeBase { @VisibleForTesting final Factory factory = new Factory(this); @@ -75,7 +77,7 @@ private boolean isNewlyGeneratedName(String name) { // This is a hack based on what the code does in RunConfigurable.createUniqueName(). // If it fails to match, the new run config still works, just without any defaults set. final String baseName = ExecutionBundle.message("run.configuration.unnamed.name.prefix"); - return name.equals(baseName) || name.startsWith(baseName + " ("); + return Objects.equals(name, baseName) || name.startsWith(baseName + " ("); } @Override diff --git a/flutter-idea/src/io/flutter/run/bazelTest/FlutterBazelTestConfigurationEditorForm.java b/flutter-idea/src/io/flutter/run/bazelTest/FlutterBazelTestConfigurationEditorForm.java index 5d74b4fd7e..6a45f472bd 100644 --- a/flutter-idea/src/io/flutter/run/bazelTest/FlutterBazelTestConfigurationEditorForm.java +++ b/flutter-idea/src/io/flutter/run/bazelTest/FlutterBazelTestConfigurationEditorForm.java @@ -21,6 +21,7 @@ import javax.swing.*; import java.awt.event.ActionEvent; +import java.util.Objects; import static io.flutter.run.bazelTest.BazelTestFields.Scope.*; @@ -163,7 +164,7 @@ private void render(Scope next) { // Because the scope of the underlying fields is calculated based on which parameters are assigned, // we remove fields that aren't part of the selected scope. - if (next.equals(Scope.TARGET_PATTERN)) { + if (Objects.equals(next, Scope.TARGET_PATTERN)) { myTestName.setText(""); myEntryFile.setText(""); } diff --git a/flutter-idea/src/io/flutter/run/common/RunMode.java b/flutter-idea/src/io/flutter/run/common/RunMode.java index 12e2a9cc7f..b0d6ee8596 100644 --- a/flutter-idea/src/io/flutter/run/common/RunMode.java +++ b/flutter-idea/src/io/flutter/run/common/RunMode.java @@ -13,6 +13,8 @@ import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; +import java.util.Objects; + /** * The IntelliJ launch mode. */ @@ -59,7 +61,7 @@ public static RunMode fromEnv(@NotNull ExecutionEnvironment env) throws Executio else if (DefaultDebugExecutor.EXECUTOR_ID.equals(mode)) { return DEBUG; } - else if (COVERAGE.myModeString.equals(mode)) { + else if (Objects.equals(COVERAGE.myModeString, mode)) { return COVERAGE; } else if (LaunchState.ANDROID_PROFILER_EXECUTOR_ID.equals(mode)) { diff --git a/flutter-idea/src/io/flutter/run/daemon/DevToolsService.java b/flutter-idea/src/io/flutter/run/daemon/DevToolsService.java index 676046ae99..ca02709bb0 100644 --- a/flutter-idea/src/io/flutter/run/daemon/DevToolsService.java +++ b/flutter-idea/src/io/flutter/run/daemon/DevToolsService.java @@ -245,7 +245,7 @@ private void tryParseStartupText(@NotNull String text) { final JsonObject obj = element.getAsJsonObject(); - if (JsonUtils.getStringMember(obj, "event").equals("server.started")) { + if (Objects.equals(JsonUtils.getStringMember(obj, "event"), "server.started")) { final JsonObject params = obj.getAsJsonObject("params"); final String host = JsonUtils.getStringMember(params, "host"); final int port = JsonUtils.getIntMember(params, "port"); diff --git a/flutter-idea/src/io/flutter/run/daemon/DeviceDaemon.java b/flutter-idea/src/io/flutter/run/daemon/DeviceDaemon.java index 5134b0ab31..f10ad518e2 100644 --- a/flutter-idea/src/io/flutter/run/daemon/DeviceDaemon.java +++ b/flutter-idea/src/io/flutter/run/daemon/DeviceDaemon.java @@ -384,7 +384,8 @@ public void onDeviceAdded(@NotNull DaemonEvent.DeviceAdded event) { final FlutterDevice newDevice = new FlutterDevice(event.id, event.emulatorId == null ? (event.name == null ? event.id : event.name) - : (event.platformType.equals("android") ? event.emulatorId : event.name), + : (java.util.Objects.equals(event.platformType, "android") + ? event.emulatorId : event.name), event.platform, event.emulator, event.category, diff --git a/flutter-idea/src/io/flutter/run/test/DartTestLocationProviderZ.java b/flutter-idea/src/io/flutter/run/test/DartTestLocationProviderZ.java index d22f82ae12..bdf5fd25a3 100644 --- a/flutter-idea/src/io/flutter/run/test/DartTestLocationProviderZ.java +++ b/flutter-idea/src/io/flutter/run/test/DartTestLocationProviderZ.java @@ -33,6 +33,7 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; +import java.util.Objects; @SuppressWarnings("Duplicates") public class DartTestLocationProviderZ implements SMTestLocator, DumbAware { @@ -123,11 +124,11 @@ protected List getLocationByGroupAndTestNames(final PsiFile psiFile, f public boolean execute(@NotNull final PsiElement element) { if (element instanceof DartCallExpression expression) { if (isTest(expression) || TestUtil.isGroup(expression)) { - if (nodes.get(nodes.size() - 1).equals(getTestLabel(expression))) { + if (Objects.equals(nodes.get(nodes.size() - 1), getTestLabel(expression))) { boolean matches = true; for (int i = nodes.size() - 2; i >= 0 && matches; --i) { expression = getGroup(expression); - if (expression == null || !nodes.get(i).equals(getTestLabel(expression))) { + if (expression == null || !Objects.equals(nodes.get(i), getTestLabel(expression))) { matches = false; } } diff --git a/flutter-idea/src/io/flutter/sdk/AndroidEmulatorManager.java b/flutter-idea/src/io/flutter/sdk/AndroidEmulatorManager.java index d24a9323a1..3abc88dbd3 100644 --- a/flutter-idea/src/io/flutter/sdk/AndroidEmulatorManager.java +++ b/flutter-idea/src/io/flutter/sdk/AndroidEmulatorManager.java @@ -105,7 +105,7 @@ private void fireChangeEvent(final List newEmulators, final Lis if (project.isDisposed()) return; // Don't fire if the list of devices is unchanged. - if (cachedEmulators.equals(newEmulators)) { + if (Objects.equals(cachedEmulators, newEmulators)) { return; } diff --git a/flutter-idea/src/io/flutter/sdk/FlutterSdk.java b/flutter-idea/src/io/flutter/sdk/FlutterSdk.java index e0e718c3d1..9317b5d97a 100644 --- a/flutter-idea/src/io/flutter/sdk/FlutterSdk.java +++ b/flutter-idea/src/io/flutter/sdk/FlutterSdk.java @@ -365,7 +365,7 @@ public FlutterCommand flutterTest(@NotNull PubRoot root, @NotNull VirtualFile fi // Starting the app paused so the IDE can catch early errors is ideal. However, we don't have a way to resume for multiple test files // yet, so we want to exclude directory scope tests from starting paused. See https://github.com/flutter/flutter-intellij/issues/4737. - if (mode == RunMode.DEBUG || (mode == RunMode.RUN && !scope.equals(TestFields.Scope.DIRECTORY))) { + if (mode == RunMode.DEBUG || (mode == RunMode.RUN && !Objects.equals(scope, TestFields.Scope.DIRECTORY))) { args.add("--start-paused"); } if (FlutterSettings.getInstance().isVerboseLogging()) { diff --git a/flutter-idea/src/io/flutter/sdk/FlutterSettingsConfigurable.java b/flutter-idea/src/io/flutter/sdk/FlutterSettingsConfigurable.java index c24b2ad116..9ccecf7064 100644 --- a/flutter-idea/src/io/flutter/sdk/FlutterSettingsConfigurable.java +++ b/flutter-idea/src/io/flutter/sdk/FlutterSettingsConfigurable.java @@ -47,6 +47,7 @@ import javax.swing.text.JTextComponent; import java.awt.datatransfer.StringSelection; import java.util.List; +import java.util.Objects; import java.util.concurrent.Semaphore; // Note: when updating the settings here, update FlutterSearchableOptionContributor as well. @@ -221,7 +222,7 @@ public boolean isModified() { return true; } - if (!settings.getFontPackages().equals(myFontPackagesTextArea.getText())) { + if (!Objects.equals(settings.getFontPackages(), myFontPackagesTextArea.getText())) { return true; } diff --git a/flutter-idea/src/io/flutter/test/DartTestEventsConverterZ.java b/flutter-idea/src/io/flutter/test/DartTestEventsConverterZ.java index f2f1be490d..d3cc0855d2 100644 --- a/flutter-idea/src/io/flutter/test/DartTestEventsConverterZ.java +++ b/flutter-idea/src/io/flutter/test/DartTestEventsConverterZ.java @@ -18,10 +18,7 @@ import java.lang.reflect.Type; import java.text.ParseException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -247,9 +244,9 @@ private static boolean shouldTestBeHiddenIfPassed(@NotNull final Test test) { final Group group = test.getParent(); return group == null && (test.getName().startsWith(LOADING_PREFIX) || test.getName().startsWith(COMPILING_PREFIX)) || - group != null && group.getDoneTestsCount() == 0 && test.getBaseName().equals(SET_UP_ALL_VIRTUAL_TEST_NAME) + group != null && group.getDoneTestsCount() == 0 && Objects.equals(test.getBaseName(), SET_UP_ALL_VIRTUAL_TEST_NAME) || - group != null && group.getDoneTestsCount() > 0 && test.getBaseName().equals(TEAR_DOWN_ALL_VIRTUAL_TEST_NAME); + group != null && group.getDoneTestsCount() > 0 && Objects.equals(test.getBaseName(), TEAR_DOWN_ALL_VIRTUAL_TEST_NAME); } private boolean handleTestDone(JsonObject obj) throws ParseException { @@ -382,7 +379,7 @@ private boolean handlePrint(JsonObject obj) throws ParseException { boolean result = true; if (!test.myTestStartReported) { - if (test.getBaseName().equals(SET_UP_ALL_VIRTUAL_TEST_NAME) || test.getBaseName().equals(TEAR_DOWN_ALL_VIRTUAL_TEST_NAME)) { + if (Objects.equals(test.getBaseName(), SET_UP_ALL_VIRTUAL_TEST_NAME) || Objects.equals(test.getBaseName(), TEAR_DOWN_ALL_VIRTUAL_TEST_NAME)) { return true; // output in successfully passing setUpAll/tearDownAll is not important enough to make these nodes visible } diff --git a/flutter-idea/src/io/flutter/view/EmbeddedBrowser.java b/flutter-idea/src/io/flutter/view/EmbeddedBrowser.java index 35766f6d72..ca90243d3c 100644 --- a/flutter-idea/src/io/flutter/view/EmbeddedBrowser.java +++ b/flutter-idea/src/io/flutter/view/EmbeddedBrowser.java @@ -25,10 +25,8 @@ import javax.swing.*; import java.awt.*; -import java.util.ArrayList; -import java.util.HashMap; +import java.util.*; import java.util.List; -import java.util.Map; import java.util.concurrent.CompletableFuture; import java.util.concurrent.atomic.AtomicBoolean; import java.util.function.Consumer; @@ -126,7 +124,7 @@ public void openPanel(ToolWindow toolWindow, String tabName, DevToolsUrl devTool tab.contentManager.removeAllContents(false); for (final String otherTabName : tabs.keySet()) { - if (otherTabName.equals(tabName)) { + if (Objects.equals(otherTabName, tabName)) { continue; } final BrowserTab browserTab = tabs.get(otherTabName); diff --git a/flutter-idea/src/io/flutter/view/FlutterView.java b/flutter-idea/src/io/flutter/view/FlutterView.java index 1cf887d1c6..9e831ba7bf 100644 --- a/flutter-idea/src/io/flutter/view/FlutterView.java +++ b/flutter-idea/src/io/flutter/view/FlutterView.java @@ -53,10 +53,8 @@ import javax.swing.*; import java.awt.*; -import java.util.ArrayList; -import java.util.Arrays; +import java.util.*; import java.util.List; -import java.util.Optional; import java.util.concurrent.TimeoutException; import java.util.concurrent.atomic.AtomicReference; @@ -357,7 +355,7 @@ protected void handleUpdatedJxBrowserStatus( ToolWindow toolWindow, JxBrowserStatus jxBrowserStatus, DevToolsIdeFeature ideFeature) { - if (jxBrowserStatus.equals(JxBrowserStatus.INSTALLED)) { + if (Objects.equals(jxBrowserStatus, JxBrowserStatus.INSTALLED)) { handleJxBrowserInstalled(app, toolWindow, ideFeature); } else if (jxBrowserStatus.equals(JxBrowserStatus.INSTALLATION_FAILED)) { @@ -381,7 +379,7 @@ protected void handleJxBrowserInstallationFailed(FlutterApp app, ToolWindow tool inputs.add(new LabelInput("The JxBrowser license could not be found.")); inputs.add(openDevToolsLabel); } - else if (latestFailureReason != null && latestFailureReason.failureType.equals(FailureType.SYSTEM_INCOMPATIBLE)) { + else if (latestFailureReason != null && Objects.equals(latestFailureReason.failureType, FailureType.SYSTEM_INCOMPATIBLE)) { // If we know the system is incompatible, skip retry link and offer to open in browser. inputs.add(new LabelInput(latestFailureReason.detail)); inputs.add(openDevToolsLabel); diff --git a/flutter-idea/src/io/flutter/vmService/DartVmServiceDebugProcess.java b/flutter-idea/src/io/flutter/vmService/DartVmServiceDebugProcess.java index 228241867c..6b16240e64 100644 --- a/flutter-idea/src/io/flutter/vmService/DartVmServiceDebugProcess.java +++ b/flutter-idea/src/io/flutter/vmService/DartVmServiceDebugProcess.java @@ -386,7 +386,7 @@ public void isolateExit(@NotNull final IsolateRef isolateRef) { myIsolatesInfo.deleteIsolate(isolateRef); mySuspendedIsolateIds.remove(isolateRef.getId()); - if (isolateRef.getId().equals(myLatestCurrentIsolateId)) { + if (Objects.equals(isolateRef.getId(), myLatestCurrentIsolateId)) { resume(getSession().getSuspendContext()); // otherwise no way no resume them from UI } } diff --git a/flutter-idea/src/io/flutter/vmService/VMServiceManager.java b/flutter-idea/src/io/flutter/vmService/VMServiceManager.java index 9fd7faa346..0b5de183f3 100644 --- a/flutter-idea/src/io/flutter/vmService/VMServiceManager.java +++ b/flutter-idea/src/io/flutter/vmService/VMServiceManager.java @@ -248,7 +248,7 @@ private void onVmServiceReceived(String streamId, Event event) { if (extension != null) { final Object value = getExtensionValueFromEventJson(name, valueFromJson); if (extension instanceof ToggleableServiceExtensionDescription toggleableExtension) { - setServiceExtensionState(name, value.equals(toggleableExtension.getEnabledValue()), value); + setServiceExtensionState(name, Objects.equals(value, toggleableExtension.getEnabledValue()), value); } else { setServiceExtensionState(name, true, value); @@ -291,7 +291,7 @@ private Object getExtensionValueFromEventJson(String name, String valueFromJson) ServiceExtensions.toggleableExtensionsAllowList.get(name).getValueClass(); if (valueClass == Boolean.class) { - return valueFromJson.equals("true"); + return Objects.equals(valueFromJson, "true"); } else if (valueClass == Double.class) { return Double.valueOf(valueFromJson); @@ -365,7 +365,7 @@ private void restoreExtensionFromDevice(String name) { Object value = null; if (obj != null) { if (valueClass == Boolean.class) { - value = obj.get("enabled").getAsString().equals("true"); + value = Objects.equals(obj.get("enabled").getAsString(), "true"); maybeRestoreExtension(name, value); } else if (valueClass == String.class) { @@ -383,7 +383,7 @@ else if (valueClass == Double.class) { private void maybeRestoreExtension(String name, Object value) { if (ServiceExtensions.toggleableExtensionsAllowList.get(name) instanceof ToggleableServiceExtensionDescription extensionDescription) { - if (value.equals(extensionDescription.getEnabledValue())) { + if (Objects.equals(value, extensionDescription.getEnabledValue())) { setServiceExtensionState(name, true, value); } } @@ -527,7 +527,7 @@ public CompletableFuture getFlutterViewId() { final JsonArray viewsList = element.getAsJsonObject().get("views").getAsJsonArray(); for (JsonElement jsonElement : viewsList) { final JsonObject view = jsonElement.getAsJsonObject(); - if (view.get("type").getAsString().equals("FlutterView")) { + if (Objects.equals(view.get("type").getAsString(), "FlutterView")) { return view.get("id").getAsString(); } } diff --git a/flutter-idea/src/io/flutter/vmService/frame/DartVmServiceEvaluator.java b/flutter-idea/src/io/flutter/vmService/frame/DartVmServiceEvaluator.java index 635b263b0b..63ee2509c8 100644 --- a/flutter-idea/src/io/flutter/vmService/frame/DartVmServiceEvaluator.java +++ b/flutter-idea/src/io/flutter/vmService/frame/DartVmServiceEvaluator.java @@ -28,10 +28,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Set; +import java.util.*; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -136,7 +133,7 @@ public void onError(RPCError error) { public void received(Obj response) { final Library library = (Library)response; for (ClassRef classRef : library.getClasses()) { - if (classRef.getName().equals(dartClassName)) { + if (Objects.equals(classRef.getName(), dartClassName)) { vmService.evaluateInTargetContext(isolateId, classRef.getId(), expression, wrappedCallback); return; } @@ -204,7 +201,7 @@ public static String getPresentableError(@NotNull final String rawError) { final List lines = StringUtil.split(StringUtil.convertLineSeparators(rawError), "\n"); if (!lines.isEmpty()) { - if ((lines.get(0).equals("Error: Unhandled exception:") || lines.get(0).equals("Unhandled exception:")) && lines.size() > 1) { + if ((Objects.equals(lines.get(0), "Error: Unhandled exception:") || Objects.equals(lines.get(0), "Unhandled exception:")) && lines.size() > 1) { return lines.get(1); } final Matcher matcher = ERROR_PATTERN.matcher(lines.get(0)); diff --git a/flutter-idea/src/io/flutter/vmService/frame/DartVmServiceSuspendContext.java b/flutter-idea/src/io/flutter/vmService/frame/DartVmServiceSuspendContext.java index 3990561976..54048be3b5 100644 --- a/flutter-idea/src/io/flutter/vmService/frame/DartVmServiceSuspendContext.java +++ b/flutter-idea/src/io/flutter/vmService/frame/DartVmServiceSuspendContext.java @@ -13,6 +13,7 @@ import java.util.ArrayList; import java.util.Collection; import java.util.List; +import java.util.Objects; public class DartVmServiceSuspendContext extends XSuspendContext { @NotNull private final DartVmServiceDebugProcess myDebugProcess; @@ -47,7 +48,7 @@ public void computeExecutionStacks(@NotNull final XExecutionStackContainer conta final Collection isolateInfos = myDebugProcess.getIsolateInfos(); myExecutionStacks = new ArrayList<>(isolateInfos.size()); for (IsolatesInfo.IsolateInfo isolateInfo : isolateInfos) { - if (isolateInfo.getIsolateId().equals(myActiveExecutionStack.getIsolateId())) { + if (Objects.equals(isolateInfo.getIsolateId(), myActiveExecutionStack.getIsolateId())) { myExecutionStacks.add(myActiveExecutionStack); } else { diff --git a/flutter-idea/testSrc/unit/io/flutter/utils/IconPreviewGeneratorTest.java b/flutter-idea/testSrc/unit/io/flutter/utils/IconPreviewGeneratorTest.java index cef34aa16a..a81dac02f6 100644 --- a/flutter-idea/testSrc/unit/io/flutter/utils/IconPreviewGeneratorTest.java +++ b/flutter-idea/testSrc/unit/io/flutter/utils/IconPreviewGeneratorTest.java @@ -12,6 +12,7 @@ import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; +import java.util.Objects; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; @@ -37,7 +38,7 @@ public void generateCupertino() throws IOException { // The list is not sorted and there's no need to sort it. // We just want to verify that a specific file exists. for (String each : list) { - if (each.equals("add.png")) { + if (Objects.equals(each, "add.png")) { found = true; break; } diff --git a/flutter-studio/src/io/flutter/utils/GradleUtils.java b/flutter-studio/src/io/flutter/utils/GradleUtils.java index d681be2559..cf6c9f0463 100644 --- a/flutter-studio/src/io/flutter/utils/GradleUtils.java +++ b/flutter-studio/src/io/flutter/utils/GradleUtils.java @@ -340,7 +340,7 @@ private static PsiElement findInclude(GradleSettingsFile parsedSettings, String private static boolean matchesName(PsiElement expr, String name) { if (expr == null) return false; String text = expr.getText(); - return name.equals(text.substring(2, text.length() - 1)); + return Objects.equals(name, text.substring(2, text.length() - 1)); } private static class CoEditHelper { @@ -381,7 +381,7 @@ private void enable() { addCoeditTransformedProject(project); // We may have multiple Gradle sync listeners. Write the files to disk synchronously so we won't edit them twice. projectRoot.refresh(false, true); - if (!projectRoot.equals(flutterModuleDir.getParent())) { + if (!Objects.equals(projectRoot, flutterModuleDir.getParent())) { flutterModuleDir.refresh(false, true); } AppExecutorUtil.getAppExecutorService().execute(() -> scheduleGradleSyncAfterSyncFinishes(project)); @@ -453,7 +453,7 @@ private void addIncludeStatement() { } private String readSettingsFile() { - inSameDir = flutterModuleDir.getParent().equals(projectRoot); + inSameDir = Objects.equals(flutterModuleDir.getParent(), projectRoot); pathToModule = FileUtilRt.getRelativePath(new File(projectRoot.getPath()), flutterModuleRoot); try { requireNonNull(pathToModule);