quick fix for `REPRESENTATION_FIELD_TRAILING_COMMA`

See: https://github.com/dart-lang/sdk/issues/55917

Change-Id: Ib278e49749618325c8c5fcc7a5627840f87c4553
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/371401
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Auto-Submit: Phil Quitslund <pquitslund@google.com>
diff --git a/pkg/analysis_server/lib/src/services/correction/dart/remove_comma.dart b/pkg/analysis_server/lib/src/services/correction/dart/remove_comma.dart
index f7da8ca..1dd3ba0 100644
--- a/pkg/analysis_server/lib/src/services/correction/dart/remove_comma.dart
+++ b/pkg/analysis_server/lib/src/services/correction/dart/remove_comma.dart
@@ -9,15 +9,23 @@
 import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
 
 class RemoveComma extends ResolvedCorrectionProducer {
+  final String commaKind;
   final String targetDescription;
 
   RemoveComma.emptyRecordLiteral({required CorrectionProducerContext context})
       : this._(context: context, targetDescription: 'empty record literals');
-
   RemoveComma.emptyRecordType({required CorrectionProducerContext context})
       : this._(context: context, targetDescription: 'empty record types');
+  RemoveComma.representationField({required CorrectionProducerContext context})
+      : this._(
+            context: context,
+            commaKind: 'trailing ',
+            targetDescription: 'representation fields');
 
-  RemoveComma._({required super.context, required this.targetDescription});
+  RemoveComma._(
+      {required super.context,
+      this.commaKind = '',
+      required this.targetDescription});
 
   @override
   CorrectionApplicability get applicability =>
@@ -27,7 +35,7 @@
   FixKind get fixKind => DartFixKind.REMOVE_COMMA;
 
   @override
-  List<String>? get multiFixArguments => [targetDescription];
+  List<String>? get multiFixArguments => [commaKind, targetDescription];
 
   @override
   FixKind get multiFixKind => DartFixKind.REMOVE_COMMA_MULTI;
diff --git a/pkg/analysis_server/lib/src/services/correction/error_fix_status.yaml b/pkg/analysis_server/lib/src/services/correction/error_fix_status.yaml
index dc21030..0356c88 100644
--- a/pkg/analysis_server/lib/src/services/correction/error_fix_status.yaml
+++ b/pkg/analysis_server/lib/src/services/correction/error_fix_status.yaml
@@ -45,8 +45,8 @@
 #
 # Stats:
 # -  42 "needsEvaluation"
-# - 323 "needsFix"
-# - 424 "hasFix"
+# - 322 "needsFix"
+# - 425 "hasFix"
 # - 517 "noFix"
 
 AnalysisOptionsErrorCode.INCLUDED_FILE_PARSE_ERROR:
@@ -3186,9 +3186,7 @@
   status: needsFix
   notes: Remove it.
 ParserErrorCode.REPRESENTATION_FIELD_TRAILING_COMMA:
-  status: needsFix
-  notes: |-
-    Remove the comma.
+  status: hasFix
 ParserErrorCode.SEALED_ENUM:
   status: needsEvaluation
 ParserErrorCode.SEALED_MIXIN:
diff --git a/pkg/analysis_server/lib/src/services/correction/fix.dart b/pkg/analysis_server/lib/src/services/correction/fix.dart
index 803970f..e72157f 100644
--- a/pkg/analysis_server/lib/src/services/correction/fix.dart
+++ b/pkg/analysis_server/lib/src/services/correction/fix.dart
@@ -1026,7 +1026,7 @@
   static const REMOVE_COMMA_MULTI = FixKind(
     'dart.fix.remove.comma.multi',
     DartFixKindPriority.IN_FILE,
-    'Remove commas from {0} everywhere in file',
+    'Remove {0}commas from {1} everywhere in file',
   );
   static const REMOVE_COMPARISON = FixKind(
     'dart.fix.remove.comparison',
diff --git a/pkg/analysis_server/lib/src/services/correction/fix_internal.dart b/pkg/analysis_server/lib/src/services/correction/fix_internal.dart
index ce8c8ee..b465e41 100644
--- a/pkg/analysis_server/lib/src/services/correction/fix_internal.dart
+++ b/pkg/analysis_server/lib/src/services/correction/fix_internal.dart
@@ -1487,6 +1487,9 @@
   ParserErrorCode.RECORD_TYPE_ONE_POSITIONAL_NO_TRAILING_COMMA: [
     AddTrailingComma.new,
   ],
+  ParserErrorCode.REPRESENTATION_FIELD_TRAILING_COMMA: [
+    RemoveComma.representationField,
+  ],
   ParserErrorCode.SEALED_MIXIN: [
     RemoveLexeme.modifier,
   ],
diff --git a/pkg/analysis_server/test/src/services/correction/fix/remove_comma_test.dart b/pkg/analysis_server/test/src/services/correction/fix/remove_comma_test.dart
index e94a586..a7dc295 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/remove_comma_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/remove_comma_test.dart
@@ -59,4 +59,13 @@
 ()? f() => null;
 ''');
   }
+
+  Future<void> test_representationFieldTrailingComma() async {
+    await resolveTestCode('''
+extension type A(int i,) {}
+''');
+    await assertHasFix('''
+extension type A(int i) {}
+''');
+  }
 }