bulk fix support for `RemoveUnusedCatchClause`

Change-Id: I2da4a200b31e6dbae5fcac476541e3517f79ccae
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/217440
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
diff --git a/pkg/analysis_server/lib/src/services/correction/dart/remove_unused_catch_clause.dart b/pkg/analysis_server/lib/src/services/correction/dart/remove_unused_catch_clause.dart
index b3a9af7..09a3c41 100644
--- a/pkg/analysis_server/lib/src/services/correction/dart/remove_unused_catch_clause.dart
+++ b/pkg/analysis_server/lib/src/services/correction/dart/remove_unused_catch_clause.dart
@@ -11,9 +11,18 @@
 
 class RemoveUnusedCatchClause extends CorrectionProducer {
   @override
+  bool get canBeAppliedInBulk => true;
+
+  @override
+  bool get canBeAppliedToFile => true;
+
+  @override
   FixKind get fixKind => DartFixKind.REMOVE_UNUSED_CATCH_CLAUSE;
 
   @override
+  FixKind get multiFixKind => DartFixKind.REMOVE_UNUSED_CATCH_CLAUSE_MULTI;
+
+  @override
   Future<void> compute(ChangeBuilder builder) async {
     var catchClause = node.parent;
     if (catchClause is! CatchClause) {
diff --git a/pkg/analysis_server/lib/src/services/correction/fix.dart b/pkg/analysis_server/lib/src/services/correction/fix.dart
index 573c7a7..e344b12 100644
--- a/pkg/analysis_server/lib/src/services/correction/fix.dart
+++ b/pkg/analysis_server/lib/src/services/correction/fix.dart
@@ -1084,6 +1084,11 @@
     DartFixKindPriority.DEFAULT,
     "Remove unused 'catch' clause",
   );
+  static const REMOVE_UNUSED_CATCH_CLAUSE_MULTI = FixKind(
+    'dart.fix.remove.unusedCatchClause.multi',
+    DartFixKindPriority.IN_FILE,
+    "Remove unused 'catch' clauses in file",
+  );
   static const REMOVE_UNUSED_CATCH_STACK = FixKind(
     'dart.fix.remove.unusedCatchStack',
     DartFixKindPriority.DEFAULT,
diff --git a/pkg/analysis_server/test/src/services/correction/fix/remove_unused_catch_clause_test.dart b/pkg/analysis_server/test/src/services/correction/fix/remove_unused_catch_clause_test.dart
index d18763d..171e2e1 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/remove_unused_catch_clause_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/remove_unused_catch_clause_test.dart
@@ -3,6 +3,7 @@
 // BSD-style license that can be found in the LICENSE file.
 
 import 'package:analysis_server/src/services/correction/fix.dart';
+import 'package:analyzer/src/error/codes.dart';
 import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
 import 'package:test_reflective_loader/test_reflective_loader.dart';
 
@@ -11,10 +12,38 @@
 void main() {
   defineReflectiveSuite(() {
     defineReflectiveTests(RemoveUnusedCatchClauseTest);
+    defineReflectiveTests(RemoveUnusedCatchClauseMultiTest);
   });
 }
 
 @reflectiveTest
+class RemoveUnusedCatchClauseMultiTest extends FixProcessorTest {
+  @override
+  FixKind get kind => DartFixKind.REMOVE_UNUSED_CATCH_CLAUSE_MULTI;
+
+  Future<void> test_singleFile() async {
+    await resolveTestCode('''
+main() {
+  try {
+    throw 42;
+  } on int catch (i) {
+  } on Error catch (e) {
+  }
+}
+''');
+    await assertHasFixAllFix(HintCode.UNUSED_CATCH_CLAUSE, '''
+main() {
+  try {
+    throw 42;
+  } on int {
+  } on Error {
+  }
+}
+''');
+  }
+}
+
+@reflectiveTest
 class RemoveUnusedCatchClauseTest extends FixProcessorTest {
   @override
   FixKind get kind => DartFixKind.REMOVE_UNUSED_CATCH_CLAUSE;