This repository was archived by the owner on Feb 25, 2025. It is now read-only.
File tree 3 files changed +43
-0
lines changed
lib/src/services/correction
test/src/services/correction/fix/bulk
3 files changed +43
-0
lines changed Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ import 'package:analysis_server/src/services/correction/dart/convert_documentati
15
15
import 'package:analysis_server/src/services/correction/dart/convert_quotes.dart' ;
16
16
import 'package:analysis_server/src/services/correction/dart/convert_to_contains.dart' ;
17
17
import 'package:analysis_server/src/services/correction/dart/create_method.dart' ;
18
+ import 'package:analysis_server/src/services/correction/dart/make_final.dart' ;
18
19
import 'package:analysis_server/src/services/correction/dart/remove_argument.dart' ;
19
20
import 'package:analysis_server/src/services/correction/dart/remove_await.dart' ;
20
21
import 'package:analysis_server/src/services/correction/dart/remove_const.dart' ;
@@ -78,6 +79,7 @@ class BulkFixProcessor {
78
79
LintNames .prefer_contains: ConvertToContains .newInstance,
79
80
LintNames .prefer_equal_for_default_values:
80
81
ReplaceColonWithEquals .newInstance,
82
+ LintNames .prefer_final_fields: MakeFinal .newInstance,
81
83
LintNames .prefer_if_elements_to_conditional_expressions:
82
84
ConvertConditionalExpressionToIfElement .newInstance,
83
85
LintNames .prefer_is_empty: ReplaceWithIsEmpty .newInstance,
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 (PreferFinalFieldsTest );
13
+ });
14
+ }
15
+
16
+ @reflectiveTest
17
+ class PreferFinalFieldsTest extends BulkFixProcessorTest {
18
+ @override
19
+ String get lintCode => LintNames .prefer_final_fields;
20
+
21
+ Future <void > test_singleFile () async {
22
+ await resolveTestUnit ('''
23
+ class C {
24
+ int _f = 2;
25
+ var _f2 = 2;
26
+ int get g => _f;
27
+ int get g2 => _f2;
28
+ }
29
+ ''' );
30
+ await assertHasFix ('''
31
+ class C {
32
+ final int _f = 2;
33
+ final _f2 = 2;
34
+ int get g => _f;
35
+ int get g2 => _f2;
36
+ }
37
+ ''' );
38
+ }
39
+ }
Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ import 'convert_to_single_quoted_strings_test.dart'
13
13
as convert_to_single_quoted_strings;
14
14
import 'convert_to_spread_test.dart' as convert_to_spread;
15
15
import 'create_method_test.dart' as create_method;
16
+ import 'make_final_test.dart' as make_final;
16
17
import 'remove_argument_test.dart' as remove_argument;
17
18
import 'remove_await_test.dart' as remove_await;
18
19
import 'remove_duplicate_case_test.dart' as remove_duplicate_case;
@@ -47,6 +48,7 @@ void main() {
47
48
convert_to_single_quoted_strings.main ();
48
49
convert_to_spread.main ();
49
50
create_method.main ();
51
+ make_final.main ();
50
52
remove_argument.main ();
51
53
remove_await.main ();
52
54
remove_duplicate_case.main ();
You can’t perform that action at this time.
0 commit comments