Skip to content

Commit d11734f

Browse files
pqcommit-bot@chromium.org
authored andcommitted
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>
1 parent af0e54c commit d11734f

File tree

3 files changed

+40
-0
lines changed

3 files changed

+40
-0
lines changed

pkg/analysis_server/lib/src/services/correction/bulk_fix_processor.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import 'package:analysis_server/src/services/correction/dart/convert_to_relative
2727
import 'package:analysis_server/src/services/correction/dart/convert_to_set_literal.dart';
2828
import 'package:analysis_server/src/services/correction/dart/convert_to_where_type.dart';
2929
import 'package:analysis_server/src/services/correction/dart/create_method.dart';
30+
import 'package:analysis_server/src/services/correction/dart/inline_invocation.dart';
3031
import 'package:analysis_server/src/services/correction/dart/make_final.dart';
3132
import 'package:analysis_server/src/services/correction/dart/remove_argument.dart';
3233
import '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
],
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
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+
}

pkg/analysis_server/test/src/services/correction/fix/bulk/test_all.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import 'convert_to_single_quoted_strings_test.dart'
2929
import 'convert_to_spread_test.dart' as convert_to_spread;
3030
import 'convert_to_where_type_test.dart' as convert_to_where_type;
3131
import 'create_method_test.dart' as create_method;
32+
import 'inline_invocation_test.dart' as inline_invocation;
3233
import 'make_final_test.dart' as make_final;
3334
import 'remove_argument_test.dart' as remove_argument;
3435
import '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();

0 commit comments

Comments
 (0)