| Index: pkg/analysis_server/lib/src/services/correction/fix_internal.dart
|
| 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 50e03ab9d41f17722a1d33e70cc242efdd20ab87..0ff70e6780fa60b6437482d7759b815884533100 100644
|
| --- a/pkg/analysis_server/lib/src/services/correction/fix_internal.dart
|
| +++ b/pkg/analysis_server/lib/src/services/correction/fix_internal.dart
|
| @@ -158,6 +158,12 @@ class FixProcessor {
|
| if (errorCode == HintCode.UNNECESSARY_CAST) {
|
| _addFix_removeUnnecessaryCast();
|
| }
|
| + if (errorCode == HintCode.UNUSED_CATCH_CLAUSE) {
|
| + _addFix_removeUnusedCatchClause();
|
| + }
|
| + if (errorCode == HintCode.UNUSED_CATCH_STACK) {
|
| + _addFix_removeUnusedCatchStack();
|
| + }
|
| if (errorCode == HintCode.UNUSED_IMPORT) {
|
| _addFix_removeUnusedImport();
|
| }
|
| @@ -1377,6 +1383,30 @@ class FixProcessor {
|
| _addFix(FixKind.REMOVE_UNNECASSARY_CAST, []);
|
| }
|
|
|
| + void _addFix_removeUnusedCatchClause() {
|
| + if (node is SimpleIdentifier) {
|
| + AstNode catchClause = node.parent;
|
| + if (catchClause is CatchClause &&
|
| + catchClause.exceptionParameter == node) {
|
| + _addRemoveEdit(
|
| + rf.rangeStartStart(catchClause.catchKeyword, catchClause.body));
|
| + _addFix(FixKind.REMOVE_UNUSED_CATCH_CLAUSE, []);
|
| + }
|
| + }
|
| + }
|
| +
|
| + void _addFix_removeUnusedCatchStack() {
|
| + if (node is SimpleIdentifier) {
|
| + AstNode catchClause = node.parent;
|
| + if (catchClause is CatchClause &&
|
| + catchClause.stackTraceParameter == node &&
|
| + catchClause.exceptionParameter != null) {
|
| + _addRemoveEdit(rf.rangeEndEnd(catchClause.exceptionParameter, node));
|
| + _addFix(FixKind.REMOVE_UNUSED_CATCH_STACK, []);
|
| + }
|
| + }
|
| + }
|
| +
|
| void _addFix_removeUnusedImport() {
|
| // prepare ImportDirective
|
| ImportDirective importDirective =
|
|
|