Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
ExtractLocalVariableFeedback.java
Go to the documentation of this file.
1/*
2 * Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
3 * for details. All rights reserved. Use of this source code is governed by a
4 * BSD-style license that can be found in the LICENSE file.
5 *
6 * This file has been automatically generated. Please do not edit it manually.
7 * To regenerate the file, use the script "pkg/analysis_server/tool/spec/generate_files".
8 */
9package org.dartlang.analysis.server.protocol;
10
11import java.util.Arrays;
12import java.util.List;
13import java.util.Map;
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;
25
26/**
27 * @coverage dart.server.generated.types
28 */
29@SuppressWarnings("unused")
31
32 public static final ExtractLocalVariableFeedback[] EMPTY_ARRAY = new ExtractLocalVariableFeedback[0];
33
34 public static final List<ExtractLocalVariableFeedback> EMPTY_LIST = Lists.newArrayList();
35
36 /**
37 * The offsets of the expressions that cover the specified selection, from the down most to the up
38 * most.
39 */
40 private final int[] coveringExpressionOffsets;
41
42 /**
43 * The lengths of the expressions that cover the specified selection, from the down most to the up
44 * most.
45 */
46 private final int[] coveringExpressionLengths;
47
48 /**
49 * The proposed names for the local variable.
50 */
51 private final List<String> names;
52
53 /**
54 * The offsets of the expressions that would be replaced by a reference to the variable.
55 */
56 private final int[] offsets;
57
58 /**
59 * The lengths of the expressions that would be replaced by a reference to the variable. The
60 * lengths correspond to the offsets. In other words, for a given expression, if the offset of that
61 * expression is offsets[i], then the length of that expression is lengths[i].
62 */
63 private final int[] lengths;
64
65 /**
66 * Constructor for {@link ExtractLocalVariableFeedback}.
67 */
68 public ExtractLocalVariableFeedback(int[] coveringExpressionOffsets, int[] coveringExpressionLengths, List<String> names, int[] offsets, int[] lengths) {
69 this.coveringExpressionOffsets = coveringExpressionOffsets;
70 this.coveringExpressionLengths = coveringExpressionLengths;
71 this.names = names;
72 this.offsets = offsets;
73 this.lengths = lengths;
74 }
75
76 @Override
77 public boolean equals(Object obj) {
78 if (obj instanceof ExtractLocalVariableFeedback) {
80 return
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);
86 }
87 return false;
88 }
89
90 public static ExtractLocalVariableFeedback fromJson(JsonObject jsonObject) {
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());
96 return new ExtractLocalVariableFeedback(coveringExpressionOffsets, coveringExpressionLengths, names, offsets, lengths);
97 }
98
99 public static List<ExtractLocalVariableFeedback> fromJsonArray(JsonArray jsonArray) {
100 if (jsonArray == null) {
101 return EMPTY_LIST;
102 }
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()));
107 }
108 return list;
109 }
110
111 /**
112 * The lengths of the expressions that cover the specified selection, from the down most to the up
113 * most.
114 */
116 return coveringExpressionLengths;
117 }
118
119 /**
120 * The offsets of the expressions that cover the specified selection, from the down most to the up
121 * most.
122 */
124 return coveringExpressionOffsets;
125 }
126
127 /**
128 * The lengths of the expressions that would be replaced by a reference to the variable. The
129 * lengths correspond to the offsets. In other words, for a given expression, if the offset of that
130 * expression is offsets[i], then the length of that expression is lengths[i].
131 */
132 public int[] getLengths() {
133 return lengths;
134 }
135
136 /**
137 * The proposed names for the local variable.
138 */
140 return names;
141 }
142
143 /**
144 * The offsets of the expressions that would be replaced by a reference to the variable.
145 */
146 public int[] getOffsets() {
147 return offsets;
148 }
149
150 @Override
151 public int hashCode() {
152 HashCodeBuilder builder = new HashCodeBuilder();
153 builder.append(coveringExpressionOffsets);
154 builder.append(coveringExpressionLengths);
155 builder.append(names);
156 builder.append(offsets);
157 builder.append(lengths);
158 return builder.toHashCode();
159 }
160
161 public JsonObject toJson() {
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));
167 }
168 jsonObject.add("coveringExpressionOffsets", jsonArrayCoveringExpressionOffsets);
169 }
170 if (coveringExpressionLengths != null) {
171 JsonArray jsonArrayCoveringExpressionLengths = new JsonArray();
172 for (int elt : coveringExpressionLengths) {
173 jsonArrayCoveringExpressionLengths.add(new JsonPrimitive(elt));
174 }
175 jsonObject.add("coveringExpressionLengths", jsonArrayCoveringExpressionLengths);
176 }
177 JsonArray jsonArrayNames = new JsonArray();
178 for (String elt : names) {
179 jsonArrayNames.add(new JsonPrimitive(elt));
180 }
181 jsonObject.add("names", jsonArrayNames);
182 JsonArray jsonArrayOffsets = new JsonArray();
183 for (int elt : offsets) {
184 jsonArrayOffsets.add(new JsonPrimitive(elt));
185 }
186 jsonObject.add("offsets", jsonArrayOffsets);
187 JsonArray jsonArrayLengths = new JsonArray();
188 for (int elt : lengths) {
189 jsonArrayLengths.add(new JsonPrimitive(elt));
190 }
191 jsonObject.add("lengths", jsonArrayLengths);
192 return jsonObject;
193 }
194
195 @Override
196 public String toString() {
197 StringBuilder builder = new StringBuilder();
198 builder.append("[");
199 builder.append("coveringExpressionOffsets=");
200 builder.append(StringUtils.join(coveringExpressionOffsets, ", ") + ", ");
201 builder.append("coveringExpressionLengths=");
202 builder.append(StringUtils.join(coveringExpressionLengths, ", ") + ", ");
203 builder.append("names=");
204 builder.append(StringUtils.join(names, ", ") + ", ");
205 builder.append("offsets=");
206 builder.append(StringUtils.join(offsets, ", ") + ", ");
207 builder.append("lengths=");
208 builder.append(StringUtils.join(lengths, ", "));
209 builder.append("]");
210 return builder.toString();
211 }
212
213}
static ExtractLocalVariableFeedback fromJson(JsonObject jsonObject)
ExtractLocalVariableFeedback(int[] coveringExpressionOffsets, int[] coveringExpressionLengths, List< String > names, int[] offsets, int[] lengths)
static List< ExtractLocalVariableFeedback > fromJsonArray(JsonArray jsonArray)