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

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

Issue 308923003: Initial implementation for 'analysis.setSubscriptions' API. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 7 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/protocol.dart
diff --git a/pkg/analysis_server/lib/src/protocol.dart b/pkg/analysis_server/lib/src/protocol.dart
index 07f40085d2e5a8af8b0c4881b486d32edabb84ef..9efbf64f92b4c83ab884d6cb8a25b2f81ab0d878 100644
--- a/pkg/analysis_server/lib/src/protocol.dart
+++ b/pkg/analysis_server/lib/src/protocol.dart
@@ -365,6 +365,41 @@ class RequestDatum {
}
return datum;
}
+
+ /**
+ * Determine if the datum is a map whose values are all string lists.
+ *
+ * Note: we can safely assume that the keys are all strings, since JSON maps
+ * cannot have any other key type.
+ */
+ bool isStringListMap() {
+ if (datum is! Map) {
+ return false;
+ }
+ for (var value in datum.values) {
+ if (value is! List) {
+ return false;
+ }
+ for (var listItem in value) {
+ if (listItem is! String) {
+ return false;
+ }
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Validate that the datum is a map from strings to string listss, and return
+ * it.
+ */
+ Map<String, List<String>> asStringListMap() {
+ if (!isStringListMap()) {
+ throw new RequestFailure(new Response.invalidParameter(request, path,
+ "be a string list map"));
+ }
+ return datum;
+ }
}
/**
@@ -466,6 +501,14 @@ class Response {
: this(requestId, new RequestError(-9, message));
/**
+ * Initialize a newly created instance to represent an error condition caused
+ * by a `analysis.setSubscriptions` [request] that includes an unknown
+ * analysis service name.
+ */
+ Response.unknownAnalysisService(Request request, String name)
+ : this(request.id, new RequestError(-10, 'Unknown analysis service: "$name"'));
+
+ /**
* Initialize a newly created instance based upon the given JSON data
*/
factory Response.fromJson(Map<String, Object> json) {
« no previous file with comments | « pkg/analysis_server/lib/src/domain_analysis.dart ('k') | pkg/analysis_server/test/domain_analysis_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698