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

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

Issue 456613004: Integration test search.getTypeHierarchy and make some minor fixes. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 4 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 8c0ae6d91119a792f079229a547bb194fe93634a..894dbc6f3e5d922780af8a10cab0004847028ca7 100644
--- a/pkg/analysis_server/lib/src/protocol.dart
+++ b/pkg/analysis_server/lib/src/protocol.dart
@@ -501,10 +501,10 @@ class Response {
final RequestError error;
/**
- * A table mapping the names of result fields to their values. The table
- * should be empty if there was an error.
+ * A table mapping the names of result fields to their values. Should be
+ * null if there is no result to send.
*/
- final Map<String, Object> result = new HashMap<String, Object>();
+ Map<String, Object> result;
/**
* Initialize a newly created instance to represent a response to a request
@@ -631,17 +631,27 @@ class Response {
* Return the value of the result field with the given [name].
*/
Object getResult(String name) {
- return result[name];
+ return result == null ? null : result[name];
}
/**
* Set the value of the result field with the given [name] to the given [value].
*/
void setResult(String name, Object value) {
+ if (result == null) {
+ result = new HashMap<String, Object>();
+ }
result[name] = _toJson(value);
}
/**
+ * Set the result to be an empty map.
+ */
+ void setEmptyResult() {
+ result = new HashMap<String, Object>();
+ }
+
+ /**
* Return a table representing the structure of the Json object that will be
* sent to the client to represent this response.
*/
@@ -651,7 +661,7 @@ class Response {
if (error != null) {
jsonObject[ERROR] = error.toJson();
}
- if (!result.isEmpty) {
+ if (result != null) {
jsonObject[RESULT] = result;
}
return jsonObject;

Powered by Google App Engine
This is Rietveld 408576698