Skip to content

Commit dcf72c0

Browse files
pqCommit Queue
authored and
Commit Queue
committed
quick fix for REPRESENTATION_FIELD_TRAILING_COMMA
See: #55917 Change-Id: Ib278e49749618325c8c5fcc7a5627840f87c4553 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/371401 Commit-Queue: Brian Wilkerson <[email protected]> Reviewed-by: Brian Wilkerson <[email protected]> Auto-Submit: Phil Quitslund <[email protected]>
1 parent 1ea71b4 commit dcf72c0

File tree

5 files changed

+27
-9
lines changed

5 files changed

+27
-9
lines changed

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

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,23 @@ import 'package:analyzer_plugin/utilities/change_builder/change_builder_core.dar
99
import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
1010

1111
class RemoveComma extends ResolvedCorrectionProducer {
12+
final String commaKind;
1213
final String targetDescription;
1314

1415
RemoveComma.emptyRecordLiteral({required CorrectionProducerContext context})
1516
: this._(context: context, targetDescription: 'empty record literals');
16-
1717
RemoveComma.emptyRecordType({required CorrectionProducerContext context})
1818
: this._(context: context, targetDescription: 'empty record types');
19+
RemoveComma.representationField({required CorrectionProducerContext context})
20+
: this._(
21+
context: context,
22+
commaKind: 'trailing ',
23+
targetDescription: 'representation fields');
1924

20-
RemoveComma._({required super.context, required this.targetDescription});
25+
RemoveComma._(
26+
{required super.context,
27+
this.commaKind = '',
28+
required this.targetDescription});
2129

2230
@override
2331
CorrectionApplicability get applicability =>
@@ -27,7 +35,7 @@ class RemoveComma extends ResolvedCorrectionProducer {
2735
FixKind get fixKind => DartFixKind.REMOVE_COMMA;
2836

2937
@override
30-
List<String>? get multiFixArguments => [targetDescription];
38+
List<String>? get multiFixArguments => [commaKind, targetDescription];
3139

3240
@override
3341
FixKind get multiFixKind => DartFixKind.REMOVE_COMMA_MULTI;

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

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@
4545
#
4646
# Stats:
4747
# - 42 "needsEvaluation"
48-
# - 323 "needsFix"
49-
# - 424 "hasFix"
48+
# - 322 "needsFix"
49+
# - 425 "hasFix"
5050
# - 517 "noFix"
5151

5252
AnalysisOptionsErrorCode.INCLUDED_FILE_PARSE_ERROR:
@@ -3186,9 +3186,7 @@ ParserErrorCode.REPRESENTATION_FIELD_MODIFIER:
31863186
status: needsFix
31873187
notes: Remove it.
31883188
ParserErrorCode.REPRESENTATION_FIELD_TRAILING_COMMA:
3189-
status: needsFix
3190-
notes: |-
3191-
Remove the comma.
3189+
status: hasFix
31923190
ParserErrorCode.SEALED_ENUM:
31933191
status: needsEvaluation
31943192
ParserErrorCode.SEALED_MIXIN:

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1026,7 +1026,7 @@ class DartFixKind {
10261026
static const REMOVE_COMMA_MULTI = FixKind(
10271027
'dart.fix.remove.comma.multi',
10281028
DartFixKindPriority.IN_FILE,
1029-
'Remove commas from {0} everywhere in file',
1029+
'Remove {0}commas from {1} everywhere in file',
10301030
);
10311031
static const REMOVE_COMPARISON = FixKind(
10321032
'dart.fix.remove.comparison',

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1487,6 +1487,9 @@ final _builtInNonLintProducers = <ErrorCode, List<ProducerGenerator>>{
14871487
ParserErrorCode.RECORD_TYPE_ONE_POSITIONAL_NO_TRAILING_COMMA: [
14881488
AddTrailingComma.new,
14891489
],
1490+
ParserErrorCode.REPRESENTATION_FIELD_TRAILING_COMMA: [
1491+
RemoveComma.representationField,
1492+
],
14901493
ParserErrorCode.SEALED_MIXIN: [
14911494
RemoveLexeme.modifier,
14921495
],

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,15 @@ f() {
5757
''');
5858
await assertHasFix('''
5959
()? f() => null;
60+
''');
61+
}
62+
63+
Future<void> test_representationFieldTrailingComma() async {
64+
await resolveTestCode('''
65+
extension type A(int i,) {}
66+
''');
67+
await assertHasFix('''
68+
extension type A(int i) {}
6069
''');
6170
}
6271
}

0 commit comments

Comments
 (0)