Skip to content

Commit 5214718

Browse files
authored
[cq] Java cleanup, remove constant values (#8470)
1 parent 8c5d1eb commit 5214718

19 files changed

+39
-63
lines changed

src/io/flutter/FlutterErrorReportSubmitter.java

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -72,23 +72,20 @@ public boolean submit(@NotNull IdeaLoggingEvent @NotNull [] events,
7272
if (stackTraceText.startsWith(DaemonApi.FLUTTER_ERROR_PREFIX)) {
7373
final String message = stackTraceText.substring(DaemonApi.FLUTTER_ERROR_PREFIX.length());
7474
final int start = message.indexOf(": ") + 2;
75-
if (start == 0) continue;
7675
int end = message.indexOf('\n');
7776
if (end < 0) end = message.length();
7877
final String error = message.substring(start, end);
7978
stackTrace = message.substring(end + 1);
8079
for (String err : KNOWN_ERRORS) {
8180
if (error.contains(err)) {
82-
if (end != message.length()) {
83-
// Dart stack trace included so extract it and set the issue target to the Flutter repo.
84-
errorMessage = err;
85-
final int endOfDartStack = stackTrace.indexOf("\\n\"\n");
86-
if (endOfDartStack > 0) {
87-
// Get only the part between quotes. If the format is wrong just use the whole thing.
88-
stackTrace = stackTrace.substring(1, endOfDartStack);
89-
}
90-
break;
81+
// Dart stack trace included so extract it and set the issue target to the Flutter repo.
82+
errorMessage = err;
83+
final int endOfDartStack = stackTrace.indexOf("\\n\"\n");
84+
if (endOfDartStack > 0) {
85+
// Get only the part between quotes. If the format is wrong just use the whole thing.
86+
stackTrace = stackTrace.substring(1, endOfDartStack);
9187
}
88+
break;
9289
}
9390
}
9491
}

src/io/flutter/FlutterInitializer.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ private void checkSdkVersionNotification(@NotNull Project project) {
318318
// See FlutterSdkVersion.MIN_SDK_SUPPORTED.
319319
if (version.isValid() && !version.isSDKSupported()) {
320320
final FlutterSettings settings = FlutterSettings.getInstance();
321-
if (settings == null || settings.isSdkVersionOutdatedWarningAcknowledged(version.getVersionText(), false)) return;
321+
if (settings.isSdkVersionOutdatedWarningAcknowledged(version.getVersionText(), false)) return;
322322
OpenApiUtils.safeInvokeLater(() -> {
323323
final Notification notification = new Notification(FlutterMessages.FLUTTER_NOTIFICATION_GROUP_ID,
324324
"Flutter SDK requires update",
@@ -343,7 +343,7 @@ public void actionPerformed(@NotNull AnActionEvent event) {
343343
// See FlutterSdkVersion.MIN_SDK_WITHOUT_SUNSET_WARNING.
344344
if (version.isValid() && version.isSDKAboutToSunset()) {
345345
final FlutterSettings settings = FlutterSettings.getInstance();
346-
if (settings == null || settings.isSdkVersionOutdatedWarningAcknowledged(version.getVersionText(), true)) return;
346+
if (settings.isSdkVersionOutdatedWarningAcknowledged(version.getVersionText(), true)) return;
347347

348348
OpenApiUtils.safeInvokeLater(() -> {
349349
final Notification notification = new Notification(FlutterMessages.FLUTTER_NOTIFICATION_GROUP_ID,

src/io/flutter/FlutterStudioStartupActivity.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@ private static Void doNonBlockingStartup(@NotNull Project project) {
2929
//FlutterProjectCreator.disableUserConfig(project);
3030
// Monitor Android dependencies.
3131
FlutterSettings flutterSettings = FlutterSettings.getInstance();
32-
if (flutterSettings != null && flutterSettings.isSyncingAndroidLibraries() ||
33-
System.getProperty("flutter.android.library.sync", null) != null) {
32+
if (flutterSettings.isSyncingAndroidLibraries() || System.getProperty("flutter.android.library.sync", null) != null) {
3433
// TODO(messick): Remove the flag once this sync mechanism is stable.
3534
AndroidModuleLibraryManager.startWatching(project);
3635
}

src/io/flutter/FlutterUtils.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -578,9 +578,6 @@ public static EmbeddedBrowser embeddedBrowser(Project project) {
578578
}
579579

580580
FlutterSettings settings = FlutterSettings.getInstance();
581-
if (settings == null) {
582-
return null;
583-
}
584581

585582
return settings.isEnableJcefBrowser()
586583
? EmbeddedJcefBrowser.getInstance(project)

src/io/flutter/actions/OpenInAndroidStudioAction.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,6 @@ protected static boolean isProjectFileName(@NotNull String name) {
178178
for (PubRoot root : PubRoots.forProject(project)) {
179179
if (root.isFlutterPlugin()) {
180180
final VirtualFile rootFile = root.getRoot();
181-
if (rootFile == null) continue;
182181
VirtualFile aFile = file;
183182
while (aFile != null) {
184183
if (aFile.equals(rootFile)) {

src/io/flutter/console/FlutterConsoleFilter.java

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -94,19 +94,17 @@ public VirtualFile fileAtPath(@NotNull String pathPart) {
9494
final VirtualFile[] roots = OpenApiUtils.getContentRoots(module);
9595
for (VirtualFile root : roots) {
9696
if (root == null) continue;
97-
if (!pathPart.isEmpty()) {
98-
final String baseDirPath = root.getPath();
99-
final String path = baseDirPath + "/" + pathPart;
100-
VirtualFile file = findFile(path);
101-
if (file == null) {
102-
// check example dir too
103-
// TODO(pq): remove when `example` is a content root: https://github.com/flutter/flutter-intellij/issues/2519
104-
final String exampleDirRelativePath = baseDirPath + "/example/" + pathPart;
105-
file = findFile(exampleDirRelativePath);
106-
}
107-
if (file != null) {
108-
return file;
109-
}
97+
final String baseDirPath = root.getPath();
98+
final String path = baseDirPath + "/" + pathPart;
99+
VirtualFile file = findFile(path);
100+
if (file == null) {
101+
// check example dir too
102+
// TODO(pq): remove when `example` is a content root: https://github.com/flutter/flutter-intellij/issues/2519
103+
final String exampleDirRelativePath = baseDirPath + "/example/" + pathPart;
104+
file = findFile(exampleDirRelativePath);
105+
}
106+
if (file != null) {
107+
return file;
110108
}
111109
}
112110

src/io/flutter/dart/FlutterRequestUtilities.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,6 @@ private static JsonObject buildJsonObjectRequest(String idValue, String methodVa
113113
*/
114114
@NotNull
115115
private static String getClassName(@Nullable Object object) {
116-
return object != null && object.getClass().getName() != null ? object.getClass().getName() : "null";
116+
return object != null ? object.getClass().getName() : "null";
117117
}
118118
}

src/io/flutter/editor/FlutterIconLineMarkerProvider.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,6 @@ private IconInfo findStandardDefinition(@NotNull String className,
239239

240240
@Nullable
241241
private Icon findStandardIconFromDef(@NotNull String name, @NotNull IconInfo iconDef, @NotNull String path) {
242-
assert LocalFileSystem.getInstance() != null;
243242
final VirtualFile virtualFile = LocalFileSystem.getInstance().findFileByPath(path);
244243
if (virtualFile == null) return null;
245244
final IconPreviewGenerator generator = new IconPreviewGenerator(virtualFile.getPath());
@@ -310,7 +309,6 @@ private LineMarkerInfo<PsiElement> createLineMarker(@Nullable PsiElement element
310309

311310
@Nullable
312311
private IconInfo findDefinition(@NotNull String className, @NotNull String iconName, @NotNull Project project, @NotNull String path) {
313-
assert LocalFileSystem.getInstance() != null;
314312
final VirtualFile virtualFile = LocalFileSystem.getInstance().findFileByPath(path);
315313
if (virtualFile == null) return null;
316314
final PsiFile psiFile = PsiManager.getInstance(project).findFile(virtualFile);
@@ -324,7 +322,6 @@ private IconInfo findDefinition(@NotNull String className, @NotNull String iconN
324322

325323
@Nullable
326324
private Icon findIconFromDef(@NotNull String iconClassName, @NotNull IconInfo iconDef, @NotNull String path) {
327-
assert LocalFileSystem.getInstance() != null;
328325
final VirtualFile virtualFile = LocalFileSystem.getInstance().findFileByPath(path);
329326
if (virtualFile == null) return null;
330327
VirtualFile parent = virtualFile;

src/io/flutter/jxbrowser/EmbeddedJxBrowser.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,6 @@ private EmbeddedJxBrowser(@NotNull Project project) {
217217
private @Nullable String jxBrowserErrorFromFailedReason(@Nullable InstallationFailedReason failedReason) {
218218
if (failedReason == null) return null;
219219
final FailureType failureType = failedReason.failureType;
220-
if (failureType == null) return null;
221220
return switch (failureType) {
222221
case SYSTEM_INCOMPATIBLE -> "System is incompatible with JX Browser";
223222
case FILE_DOWNLOAD_FAILED -> "JX Browser file download failed";

src/io/flutter/run/FlutterReloadManager.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -372,9 +372,7 @@ private void restartApp(@NotNull FlutterApp app, @NotNull String reason) {
372372
});
373373

374374
final FlutterDevice device = app.device();
375-
if (device != null) {
376-
device.bringToFront();
377-
}
375+
device.bringToFront();
378376
}
379377
}
380378

0 commit comments

Comments
 (0)