Skip to content

Commit 2f11f24

Browse files
authored
Fix various performance and cleanup issues (#6944)
Java syntax changes include: - inclusion of @NotNull - making downcasts explict - use of amend instead of the string `+` operator
1 parent 50ccd09 commit 2f11f24

19 files changed

+51
-50
lines changed

flutter-idea/src/io/flutter/actions/FlutterAppAction.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public FlutterAppAction(@NotNull FlutterApp app,
4747
}
4848

4949
@Override
50-
public ActionUpdateThread getActionUpdateThread() {
50+
public @NotNull ActionUpdateThread getActionUpdateThread() {
5151
return ActionUpdateThread.BGT;
5252
}
5353

flutter-idea/src/io/flutter/analytics/FlutterAnalysisServerListener.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ private HashMap<String, Integer> getTotalAnalysisErrorCounts() {
277277
// errorCountsArray[*]
278278
for (int i = 0; i < ERROR_TYPES.length; i++) {
279279
final int j = i;
280-
errorCountsArray[j] += errors.stream().filter(e -> {
280+
errorCountsArray[j] += (int) errors.stream().filter(e -> {
281281
assert e != null;
282282
return Objects.equals(e.getType(), ERROR_TYPES[j]);
283283
}).count();

flutter-idea/src/io/flutter/console/FlutterConsoleFilter.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ private static class OpenExternalFileHyperlink implements HyperlinkInfo {
4949
}
5050

5151
@Override
52-
public void navigate(Project project) {
52+
public void navigate(@NotNull Project project) {
5353
try {
5454
final GeneralCommandLine cmd = new GeneralCommandLine().withExePath("open").withParameters(myPath);
5555
final ColoredProcessHandler handler = new ColoredProcessHandler(cmd);
@@ -257,7 +257,7 @@ private static Result getFlutterDoctorResult(final String line, final int lineSt
257257

258258
private static class FlutterDoctorHyperlinkInfo implements HyperlinkInfo {
259259
@Override
260-
public void navigate(final Project project) {
260+
public void navigate(final @NotNull Project project) {
261261
// TODO(skybrian) analytics for clicking the link? (We do log the command.)
262262
final FlutterSdk sdk = FlutterSdk.getFlutterSdk(project);
263263
if (sdk == null) {

flutter-idea/src/io/flutter/editor/FlutterColorProvider.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ else if (parent.getNode().getElementType() == DartTokenTypes.SIMPLE_TYPE) {
8686
}
8787
final PsiElement reference = resolveReferencedElement(refExpr);
8888
if (reference != null && reference.getLastChild() != null) {
89-
Color tryParseColor = null;
89+
Color tryParseColor;
9090
if (reference instanceof DartCallExpression) {
9191
final DartExpression expression = ((DartCallExpression)reference).getExpression();
9292
if (expression != null && expression.getLastChild() instanceof DartReferenceExpression) {

flutter-idea/src/io/flutter/editor/PreviewViewControllerBase.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -656,7 +656,7 @@ public void paint(@NotNull Graphics g, int lineHeight) {
656656
}
657657
g2d.setColor(JBColor.BLACK);
658658

659-
drawMultilineString(g2d, getNoScreenshotMessage(), screenshotBounds.x + 4, screenshotBounds.y + +lineHeight - 4, lineHeight);
659+
drawMultilineString(g2d, getNoScreenshotMessage(), screenshotBounds.x + 4, screenshotBounds.y + lineHeight - 4, lineHeight);
660660
}
661661
g2d.setClip(clip);
662662

flutter-idea/src/io/flutter/editor/PropertyEditorPanel.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,6 @@ public PropertyEnumComboBoxModel(FlutterWidgetProperty property) {
9898
String expression = property.getExpression();
9999
if (expression == null) {
100100
mySelected = null;
101-
expression = "";
102101
return;
103102
}
104103
if (property.getValue() != null) {
@@ -489,7 +488,7 @@ protected void rebuildUi() {
489488
continue;
490489
}
491490
final String documentation = property.getDocumentation();
492-
JComponent field = null;
491+
JComponent field;
493492

494493
if (property.getEditor() == null) {
495494
// TODO(jacobr): detect color properties more robustly.

flutter-idea/src/io/flutter/inspector/InspectorService.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -440,8 +440,8 @@ private void onVmServiceReceived(String streamId, Event event) {
440440
if (path == null) return;
441441

442442
VirtualFile file = LocalFileSystem.getInstance().findFileByPath(path);
443-
final Integer line = JsonUtils.getIntMember(json, "line");
444-
final Integer column = JsonUtils.getIntMember(json, "column");;
443+
final int line = JsonUtils.getIntMember(json, "line");
444+
final int column = JsonUtils.getIntMember(json, "column");;
445445

446446
ApplicationManager.getApplication().invokeLater(() -> {
447447
if (file != null && line >= 0 && column >= 0) {

flutter-idea/src/io/flutter/inspector/TreeScrollAnimator.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,7 @@ public void animateTo(List<TreePath> targets) {
402402
for (TreePath target : targets) {
403403
if (this.targets.contains(target)) {
404404
newTarget = false;
405+
break;
405406
}
406407
}
407408
}

flutter-idea/src/io/flutter/test/DartTestEventsConverterZ.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ public DartTestEventsConverterZ(@NotNull final String testFrameworkName,
112112
}
113113

114114
@Override
115-
protected boolean processServiceMessages(final String text, final Key outputType, final ServiceMessageVisitor visitor)
115+
protected boolean processServiceMessages(final String text, final @NotNull Key outputType, final @NotNull ServiceMessageVisitor visitor)
116116
throws ParseException {
117117
LOG.debug("<<< " + text.trim());
118118
myCurrentOutputType = outputType;

flutter-idea/src/io/flutter/vmService/DartVmServiceDebugProcess.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ public XDebuggerEditorsProvider getEditorsProvider() {
280280

281281
@Override
282282
@NotNull
283-
public XBreakpointHandler<?>[] getBreakpointHandlers() {
283+
public XBreakpointHandler<?> @NotNull [] getBreakpointHandlers() {
284284
return myBreakpointHandlers;
285285
}
286286

0 commit comments

Comments
 (0)