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;
29@SuppressWarnings(
"unused")
50 private final String returnType;
60 private final boolean canCreateGetter;
79 private final int[] lengths;
87 this.returnType = returnType;
89 this.canCreateGetter = canCreateGetter;
90 this.parameters = parameters;
92 this.lengths = lengths;
102 ObjectUtilities.equals(other.returnType, returnType) &&
103 ObjectUtilities.equals(other.names,
names) &&
104 other.canCreateGetter == canCreateGetter &&
105 ObjectUtilities.equals(other.parameters, parameters) &&
106 Arrays.equals(other.offsets,
offsets) &&
107 Arrays.equals(other.lengths, lengths);
113 int offset = jsonObject.get(
"offset").getAsInt();
114 int length = jsonObject.get(
"length").getAsInt();
115 String returnType = jsonObject.get(
"returnType").getAsString();
116 List<String> names = JsonUtilities.decodeStringList(jsonObject.get(
"names").getAsJsonArray());
117 boolean canCreateGetter = jsonObject.get(
"canCreateGetter").getAsBoolean();
119 int[]
offsets = JsonUtilities.decodeIntArray(jsonObject.get(
"offsets").getAsJsonArray());
120 int[] lengths = JsonUtilities.decodeIntArray(jsonObject.get(
"lengths").getAsJsonArray());
125 if (jsonArray ==
null) {
128 ArrayList<ExtractMethodFeedback> list =
new ArrayList<ExtractMethodFeedback>(jsonArray.size());
129 Iterator<JsonElement> iterator = jsonArray.iterator();
130 while (iterator.hasNext()) {
131 list.add(fromJson(iterator.next().getAsJsonObject()));
140 return canCreateGetter;
199 HashCodeBuilder
builder =
new HashCodeBuilder();
204 builder.append(canCreateGetter);
212 JsonObject jsonObject =
new JsonObject();
213 jsonObject.addProperty(
"offset",
offset);
214 jsonObject.addProperty(
"length",
length);
215 jsonObject.addProperty(
"returnType", returnType);
216 JsonArray jsonArrayNames =
new JsonArray();
217 for (String elt :
names) {
218 jsonArrayNames.add(
new JsonPrimitive(elt));
220 jsonObject.add(
"names", jsonArrayNames);
221 jsonObject.addProperty(
"canCreateGetter", canCreateGetter);
222 JsonArray jsonArrayParameters =
new JsonArray();
224 jsonArrayParameters.add(elt.toJson());
226 jsonObject.add(
"parameters", jsonArrayParameters);
227 JsonArray jsonArrayOffsets =
new JsonArray();
229 jsonArrayOffsets.add(
new JsonPrimitive(elt));
231 jsonObject.add(
"offsets", jsonArrayOffsets);
232 JsonArray jsonArrayLengths =
new JsonArray();
233 for (
int elt : lengths) {
234 jsonArrayLengths.add(
new JsonPrimitive(elt));
236 jsonObject.add(
"lengths", jsonArrayLengths);
242 StringBuilder
builder =
new StringBuilder();
249 builder.append(returnType +
", ");
252 builder.append(
"canCreateGetter=");
253 builder.append(canCreateGetter +
", ");
255 builder.append(StringUtils.join(parameters,
", ") +
", ");
259 builder.append(StringUtils.join(lengths,
", "));
static List< RefactoringMethodParameter > fromJsonArray(JsonArray jsonArray)
static const char *const names[]