Skip to content

Commit 7ead4b5

Browse files
pqCommit Queue
authored and
Commit Queue
committed
quick fix for MISSING_TYPEDEF_PARAMETERS
See: #55917 Change-Id: I9b81940c1c515bf923ceecb83d5aaad1d416dab1 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/370482 Commit-Queue: Phil Quitslund <[email protected]> Reviewed-by: Brian Wilkerson <[email protected]>
1 parent 49e0c0b commit 7ead4b5

File tree

4 files changed

+23
-6
lines changed

4 files changed

+23
-6
lines changed

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,17 @@ class AddEmptyArgumentList extends ResolvedCorrectionProducer {
2424
@override
2525
Future<void> compute(ChangeBuilder builder) async {
2626
var node = this.node;
27-
if (node is! AnnotationImpl) return;
27+
int? offset;
28+
if (node is AnnotationImpl) {
29+
offset = node.end;
30+
} else if (node is FunctionTypeAlias) {
31+
// endToken is the trailing `;`.
32+
offset = node.endToken.previous?.end;
33+
}
34+
if (offset == null) return;
2835

2936
await builder.addDartFileEdit(file, (builder) {
30-
builder.addSimpleInsertion(node.end, '()');
37+
builder.addSimpleInsertion(offset!, '()');
3138
});
3239
}
3340
}

pkg/analysis_server/lib/src/services/correction/error_fix_status.yaml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
#
4646
# Stats:
4747
# - 42 "needsEvaluation"
48-
# - 334 "needsFix"
48+
# - 331 "needsFix"
4949
# - 417 "hasFix"
5050
# - 516 "noFix"
5151

@@ -3060,9 +3060,7 @@ ParserErrorCode.MISSING_TERMINATOR_FOR_PARAMETER_GROUP:
30603060
notes: |-
30613061
Add the missing terminator.
30623062
ParserErrorCode.MISSING_TYPEDEF_PARAMETERS:
3063-
status: needsFix
3064-
notes: |-
3065-
Add an empty parameter list.
3063+
status: hasFix
30663064
ParserErrorCode.MISSING_VARIABLE_IN_FOR_EACH:
30673065
status: noFix
30683066
ParserErrorCode.MIXED_PARAMETER_GROUPS:

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1452,6 +1452,9 @@ final _builtInNonLintProducers = <ErrorCode, List<ProducerGenerator>>{
14521452
ParserErrorCode.MISSING_FUNCTION_BODY: [
14531453
ConvertIntoBlockBody.missingBody,
14541454
],
1455+
ParserErrorCode.MISSING_TYPEDEF_PARAMETERS: [
1456+
AddEmptyArgumentList.new,
1457+
],
14551458
ParserErrorCode.MIXIN_DECLARES_CONSTRUCTOR: [
14561459
RemoveConstructor.new,
14571460
],

pkg/analysis_server/test/src/services/correction/fix/add_empty_argument_list_test.dart

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,15 @@ class A {
6161
}
6262
@A()
6363
main() {}
64+
''');
65+
}
66+
67+
Future<void> test_missingTypedefParameters() async {
68+
await resolveTestCode('''
69+
typedef F<E>;
70+
''');
71+
await assertHasFix('''
72+
typedef F<E>();
6473
''');
6574
}
6675
}

0 commit comments

Comments
 (0)