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

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

Issue 2391173003: Catch and suppress expected exceptions in corrections. (Closed)
Patch Set: Created 4 years, 2 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 78939c562c35d2b1b414a09ecedb1bc469155f60..f0e2c0a2ea8238fea80f5d5c9502787a88ec1ba4 100644
--- a/pkg/analysis_server/lib/src/services/correction/fix_internal.dart
+++ b/pkg/analysis_server/lib/src/services/correction/fix_internal.dart
@@ -69,9 +69,13 @@ class DartFixContextImpl extends FixContextImpl implements DartFixContext {
*/
class DefaultFixContributor extends DartFixContributor {
@override
- Future<List<Fix>> internalComputeFixes(DartFixContext context) {
- FixProcessor processor = new FixProcessor(context);
- return processor.compute();
+ Future<List<Fix>> internalComputeFixes(DartFixContext context) async {
+ try {
+ FixProcessor processor = new FixProcessor(context);
+ return processor.compute();
+ } on CancelCorrectionException {
+ return Fix.EMPTY_LIST;
+ }
}
}
@@ -135,7 +139,12 @@ class FixProcessor {
String get eol => utils.endOfLine;
Future<List<Fix>> compute() async {
- utils = new CorrectionUtils(unit);
+ try {
+ utils = new CorrectionUtils(unit);
+ } catch (e) {
+ throw new CancelCorrectionException(exception: e);
+ }
+
errorOffset = error.offset;
errorLength = error.length;
errorEnd = errorOffset + errorLength;

Powered by Google App Engine
This is Rietveld 408576698