@@ -16,44 +16,94 @@ import 'package:analysis_server/src/edit/fix/prefer_spread_collections_fix.dart'
16
16
17
17
const allFixes = < DartFixInfo > [
18
18
//
19
- // Required fixes
19
+ // Fixes enabled by default
20
20
//
21
21
const DartFixInfo (
22
22
'fix-named-constructor-type-arguments' ,
23
- 'Move named constructor type arguments from the name to the type.' ,
23
+ '''
24
+ Move named constructor type arguments from the name to the type.
25
+
26
+ For example, this
27
+ new List.filled<String>(20, 'value');
28
+
29
+ will be converted to
30
+ new List<String>.filled(20, 'value');''' ,
24
31
FixErrorTask .fixNamedConstructorTypeArgs,
25
32
isRequired: true ,
26
33
),
27
34
const DartFixInfo (
28
35
'use-mixin' ,
29
- 'Convert classes used as a mixin to the new mixin syntax.' ,
36
+ '''
37
+ Convert classes used as a mixin to the new mixin syntax.
38
+
39
+ For example, this
40
+ class C with M { }
41
+ class M { }
42
+
43
+ will be converted to
44
+ class C with M { }
45
+ mixin M { }
46
+
47
+ There are several situations where a class cannot be automatically converted
48
+ to a mixin such as when the class contains a constructor. In that situation
49
+ a message is displayed and the class is not converted to a mixin.''' ,
30
50
PreferMixinFix .task,
31
51
isRequired: true ,
32
52
),
33
53
//
34
- // Suggested fixes
54
+ // Fixes that may be explicitly enabled
35
55
//
36
56
const DartFixInfo (
37
57
'double-to-int' ,
38
- 'Find double literals ending in .0 and remove the .0 '
39
- 'wherever double context can be inferred.' ,
58
+ '''
59
+ Find double literals ending in .0 and remove the .0
60
+ wherever double context can be inferred.
61
+
62
+ For example, this
63
+ const double myDouble = 8.0;
64
+
65
+ will be converted to
66
+ const double myDouble = 8;''' ,
40
67
PreferIntLiteralsFix .task,
41
68
),
42
69
const DartFixInfo (
43
70
'use-spread-collections' ,
44
- 'Convert to using collection spread operators.' ,
71
+ '''
72
+ Convert to using collection spread operators.
73
+
74
+ For example, this
75
+ var l1 = ['b'];
76
+ var l2 = ['a']..addAll(l1);
77
+
78
+ will be converted to
79
+ var l1 = ['b'];
80
+ var l2 = ['a', ...l1];''' ,
45
81
PreferSpreadCollectionsFix .task,
46
82
isDefault: false ,
47
83
),
48
84
const DartFixInfo (
49
85
'collection-if-elements' ,
50
- 'Convert to using if elements when building collections.' ,
86
+ '''
87
+ Convert to using if elements when building collections.
88
+
89
+ For example, this
90
+ f(bool b) => ['a', b ? 'c' : 'd', 'e'];
91
+
92
+ will be converted to
93
+ f(bool b) => ['a', if (b) 'c' else 'd', 'e'];''' ,
51
94
PreferIfElementsToConditionalExpressionsFix .task,
52
95
isDefault: false ,
53
96
),
54
97
const DartFixInfo (
55
98
'map-for-elements' ,
56
- 'Convert to for elements when building maps from iterables.' ,
99
+ '''
100
+ Convert to for elements when building maps from iterables.
101
+
102
+ For example, this
103
+ Map<int, int>.fromIterable([1, 2, 3], key: (i) => i, value: (i) => i * 2)
104
+
105
+ will be converted to
106
+ <int, int>{ for(int i in [1, 2, 3]) i : i * 2, }''' ,
57
107
PreferForElementsToMapFromIterableFix .task,
58
108
isDefault: false ,
59
109
),
@@ -64,8 +114,10 @@ const allFixes = <DartFixInfo>[
64
114
'non-nullable' ,
65
115
// TODO(danrubel) update description and make default/required
66
116
// when NNBD fix is ready
67
- 'Experimental: Update sources to be non-nullable by default.\n '
68
- 'This requires the experimental non-nullable flag to be enabled.' ,
117
+ '''
118
+ EXPERIMENTAL: Update sources to be non-nullable by default.
119
+ This requires the experimental non-nullable flag to be enabled
120
+ when running the updated application.''' ,
69
121
NonNullableFix .task,
70
122
isDefault: false ,
71
123
),
0 commit comments