bulk fix for `prefer_inlined_adds`
Change-Id: I0d165fcc2068ccb05b1ef202cae29c4e415a430a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/164603
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
diff --git a/pkg/analysis_server/lib/src/services/correction/bulk_fix_processor.dart b/pkg/analysis_server/lib/src/services/correction/bulk_fix_processor.dart
index 66c8c45..16528c5 100644
--- a/pkg/analysis_server/lib/src/services/correction/bulk_fix_processor.dart
+++ b/pkg/analysis_server/lib/src/services/correction/bulk_fix_processor.dart
@@ -27,6 +27,7 @@
import 'package:analysis_server/src/services/correction/dart/convert_to_set_literal.dart';
import 'package:analysis_server/src/services/correction/dart/convert_to_where_type.dart';
import 'package:analysis_server/src/services/correction/dart/create_method.dart';
+import 'package:analysis_server/src/services/correction/dart/inline_invocation.dart';
import 'package:analysis_server/src/services/correction/dart/make_final.dart';
import 'package:analysis_server/src/services/correction/dart/remove_argument.dart';
import 'package:analysis_server/src/services/correction/dart/remove_await.dart';
@@ -175,6 +176,10 @@
LintNames.prefer_if_null_operators: [
ConvertToIfNull.newInstance,
],
+ LintNames.prefer_inlined_adds: [
+ ConvertAddAllToSpread.newInstance,
+ InlineInvocation.newInstance,
+ ],
LintNames.prefer_int_literals: [
ConvertToIntLiteral.newInstance,
],
diff --git a/pkg/analysis_server/test/src/services/correction/fix/bulk/inline_invocation_test.dart b/pkg/analysis_server/test/src/services/correction/fix/bulk/inline_invocation_test.dart
new file mode 100644
index 0000000..2e6ed1b
--- /dev/null
+++ b/pkg/analysis_server/test/src/services/correction/fix/bulk/inline_invocation_test.dart
@@ -0,0 +1,33 @@
+// Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import 'package:analysis_server/src/services/linter/lint_names.dart';
+import 'package:test_reflective_loader/test_reflective_loader.dart';
+
+import 'bulk_fix_processor.dart';
+
+void main() {
+ defineReflectiveSuite(() {
+ defineReflectiveTests(InlineInvocationTest);
+ });
+}
+
+@reflectiveTest
+class InlineInvocationTest extends BulkFixProcessorTest {
+ @override
+ String get lintCode => LintNames.prefer_inlined_adds;
+
+ Future<void> test_singleFile() async {
+ await resolveTestUnit('''
+var l = []..add('a')..add('b');
+var l2 = ['a', 'b']..add('c');
+var l3 = ['a']..addAll(['b', 'c']);
+''');
+ await assertHasFix('''
+var l = ['a']..add('b');
+var l2 = ['a', 'b', 'c'];
+var l3 = ['a', 'b', 'c'];
+''');
+ }
+}
diff --git a/pkg/analysis_server/test/src/services/correction/fix/bulk/test_all.dart b/pkg/analysis_server/test/src/services/correction/fix/bulk/test_all.dart
index 5fb51b9..4d5f5ee 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/bulk/test_all.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/bulk/test_all.dart
@@ -29,6 +29,7 @@
import 'convert_to_spread_test.dart' as convert_to_spread;
import 'convert_to_where_type_test.dart' as convert_to_where_type;
import 'create_method_test.dart' as create_method;
+import 'inline_invocation_test.dart' as inline_invocation;
import 'make_final_test.dart' as make_final;
import 'remove_argument_test.dart' as remove_argument;
import 'remove_await_test.dart' as remove_await;
@@ -83,6 +84,7 @@
convert_to_spread.main();
convert_to_where_type.main();
create_method.main();
+ inline_invocation.main();
make_final.main();
remove_argument.main();
remove_await.main();