| 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) {
|
|
|