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

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

Issue 247893004: Serialize AnalysisErrors to JSON in the analysis server. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 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/analysis_server.dart
diff --git a/pkg/analysis_server/lib/src/analysis_server.dart b/pkg/analysis_server/lib/src/analysis_server.dart
index cb6406e5d3765bf603163913f078ffcdb0de648a..f1c1d3f22b5c188cbfa97dfdfa6de23cc0496565 100644
--- a/pkg/analysis_server/lib/src/analysis_server.dart
+++ b/pkg/analysis_server/lib/src/analysis_server.dart
@@ -10,6 +10,7 @@ import 'package:analysis_server/src/analysis_logger.dart';
import 'package:analysis_server/src/channel.dart';
import 'package:analysis_server/src/protocol.dart';
import 'package:analyzer/src/generated/engine.dart';
+import 'package:analyzer/src/generated/error.dart';
/**
* Instances of the class [AnalysisServer] implement a server that listens on a
@@ -188,11 +189,31 @@ class AnalysisServer {
ChangeNotice notice = notices[i];
Notification notification = new Notification(ERROR_NOTIFICATION_NAME);
notification.setParameter(SOURCE_PARAM, notice.source.encoding);
- notification.setParameter(ERRORS_PARAM, notice.errors);
+ notification.setParameter(ERRORS_PARAM, new List.from(notice.errors.map(
scheglov 2014/04/23 19:20:56 You could use .map(f).toList().
Paul Berry 2014/04/23 20:36:26 Done.
+ errorToJson)));
sendNotification(notification);
}
}
+ static Map<String, Object> errorToJson(AnalysisError analysisError) {
+ // TODO(paulberry): move this function into the AnalysisError class.
+
+ // TODO(paulberry): add "ordinal" to errorCode interface so that this trick
+ // with dynamic is unnecessary.
scheglov 2014/04/23 19:20:56 You could probably cast it to Enum. (errorCode as
Paul Berry 2014/04/23 20:36:26 Done.
+ dynamic errorCode = analysisError.errorCode;
+ Map<String, Object> result = {
+ 'source': analysisError.source.encoding,
+ 'errorCode': errorCode.ordinal,
scheglov 2014/04/23 19:20:56 I don't think that using "ordinal" is valid at all
Paul Berry 2014/04/23 20:36:26 Good point. I've updated the TODO comment accordi
Brian Wilkerson 2014/04/24 15:44:05 There has been some discussion in the past about c
+ 'offset': analysisError.offset,
+ 'length': analysisError.length,
+ 'message': analysisError.message
+ };
+ if (analysisError.correction != null) {
+ result['correction'] = analysisError.correction;
+ }
+ return result;
+ }
+
/**
* Send the given [notification] to the client.
*/
« no previous file with comments | « no previous file | pkg/analysis_server/test/analysis_server_test.dart » ('j') | pkg/analysis_server/test/analysis_server_test.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698