9package org.dartlang.analysis.server.protocol;
11import java.util.Arrays;
14import com.google.common.collect.Lists;
15import com.google.dart.server.utilities.general.JsonUtilities;
16import com.google.dart.server.utilities.general.ObjectUtilities;
17import com.google.gson.JsonArray;
18import com.google.gson.JsonElement;
19import com.google.gson.JsonObject;
20import com.google.gson.JsonPrimitive;
21import org.apache.commons.lang3.builder.HashCodeBuilder;
22import java.util.ArrayList;
23import java.util.Iterator;
24import org.apache.commons.lang3.StringUtils;
31@SuppressWarnings(
"unused")
65 private final Integer selectionLength;
71 private final String
id;
79 this.linkedEditGroups = linkedEditGroups;
80 this.selection = selection;
81 this.selectionLength = selectionLength;
91 ObjectUtilities.equals(other.edits, edits) &&
92 ObjectUtilities.equals(other.linkedEditGroups, linkedEditGroups) &&
93 ObjectUtilities.equals(other.selection, selection) &&
94 ObjectUtilities.equals(other.selectionLength, selectionLength) &&
95 ObjectUtilities.equals(other.id,
id);
101 String
message = jsonObject.get(
"message").getAsString();
104 Position selection = jsonObject.get(
"selection") ==
null ? null :
Position.
fromJson(jsonObject.get(
"selection").getAsJsonObject());
105 Integer selectionLength = jsonObject.get(
"selectionLength") ==
null ? null : jsonObject.get(
"selectionLength").getAsInt();
106 String
id = jsonObject.get(
"id") ==
null ? null : jsonObject.get(
"id").getAsString();
111 if (jsonArray ==
null) {
114 ArrayList<SourceChange> list =
new ArrayList<SourceChange>(jsonArray.size());
115 Iterator<JsonElement> iterator = jsonArray.iterator();
116 while (iterator.hasNext()) {
117 list.add(fromJson(iterator.next().getAsJsonObject()));
141 return linkedEditGroups;
166 return selectionLength;
171 HashCodeBuilder
builder =
new HashCodeBuilder();
174 builder.append(linkedEditGroups);
176 builder.append(selectionLength);
182 JsonObject jsonObject =
new JsonObject();
183 jsonObject.addProperty(
"message",
message);
184 JsonArray jsonArrayEdits =
new JsonArray();
186 jsonArrayEdits.add(elt.toJson());
188 jsonObject.add(
"edits", jsonArrayEdits);
189 JsonArray jsonArrayLinkedEditGroups =
new JsonArray();
191 jsonArrayLinkedEditGroups.add(elt.toJson());
193 jsonObject.add(
"linkedEditGroups", jsonArrayLinkedEditGroups);
194 if (selection !=
null) {
195 jsonObject.add(
"selection", selection.
toJson());
197 if (selectionLength !=
null) {
198 jsonObject.addProperty(
"selectionLength", selectionLength);
201 jsonObject.addProperty(
"id",
id);
208 StringBuilder
builder =
new StringBuilder();
213 builder.append(StringUtils.join(edits,
", ") +
", ");
214 builder.append(
"linkedEditGroups=");
215 builder.append(StringUtils.join(linkedEditGroups,
", ") +
", ");
217 builder.append(selection +
", ");
218 builder.append(
"selectionLength=");
219 builder.append(selectionLength +
", ");
static List< LinkedEditGroup > fromJsonArray(JsonArray jsonArray)
static Position fromJson(JsonObject jsonObject)
static List< SourceChange > fromJsonArray(JsonArray jsonArray)
List< SourceFileEdit > getEdits()
List< LinkedEditGroup > getLinkedEditGroups()
Integer getSelectionLength()
SourceChange(String message, List< SourceFileEdit > edits, List< LinkedEditGroup > linkedEditGroups, Position selection, Integer selectionLength, String id)
static SourceChange fromJson(JsonObject jsonObject)
boolean equals(Object obj)
static List< SourceFileEdit > fromJsonArray(JsonArray jsonArray)