File tree Expand file tree Collapse file tree 3 files changed +40
-0
lines changed
lib/src/services/correction
test/src/services/correction/fix/bulk Expand file tree Collapse file tree 3 files changed +40
-0
lines changed Original file line number Diff line number Diff line change @@ -27,6 +27,7 @@ import 'package:analysis_server/src/services/correction/dart/convert_to_relative
2727import 'package:analysis_server/src/services/correction/dart/convert_to_set_literal.dart' ;
2828import 'package:analysis_server/src/services/correction/dart/convert_to_where_type.dart' ;
2929import 'package:analysis_server/src/services/correction/dart/create_method.dart' ;
30+ import 'package:analysis_server/src/services/correction/dart/inline_invocation.dart' ;
3031import 'package:analysis_server/src/services/correction/dart/make_final.dart' ;
3132import 'package:analysis_server/src/services/correction/dart/remove_argument.dart' ;
3233import 'package:analysis_server/src/services/correction/dart/remove_await.dart' ;
@@ -175,6 +176,10 @@ class BulkFixProcessor {
175176 LintNames .prefer_if_null_operators: [
176177 ConvertToIfNull .newInstance,
177178 ],
179+ LintNames .prefer_inlined_adds: [
180+ ConvertAddAllToSpread .newInstance,
181+ InlineInvocation .newInstance,
182+ ],
178183 LintNames .prefer_int_literals: [
179184 ConvertToIntLiteral .newInstance,
180185 ],
Original file line number Diff line number Diff line change 1+ // Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file
2+ // for details. All rights reserved. Use of this source code is governed by a
3+ // BSD-style license that can be found in the LICENSE file.
4+
5+ import 'package:analysis_server/src/services/linter/lint_names.dart' ;
6+ import 'package:test_reflective_loader/test_reflective_loader.dart' ;
7+
8+ import 'bulk_fix_processor.dart' ;
9+
10+ void main () {
11+ defineReflectiveSuite (() {
12+ defineReflectiveTests (InlineInvocationTest );
13+ });
14+ }
15+
16+ @reflectiveTest
17+ class InlineInvocationTest extends BulkFixProcessorTest {
18+ @override
19+ String get lintCode => LintNames .prefer_inlined_adds;
20+
21+ Future <void > test_singleFile () async {
22+ await resolveTestUnit ('''
23+ var l = []..add('a')..add('b');
24+ var l2 = ['a', 'b']..add('c');
25+ var l3 = ['a']..addAll(['b', 'c']);
26+ ''' );
27+ await assertHasFix ('''
28+ var l = ['a']..add('b');
29+ var l2 = ['a', 'b', 'c'];
30+ var l3 = ['a', 'b', 'c'];
31+ ''' );
32+ }
33+ }
Original file line number Diff line number Diff line change @@ -29,6 +29,7 @@ import 'convert_to_single_quoted_strings_test.dart'
2929import 'convert_to_spread_test.dart' as convert_to_spread;
3030import 'convert_to_where_type_test.dart' as convert_to_where_type;
3131import 'create_method_test.dart' as create_method;
32+ import 'inline_invocation_test.dart' as inline_invocation;
3233import 'make_final_test.dart' as make_final;
3334import 'remove_argument_test.dart' as remove_argument;
3435import 'remove_await_test.dart' as remove_await;
@@ -83,6 +84,7 @@ void main() {
8384 convert_to_spread.main ();
8485 convert_to_where_type.main ();
8586 create_method.main ();
87+ inline_invocation.main ();
8688 make_final.main ();
8789 remove_argument.main ();
8890 remove_await.main ();
You can’t perform that action at this time.
0 commit comments