Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(29)

Unified Diff: pkg/analysis_server/lib/src/services/correction/fix_internal.dart

Issue 1020853006: Quick Fixes for unused catch clause/stack. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 =
« no previous file with comments | « pkg/analysis_server/lib/src/services/correction/fix.dart ('k') | pkg/analysis_server/test/services/correction/fix_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698