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

Unified Diff: editor/tools/plugins/com.google.dart.server/src/com/google/dart/server/generated/types/SourceChange.java

Issue 482573004: Change analysis server protocol to omit empty lists when optional. (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: editor/tools/plugins/com.google.dart.server/src/com/google/dart/server/generated/types/SourceChange.java
diff --git a/editor/tools/plugins/com.google.dart.server/src/com/google/dart/server/generated/types/SourceChange.java b/editor/tools/plugins/com.google.dart.server/src/com/google/dart/server/generated/types/SourceChange.java
index cc021607f9d684996164dd746653478cd88a6956..639edd5dfb3344b3c82c14bd42be9f498176138c 100644
--- a/editor/tools/plugins/com.google.dart.server/src/com/google/dart/server/generated/types/SourceChange.java
+++ b/editor/tools/plugins/com.google.dart.server/src/com/google/dart/server/generated/types/SourceChange.java
@@ -87,8 +87,8 @@ public class SourceChange {
public static SourceChange fromJson(JsonObject jsonObject) {
String message = jsonObject.get("message").getAsString();
- List<SourceFileEdit> edits = SourceFileEdit.fromJsonArray(jsonObject.get("edits").getAsJsonArray());
- List<LinkedEditGroup> linkedEditGroups = LinkedEditGroup.fromJsonArray(jsonObject.get("linkedEditGroups").getAsJsonArray());
+ List<SourceFileEdit> edits = jsonObject.get("edits") == null ? null : SourceFileEdit.fromJsonArray(jsonObject.get("edits").getAsJsonArray());
+ List<LinkedEditGroup> linkedEditGroups = jsonObject.get("linkedEditGroups") == null ? null : LinkedEditGroup.fromJsonArray(jsonObject.get("linkedEditGroups").getAsJsonArray());
Position selection = jsonObject.get("selection") == null ? null : Position.fromJson(jsonObject.get("selection").getAsJsonObject());
return new SourceChange(message, edits, linkedEditGroups, selection);
}
@@ -136,16 +136,20 @@ public class SourceChange {
public JsonObject toJson() {
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty("message", message);
- JsonArray jsonArrayEdits = new JsonArray();
- for(SourceFileEdit elt : edits) {
- jsonArrayEdits.add(elt.toJson());
+ if (edits != null) {
+ JsonArray jsonArrayEdits = new JsonArray();
+ for(SourceFileEdit elt : edits) {
+ jsonArrayEdits.add(elt.toJson());
+ }
+ jsonObject.add("edits", jsonArrayEdits);
}
- jsonObject.add("edits", jsonArrayEdits);
- JsonArray jsonArrayLinkedEditGroups = new JsonArray();
- for(LinkedEditGroup elt : linkedEditGroups) {
- jsonArrayLinkedEditGroups.add(elt.toJson());
+ if (linkedEditGroups != null) {
+ JsonArray jsonArrayLinkedEditGroups = new JsonArray();
+ for(LinkedEditGroup elt : linkedEditGroups) {
+ jsonArrayLinkedEditGroups.add(elt.toJson());
+ }
+ jsonObject.add("linkedEditGroups", jsonArrayLinkedEditGroups);
}
- jsonObject.add("linkedEditGroups", jsonArrayLinkedEditGroups);
if (selection != null) {
jsonObject.add("selection", selection.toJson());
}

Powered by Google App Engine
This is Rietveld 408576698