File tree 2 files changed +59
-4
lines changed
lib/src/services/correction
test/src/services/correction/fix
2 files changed +59
-4
lines changed Original file line number Diff line number Diff line change @@ -1146,7 +1146,7 @@ class FixProcessor {
1146
1146
sessionHelper,
1147
1147
namedExpression.parent.parent,
1148
1148
);
1149
- return parameters.namedNames;
1149
+ return parameters? .namedNames;
1150
1150
}
1151
1151
return null ;
1152
1152
}
@@ -4541,11 +4541,15 @@ class _ExecutableParameters {
4541
4541
factory _ExecutableParameters (
4542
4542
AnalysisSessionHelper sessionHelper, AstNode invocation) {
4543
4543
Element element;
4544
- if (invocation is InstanceCreationExpression ) {
4544
+ // This doesn't handle FunctionExpressionInvocation.
4545
+ if (invocation is Annotation ) {
4546
+ element = invocation.element;
4547
+ } else if (invocation is InstanceCreationExpression ) {
4545
4548
element = invocation.staticElement;
4546
- }
4547
- if (invocation is MethodInvocation ) {
4549
+ } else if (invocation is MethodInvocation ) {
4548
4550
element = invocation.methodName.staticElement;
4551
+ } else if (invocation is ConstructorReferenceNode ) {
4552
+ element = invocation.staticElement;
4549
4553
}
4550
4554
if (element is ExecutableElement && ! element.isSynthetic) {
4551
4555
return new _ExecutableParameters ._(sessionHelper, element);
Original file line number Diff line number Diff line change @@ -117,6 +117,23 @@ class A {
117
117
''' );
118
118
}
119
119
120
+ test_default_annotation () async {
121
+ await resolveTestUnit ('''
122
+ @A(boot: 2)
123
+ f() => null;
124
+ class A {
125
+ const A({int boat});
126
+ }
127
+ ''' );
128
+ await assertHasFix ('''
129
+ @A(boat: 2)
130
+ f() => null;
131
+ class A {
132
+ const A({int boat});
133
+ }
134
+ ''' );
135
+ }
136
+
120
137
test_default_constructor () async {
121
138
await resolveTestUnit ('''
122
139
f() => new A(boot: 2);
@@ -166,6 +183,40 @@ class A {
166
183
''' );
167
184
}
168
185
186
+ test_default_redirectingConstructor () async {
187
+ await resolveTestUnit ('''
188
+ class A {
189
+ A.one() : this.two(boot: 3);
190
+ A.two({int boat});
191
+ }
192
+ ''' );
193
+ await assertHasFix ('''
194
+ class A {
195
+ A.one() : this.two(boat: 3);
196
+ A.two({int boat});
197
+ }
198
+ ''' );
199
+ }
200
+
201
+ test_default_superConstructor () async {
202
+ await resolveTestUnit ('''
203
+ class A {
204
+ A.a({int boat});
205
+ }
206
+ class B extends A {
207
+ B.b() : super.a(boot: 3);
208
+ }
209
+ ''' );
210
+ await assertHasFix ('''
211
+ class A {
212
+ A.a({int boat});
213
+ }
214
+ class B extends A {
215
+ B.b() : super.a(boat: 3);
216
+ }
217
+ ''' );
218
+ }
219
+
169
220
test_tooDistant_constructor () async {
170
221
await resolveTestUnit ('''
171
222
f() => new A(bbbbb: 2);
You can’t perform that action at this time.
0 commit comments