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

Unified Diff: pkg/analysis_server/lib/src/edit/edit_domain.dart

Issue 1099633004: Fix error handling for formatting and update the spec (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 8 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/edit/edit_domain.dart
diff --git a/pkg/analysis_server/lib/src/edit/edit_domain.dart b/pkg/analysis_server/lib/src/edit/edit_domain.dart
index cb5aa86065b9b11b13ef2244c20e7a4e9af0c2a2..8e11600a7c1544ab2f0787a4560bd5d2ee987e78 100644
--- a/pkg/analysis_server/lib/src/edit/edit_domain.dart
+++ b/pkg/analysis_server/lib/src/edit/edit_domain.dart
@@ -98,7 +98,12 @@ class EditDomainHandler implements RequestHandler {
selectionStart: start,
selectionLength: length);
DartFormatter formatter = new DartFormatter();
- SourceCode formattedResult = formatter.formatSource(code);
+ SourceCode formattedResult;
+ try {
+ formattedResult = formatter.formatSource(code);
+ } on FormatterException {
+ return new Response.formatWithErrors(request);
+ }
String formattedSource = formattedResult.text;
List<SourceEdit> edits = <SourceEdit>[];
@@ -122,8 +127,8 @@ class EditDomainHandler implements RequestHandler {
newLength = 0;
}
- return new EditFormatResult(edits, newStart,
- newLength).toResponse(request.id);
+ return new EditFormatResult(edits, newStart, newLength)
+ .toResponse(request.id);
}
Response getAssists(Request request) {
@@ -133,8 +138,8 @@ class EditDomainHandler implements RequestHandler {
Source source = pair.source;
List<SourceChange> changes = <SourceChange>[];
if (context != null && source != null) {
- List<Assist> assists = computeAssists(plugin, context,
- source, params.offset, params.length);
+ List<Assist> assists =
+ computeAssists(plugin, context, source, params.offset, params.length);
assists.forEach((Assist assist) {
changes.add(assist.change);
});

Powered by Google App Engine
This is Rietveld 408576698