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

Unified Diff: pkg/analysis_server/lib/src/services/correction/assist_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/assist_internal.dart
diff --git a/pkg/analysis_server/lib/src/services/correction/assist_internal.dart b/pkg/analysis_server/lib/src/services/correction/assist_internal.dart
index 42ccd71785ca80d72a1719a0eb1d2a659f4067e8..75d52f191d4df158d6f85fd2d3e54a5cec566e8a 100644
--- a/pkg/analysis_server/lib/src/services/correction/assist_internal.dart
+++ b/pkg/analysis_server/lib/src/services/correction/assist_internal.dart
@@ -87,7 +87,12 @@ class AssistProcessor {
String get eol => utils.endOfLine;
Future<List<Assist>> compute() async {
- utils = new CorrectionUtils(unit);
+ try {
+ utils = new CorrectionUtils(unit);
+ } catch (e) {
+ throw new CancelCorrectionException(exception: e);
+ }
+
node = new NodeLocator(selectionOffset, selectionEnd).searchWithin(unit);
if (node == null) {
return assists;
@@ -2239,9 +2244,13 @@ class AssistProcessor {
*/
class DefaultAssistContributor extends DartAssistContributor {
@override
- Future<List<Assist>> internalComputeAssists(DartAssistContext context) {
- AssistProcessor processor = new AssistProcessor(context);
- return processor.compute();
+ Future<List<Assist>> internalComputeAssists(DartAssistContext context) async {
+ try {
+ AssistProcessor processor = new AssistProcessor(context);
+ return processor.compute();
+ } on CancelCorrectionException {
+ return Assist.EMPTY_LIST;
+ }
}
}

Powered by Google App Engine
This is Rietveld 408576698