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

Unified Diff: pkg/analysis_server/test/services/correction/fix_test.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
« no previous file with comments | « pkg/analysis_server/lib/src/services/correction/fix_internal.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analysis_server/test/services/correction/fix_test.dart
diff --git a/pkg/analysis_server/test/services/correction/fix_test.dart b/pkg/analysis_server/test/services/correction/fix_test.dart
index ec60d939a3837eb3dd6abfe104ef4ac1e5531f34..aa12e4d5c48bb934a56f42a81bd286bb5fc16a30 100644
--- a/pkg/analysis_server/test/services/correction/fix_test.dart
+++ b/pkg/analysis_server/test/services/correction/fix_test.dart
@@ -26,7 +26,13 @@ typedef bool AnalysisErrorFilter(AnalysisError error);
@reflectiveTest
class FixProcessorTest extends AbstractSingleUnitTest {
- AnalysisErrorFilter errorFilter = null;
+ AnalysisErrorFilter errorFilter = (AnalysisError error) {
+ return error.errorCode != HintCode.UNUSED_CATCH_CLAUSE &&
+ error.errorCode != HintCode.UNUSED_CATCH_STACK &&
+ error.errorCode != HintCode.UNUSED_ELEMENT &&
+ error.errorCode != HintCode.UNUSED_FIELD &&
+ error.errorCode != HintCode.UNUSED_LOCAL_VARIABLE;
+ };
Fix fix;
SourceChange change;
@@ -2439,6 +2445,46 @@ main(Object p) {
''');
}
+ void test_removeUnusedCatchClause() {
+ errorFilter = (AnalysisError error) => true;
+ resolveTestUnit('''
+main() {
+ try {
+ throw 42;
+ } on int catch (e) {
+ }
+}
+''');
+ assertHasFix(FixKind.REMOVE_UNUSED_CATCH_CLAUSE, '''
+main() {
+ try {
+ throw 42;
+ } on int {
+ }
+}
+''');
+ }
+
+ void test_removeUnusedCatchStack() {
+ errorFilter = (AnalysisError error) => true;
+ resolveTestUnit('''
+main() {
+ try {
+ throw 42;
+ } catch (e, stack) {
+ }
+}
+''');
+ assertHasFix(FixKind.REMOVE_UNUSED_CATCH_STACK, '''
+main() {
+ try {
+ throw 42;
+ } catch (e) {
+ }
+}
+''');
+ }
+
void test_removeUnusedImport() {
resolveTestUnit('''
import 'dart:math';
@@ -3440,13 +3486,6 @@ main() {
AnalysisError _findErrorToFix() {
List<AnalysisError> errors = context.computeErrors(testSource);
- errors.removeWhere((error) {
- return error.errorCode == HintCode.UNUSED_CATCH_CLAUSE ||
- error.errorCode == HintCode.UNUSED_CATCH_STACK ||
- error.errorCode == HintCode.UNUSED_ELEMENT ||
- error.errorCode == HintCode.UNUSED_FIELD ||
- error.errorCode == HintCode.UNUSED_LOCAL_VARIABLE;
- });
if (errorFilter != null) {
errors = errors.where(errorFilter).toList();
}
« no previous file with comments | « pkg/analysis_server/lib/src/services/correction/fix_internal.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698