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")
51 private final String replacement;
62 private final String
id;
74 private final String description;
82 this.replacement = replacement;
84 this.description = description;
94 ObjectUtilities.
equals(other.replacement, replacement) &&
95 ObjectUtilities.equals(other.id,
id) &&
96 ObjectUtilities.equals(other.description, description);
102 int offset = jsonObject.get(
"offset").getAsInt();
103 int length = jsonObject.get(
"length").getAsInt();
104 String replacement = jsonObject.get(
"replacement").getAsString();
105 String
id = jsonObject.get(
"id") ==
null ? null : jsonObject.get(
"id").getAsString();
106 String description = jsonObject.get(
"description") ==
null ? null : jsonObject.get(
"description").getAsString();
111 if (jsonArray ==
null) {
114 ArrayList<SourceEdit> list =
new ArrayList<SourceEdit>(jsonArray.size());
115 Iterator<JsonElement> iterator = jsonArray.iterator();
116 while (iterator.hasNext()) {
117 list.add(fromJson(iterator.next().getAsJsonObject()));
172 HashCodeBuilder builder =
new HashCodeBuilder();
175 builder.append(replacement);
177 builder.append(description);
178 return builder.toHashCode();
182 JsonObject jsonObject =
new JsonObject();
183 jsonObject.addProperty(
"offset",
offset);
184 jsonObject.addProperty(
"length",
length);
185 jsonObject.addProperty(
"replacement", replacement);
187 jsonObject.addProperty(
"id",
id);
189 if (description !=
null) {
190 jsonObject.addProperty(
"description", description);
197 StringBuilder builder =
new StringBuilder();
199 builder.append(
"offset=");
200 builder.append(
offset +
", ");
201 builder.append(
"length=");
202 builder.append(
length +
", ");
203 builder.append(
"replacement=");
204 builder.append(replacement +
", ");
205 builder.append(
"id=");
206 builder.append(
id +
", ");
207 builder.append(
"description=");
208 builder.append(description);
210 return builder.toString();
SourceEdit(int offset, int length, String replacement, String id, String description)
static List< SourceEdit > fromJsonArray(JsonArray jsonArray)
boolean equals(Object obj)
static SourceEdit fromJson(JsonObject jsonObject)