File tree Expand file tree Collapse file tree 3 files changed +45
-0
lines changed
lib/src/services/correction
test/src/services/correction/fix/bulk Expand file tree Collapse file tree 3 files changed +45
-0
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ import 'package:analysis_server/src/services/correction/dart/abstract_producer.d
1111import 'package:analysis_server/src/services/correction/dart/add_override.dart' ;
1212import 'package:analysis_server/src/services/correction/dart/convert_documentation_into_line.dart' ;
1313import 'package:analysis_server/src/services/correction/dart/remove_const.dart' ;
14+ import 'package:analysis_server/src/services/correction/dart/remove_initializer.dart' ;
1415import 'package:analysis_server/src/services/correction/dart/remove_unnecessary_new.dart' ;
1516import 'package:analysis_server/src/services/correction/dart/replace_cascade_with_dot.dart' ;
1617import 'package:analysis_server/src/services/correction/dart/replace_colon_with_equals.dart' ;
@@ -29,6 +30,7 @@ class BulkFixProcessor {
2930 /// generators used for non-lint diagnostics are in the [nonLintProducerMap] .
3031 static const Map <String , ProducerGenerator > lintProducerMap = {
3132 LintNames .annotate_overrides: AddOverride .newInstance,
33+ LintNames .avoid_init_to_null: RemoveInitializer .newInstance,
3234 LintNames .avoid_single_cascade_in_expression_statements:
3335 ReplaceCascadeWithDot .newInstance,
3436 LintNames .prefer_equal_for_default_values:
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 (RemoveInitializerTest );
13+ });
14+ }
15+
16+ @reflectiveTest
17+ class RemoveInitializerTest extends BulkFixProcessorTest {
18+ @override
19+ String get lintCode => LintNames .avoid_init_to_null;
20+
21+ Future <void > test_singleFile () async {
22+ await resolveTestUnit ('''
23+ class T {
24+ int x = null;
25+ }
26+
27+ class T2 {
28+ int x = null;
29+ }
30+ ''' );
31+ await assertHasFix ('''
32+ class T {
33+ int x;
34+ }
35+
36+ class T2 {
37+ int x;
38+ }
39+ ''' );
40+ }
41+ }
Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ import 'package:test_reflective_loader/test_reflective_loader.dart';
77import 'add_override_test.dart' as add_override;
88import 'convert_documentation_into_line_test.dart'
99 as convert_documentation_into_line;
10+ import 'remove_initializer_test.dart' as remove_initializer;
1011import 'remove_unnecessary_const_test.dart' as remove_unnecessary_const;
1112import 'remove_unnecessary_new_test.dart' as remove_unnecessary_new;
1213import 'replace_colon_with_equals_test.dart' as replace_colon_with_equals;
@@ -15,6 +16,7 @@ void main() {
1516 defineReflectiveSuite (() {
1617 add_override.main ();
1718 convert_documentation_into_line.main ();
19+ remove_initializer.main ();
1820 remove_unnecessary_const.main ();
1921 remove_unnecessary_new.main ();
2022 replace_colon_with_equals.main ();
You can’t perform that action at this time.
0 commit comments