Flutter Engine
The Flutter Engine
ElementDeclaration.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 * A declaration - top-level (class, field, etc) or a class member (method, field, etc).
28 *
29 * @coverage dart.server.generated.types
30 */
31@SuppressWarnings("unused")
32public class ElementDeclaration {
33
34 public static final ElementDeclaration[] EMPTY_ARRAY = new ElementDeclaration[0];
35
36 public static final List<ElementDeclaration> EMPTY_LIST = Lists.newArrayList();
37
38 /**
39 * The name of the declaration.
40 */
41 private final String name;
42
43 /**
44 * The kind of the element that corresponds to the declaration.
45 */
46 private final String kind;
47
48 /**
49 * The index of the file (in the enclosing response).
50 */
51 private final int fileIndex;
52
53 /**
54 * The offset of the declaration name in the file.
55 */
56 private final int offset;
57
58 /**
59 * The one-based index of the line containing the declaration name.
60 */
61 private final int line;
62
63 /**
64 * The one-based index of the column containing the declaration name.
65 */
66 private final int column;
67
68 /**
69 * The offset of the first character of the declaration code in the file.
70 */
71 private final int codeOffset;
72
73 /**
74 * The length of the declaration code in the file.
75 */
76 private final int codeLength;
77
78 /**
79 * The name of the class enclosing this declaration. If the declaration is not a class member, this
80 * field will be absent.
81 */
82 private final String className;
83
84 /**
85 * The name of the mixin enclosing this declaration. If the declaration is not a mixin member, this
86 * field will be absent.
87 */
88 private final String mixinName;
89
90 /**
91 * The parameter list for the element. If the element is not a method or function this field will
92 * not be defined. If the element doesn't have parameters (e.g. getter), this field will not be
93 * defined. If the element has zero parameters, this field will have a value of "()". The value
94 * should not be treated as exact presentation of parameters, it is just approximation of
95 * parameters to give the user general idea.
96 */
97 private final String parameters;
98
99 /**
100 * Constructor for {@link ElementDeclaration}.
101 */
102 public ElementDeclaration(String name, String kind, int fileIndex, int offset, int line, int column, int codeOffset, int codeLength, String className, String mixinName, String parameters) {
103 this.name = name;
104 this.kind = kind;
105 this.fileIndex = fileIndex;
106 this.offset = offset;
107 this.line = line;
108 this.column = column;
109 this.codeOffset = codeOffset;
110 this.codeLength = codeLength;
111 this.className = className;
112 this.mixinName = mixinName;
113 this.parameters = parameters;
114 }
115
116 @Override
117 public boolean equals(Object obj) {
118 if (obj instanceof ElementDeclaration) {
120 return
121 ObjectUtilities.equals(other.name, name) &&
122 ObjectUtilities.equals(other.kind, kind) &&
123 other.fileIndex == fileIndex &&
124 other.offset == offset &&
125 other.line == line &&
126 other.column == column &&
127 other.codeOffset == codeOffset &&
128 other.codeLength == codeLength &&
129 ObjectUtilities.equals(other.className, className) &&
130 ObjectUtilities.equals(other.mixinName, mixinName) &&
131 ObjectUtilities.equals(other.parameters, parameters);
132 }
133 return false;
134 }
135
136 public static ElementDeclaration fromJson(JsonObject jsonObject) {
137 String name = jsonObject.get("name").getAsString();
138 String kind = jsonObject.get("kind").getAsString();
139 int fileIndex = jsonObject.get("fileIndex").getAsInt();
140 int offset = jsonObject.get("offset").getAsInt();
141 int line = jsonObject.get("line").getAsInt();
142 int column = jsonObject.get("column").getAsInt();
143 int codeOffset = jsonObject.get("codeOffset").getAsInt();
144 int codeLength = jsonObject.get("codeLength").getAsInt();
145 String className = jsonObject.get("className") == null ? null : jsonObject.get("className").getAsString();
146 String mixinName = jsonObject.get("mixinName") == null ? null : jsonObject.get("mixinName").getAsString();
147 String parameters = jsonObject.get("parameters") == null ? null : jsonObject.get("parameters").getAsString();
148 return new ElementDeclaration(name, kind, fileIndex, offset, line, column, codeOffset, codeLength, className, mixinName, parameters);
149 }
150
151 public static List<ElementDeclaration> fromJsonArray(JsonArray jsonArray) {
152 if (jsonArray == null) {
153 return EMPTY_LIST;
154 }
155 ArrayList<ElementDeclaration> list = new ArrayList<ElementDeclaration>(jsonArray.size());
156 Iterator<JsonElement> iterator = jsonArray.iterator();
157 while (iterator.hasNext()) {
158 list.add(fromJson(iterator.next().getAsJsonObject()));
159 }
160 return list;
161 }
162
163 /**
164 * The name of the class enclosing this declaration. If the declaration is not a class member, this
165 * field will be absent.
166 */
167 public String getClassName() {
168 return className;
169 }
170
171 /**
172 * The length of the declaration code in the file.
173 */
174 public int getCodeLength() {
175 return codeLength;
176 }
177
178 /**
179 * The offset of the first character of the declaration code in the file.
180 */
181 public int getCodeOffset() {
182 return codeOffset;
183 }
184
185 /**
186 * The one-based index of the column containing the declaration name.
187 */
188 public int getColumn() {
189 return column;
190 }
191
192 /**
193 * The index of the file (in the enclosing response).
194 */
195 public int getFileIndex() {
196 return fileIndex;
197 }
198
199 /**
200 * The kind of the element that corresponds to the declaration.
201 */
202 public String getKind() {
203 return kind;
204 }
205
206 /**
207 * The one-based index of the line containing the declaration name.
208 */
209 public int getLine() {
210 return line;
211 }
212
213 /**
214 * The name of the mixin enclosing this declaration. If the declaration is not a mixin member, this
215 * field will be absent.
216 */
217 public String getMixinName() {
218 return mixinName;
219 }
220
221 /**
222 * The name of the declaration.
223 */
224 public String getName() {
225 return name;
226 }
227
228 /**
229 * The offset of the declaration name in the file.
230 */
231 public int getOffset() {
232 return offset;
233 }
234
235 /**
236 * The parameter list for the element. If the element is not a method or function this field will
237 * not be defined. If the element doesn't have parameters (e.g. getter), this field will not be
238 * defined. If the element has zero parameters, this field will have a value of "()". The value
239 * should not be treated as exact presentation of parameters, it is just approximation of
240 * parameters to give the user general idea.
241 */
242 public String getParameters() {
243 return parameters;
244 }
245
246 @Override
247 public int hashCode() {
248 HashCodeBuilder builder = new HashCodeBuilder();
249 builder.append(name);
250 builder.append(kind);
251 builder.append(fileIndex);
252 builder.append(offset);
253 builder.append(line);
254 builder.append(column);
255 builder.append(codeOffset);
256 builder.append(codeLength);
257 builder.append(className);
258 builder.append(mixinName);
259 builder.append(parameters);
260 return builder.toHashCode();
261 }
262
263 public JsonObject toJson() {
264 JsonObject jsonObject = new JsonObject();
265 jsonObject.addProperty("name", name);
266 jsonObject.addProperty("kind", kind);
267 jsonObject.addProperty("fileIndex", fileIndex);
268 jsonObject.addProperty("offset", offset);
269 jsonObject.addProperty("line", line);
270 jsonObject.addProperty("column", column);
271 jsonObject.addProperty("codeOffset", codeOffset);
272 jsonObject.addProperty("codeLength", codeLength);
273 if (className != null) {
274 jsonObject.addProperty("className", className);
275 }
276 if (mixinName != null) {
277 jsonObject.addProperty("mixinName", mixinName);
278 }
279 if (parameters != null) {
280 jsonObject.addProperty("parameters", parameters);
281 }
282 return jsonObject;
283 }
284
285 @Override
286 public String toString() {
287 StringBuilder builder = new StringBuilder();
288 builder.append("[");
289 builder.append("name=");
290 builder.append(name + ", ");
291 builder.append("kind=");
292 builder.append(kind + ", ");
293 builder.append("fileIndex=");
294 builder.append(fileIndex + ", ");
295 builder.append("offset=");
296 builder.append(offset + ", ");
297 builder.append("line=");
298 builder.append(line + ", ");
299 builder.append("column=");
300 builder.append(column + ", ");
301 builder.append("codeOffset=");
302 builder.append(codeOffset + ", ");
303 builder.append("codeLength=");
304 builder.append(codeLength + ", ");
305 builder.append("className=");
306 builder.append(className + ", ");
307 builder.append("mixinName=");
308 builder.append(mixinName + ", ");
309 builder.append("parameters=");
310 builder.append(parameters);
311 builder.append("]");
312 return builder.toString();
313 }
314
315}
static ElementDeclaration fromJson(JsonObject jsonObject)
ElementDeclaration(String name, String kind, int fileIndex, int offset, int line, int column, int codeOffset, int codeLength, String className, String mixinName, String parameters)
static List< ElementDeclaration > fromJsonArray(JsonArray jsonArray)
DEF_SWITCHES_START aot vmservice shared library name
Definition: switches.h:32
SeparatedVector2 offset