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")
40 private final int[] coveringExpressionOffsets;
46 private final int[] coveringExpressionLengths;
63 private final int[] lengths;
69 this.coveringExpressionOffsets = coveringExpressionOffsets;
70 this.coveringExpressionLengths = coveringExpressionLengths;
73 this.lengths = lengths;
81 Arrays.
equals(other.coveringExpressionOffsets, coveringExpressionOffsets) &&
82 Arrays.equals(other.coveringExpressionLengths, coveringExpressionLengths) &&
83 ObjectUtilities.equals(other.names,
names) &&
84 Arrays.equals(other.offsets,
offsets) &&
85 Arrays.equals(other.lengths, lengths);
91 int[] coveringExpressionOffsets = jsonObject.get(
"coveringExpressionOffsets") ==
null ? null : JsonUtilities.decodeIntArray(jsonObject.get(
"coveringExpressionOffsets").getAsJsonArray());
92 int[] coveringExpressionLengths = jsonObject.get(
"coveringExpressionLengths") ==
null ? null : JsonUtilities.decodeIntArray(jsonObject.get(
"coveringExpressionLengths").getAsJsonArray());
93 List<String> names = JsonUtilities.decodeStringList(jsonObject.get(
"names").getAsJsonArray());
94 int[]
offsets = JsonUtilities.decodeIntArray(jsonObject.get(
"offsets").getAsJsonArray());
95 int[] lengths = JsonUtilities.decodeIntArray(jsonObject.get(
"lengths").getAsJsonArray());
100 if (jsonArray ==
null) {
103 ArrayList<ExtractLocalVariableFeedback> list =
new ArrayList<ExtractLocalVariableFeedback>(jsonArray.size());
104 Iterator<JsonElement> iterator = jsonArray.iterator();
105 while (iterator.hasNext()) {
106 list.add(fromJson(iterator.next().getAsJsonObject()));
116 return coveringExpressionLengths;
124 return coveringExpressionOffsets;
152 HashCodeBuilder
builder =
new HashCodeBuilder();
153 builder.append(coveringExpressionOffsets);
154 builder.append(coveringExpressionLengths);
162 JsonObject jsonObject =
new JsonObject();
163 if (coveringExpressionOffsets !=
null) {
164 JsonArray jsonArrayCoveringExpressionOffsets =
new JsonArray();
165 for (
int elt : coveringExpressionOffsets) {
166 jsonArrayCoveringExpressionOffsets.add(
new JsonPrimitive(elt));
168 jsonObject.add(
"coveringExpressionOffsets", jsonArrayCoveringExpressionOffsets);
170 if (coveringExpressionLengths !=
null) {
171 JsonArray jsonArrayCoveringExpressionLengths =
new JsonArray();
172 for (
int elt : coveringExpressionLengths) {
173 jsonArrayCoveringExpressionLengths.add(
new JsonPrimitive(elt));
175 jsonObject.add(
"coveringExpressionLengths", jsonArrayCoveringExpressionLengths);
177 JsonArray jsonArrayNames =
new JsonArray();
178 for (String elt :
names) {
179 jsonArrayNames.add(
new JsonPrimitive(elt));
181 jsonObject.add(
"names", jsonArrayNames);
182 JsonArray jsonArrayOffsets =
new JsonArray();
184 jsonArrayOffsets.add(
new JsonPrimitive(elt));
186 jsonObject.add(
"offsets", jsonArrayOffsets);
187 JsonArray jsonArrayLengths =
new JsonArray();
188 for (
int elt : lengths) {
189 jsonArrayLengths.add(
new JsonPrimitive(elt));
191 jsonObject.add(
"lengths", jsonArrayLengths);
197 StringBuilder
builder =
new StringBuilder();
199 builder.append(
"coveringExpressionOffsets=");
200 builder.append(StringUtils.join(coveringExpressionOffsets,
", ") +
", ");
201 builder.append(
"coveringExpressionLengths=");
202 builder.append(StringUtils.join(coveringExpressionLengths,
", ") +
", ");
208 builder.append(StringUtils.join(lengths,
", "));
static const char *const names[]