Flutter Engine
The Flutter Engine
HoverInformation.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 * The hover information associated with a specific location.
28 *
29 * @coverage dart.server.generated.types
30 */
31@SuppressWarnings("unused")
32public class HoverInformation {
33
34 public static final HoverInformation[] EMPTY_ARRAY = new HoverInformation[0];
35
36 public static final List<HoverInformation> EMPTY_LIST = Lists.newArrayList();
37
38 /**
39 * The offset of the range of characters that encompasses the cursor position and has the same
40 * hover information as the cursor position.
41 */
42 private final int offset;
43
44 /**
45 * The length of the range of characters that encompasses the cursor position and has the same
46 * hover information as the cursor position.
47 */
48 private final int length;
49
50 /**
51 * The path to the defining compilation unit of the library in which the referenced element is
52 * declared. This data is omitted if there is no referenced element, or if the element is declared
53 * inside an HTML file.
54 */
55 private final String containingLibraryPath;
56
57 /**
58 * The URI of the containing library, examples here include "dart:core", "package:.." and file uris
59 * represented by the path on disk, "/..". The data is omitted if the element is declared inside an
60 * HTML file.
61 */
62 private final String containingLibraryName;
63
64 /**
65 * A human-readable description of the class declaring the element being referenced. This data is
66 * omitted if there is no referenced element, or if the element is not a class member.
67 */
68 private final String containingClassDescription;
69
70 /**
71 * The dartdoc associated with the referenced element. Other than the removal of the comment
72 * delimiters, including leading asterisks in the case of a block comment, the dartdoc is
73 * unprocessed markdown. This data is omitted if there is no referenced element, or if the element
74 * has no dartdoc.
75 */
76 private final String dartdoc;
77
78 /**
79 * A human-readable description of the element being referenced. This data is omitted if there is
80 * no referenced element.
81 */
82 private final String elementDescription;
83
84 /**
85 * A human-readable description of the kind of element being referenced (such as "class" or
86 * "function type alias"). This data is omitted if there is no referenced element.
87 */
88 private final String elementKind;
89
90 /**
91 * True if the referenced element is deprecated.
92 */
93 private final Boolean isDeprecated;
94
95 /**
96 * A human-readable description of the parameter corresponding to the expression being hovered
97 * over. This data is omitted if the location is not in an argument to a function.
98 */
99 private final String parameter;
100
101 /**
102 * The name of the propagated type of the expression. This data is omitted if the location does not
103 * correspond to an expression or if there is no propagated type information.
104 */
105 private final String propagatedType;
106
107 /**
108 * The name of the static type of the expression. This data is omitted if the location does not
109 * correspond to an expression.
110 */
111 private final String staticType;
112
113 /**
114 * Constructor for {@link HoverInformation}.
115 */
116 public HoverInformation(int offset, int length, String containingLibraryPath, String containingLibraryName, String containingClassDescription, String dartdoc, String elementDescription, String elementKind, Boolean isDeprecated, String parameter, String propagatedType, String staticType) {
117 this.offset = offset;
118 this.length = length;
119 this.containingLibraryPath = containingLibraryPath;
120 this.containingLibraryName = containingLibraryName;
121 this.containingClassDescription = containingClassDescription;
122 this.dartdoc = dartdoc;
123 this.elementDescription = elementDescription;
124 this.elementKind = elementKind;
125 this.isDeprecated = isDeprecated;
126 this.parameter = parameter;
127 this.propagatedType = propagatedType;
128 this.staticType = staticType;
129 }
130
131 @Override
132 public boolean equals(Object obj) {
133 if (obj instanceof HoverInformation) {
135 return
136 other.offset == offset &&
137 other.length == length &&
138 ObjectUtilities.equals(other.containingLibraryPath, containingLibraryPath) &&
139 ObjectUtilities.equals(other.containingLibraryName, containingLibraryName) &&
140 ObjectUtilities.equals(other.containingClassDescription, containingClassDescription) &&
141 ObjectUtilities.equals(other.dartdoc, dartdoc) &&
142 ObjectUtilities.equals(other.elementDescription, elementDescription) &&
143 ObjectUtilities.equals(other.elementKind, elementKind) &&
144 ObjectUtilities.equals(other.isDeprecated, isDeprecated) &&
145 ObjectUtilities.equals(other.parameter, parameter) &&
146 ObjectUtilities.equals(other.propagatedType, propagatedType) &&
147 ObjectUtilities.equals(other.staticType, staticType);
148 }
149 return false;
150 }
151
152 public static HoverInformation fromJson(JsonObject jsonObject) {
153 int offset = jsonObject.get("offset").getAsInt();
154 int length = jsonObject.get("length").getAsInt();
155 String containingLibraryPath = jsonObject.get("containingLibraryPath") == null ? null : jsonObject.get("containingLibraryPath").getAsString();
156 String containingLibraryName = jsonObject.get("containingLibraryName") == null ? null : jsonObject.get("containingLibraryName").getAsString();
157 String containingClassDescription = jsonObject.get("containingClassDescription") == null ? null : jsonObject.get("containingClassDescription").getAsString();
158 String dartdoc = jsonObject.get("dartdoc") == null ? null : jsonObject.get("dartdoc").getAsString();
159 String elementDescription = jsonObject.get("elementDescription") == null ? null : jsonObject.get("elementDescription").getAsString();
160 String elementKind = jsonObject.get("elementKind") == null ? null : jsonObject.get("elementKind").getAsString();
161 Boolean isDeprecated = jsonObject.get("isDeprecated") == null ? null : jsonObject.get("isDeprecated").getAsBoolean();
162 String parameter = jsonObject.get("parameter") == null ? null : jsonObject.get("parameter").getAsString();
163 String propagatedType = jsonObject.get("propagatedType") == null ? null : jsonObject.get("propagatedType").getAsString();
164 String staticType = jsonObject.get("staticType") == null ? null : jsonObject.get("staticType").getAsString();
165 return new HoverInformation(offset, length, containingLibraryPath, containingLibraryName, containingClassDescription, dartdoc, elementDescription, elementKind, isDeprecated, parameter, propagatedType, staticType);
166 }
167
168 public static List<HoverInformation> fromJsonArray(JsonArray jsonArray) {
169 if (jsonArray == null) {
170 return EMPTY_LIST;
171 }
172 ArrayList<HoverInformation> list = new ArrayList<HoverInformation>(jsonArray.size());
173 Iterator<JsonElement> iterator = jsonArray.iterator();
174 while (iterator.hasNext()) {
175 list.add(fromJson(iterator.next().getAsJsonObject()));
176 }
177 return list;
178 }
179
180 /**
181 * A human-readable description of the class declaring the element being referenced. This data is
182 * omitted if there is no referenced element, or if the element is not a class member.
183 */
185 return containingClassDescription;
186 }
187
188 /**
189 * The URI of the containing library, examples here include "dart:core", "package:.." and file uris
190 * represented by the path on disk, "/..". The data is omitted if the element is declared inside an
191 * HTML file.
192 */
193 public String getContainingLibraryName() {
194 return containingLibraryName;
195 }
196
197 /**
198 * The path to the defining compilation unit of the library in which the referenced element is
199 * declared. This data is omitted if there is no referenced element, or if the element is declared
200 * inside an HTML file.
201 */
202 public String getContainingLibraryPath() {
203 return containingLibraryPath;
204 }
205
206 /**
207 * The dartdoc associated with the referenced element. Other than the removal of the comment
208 * delimiters, including leading asterisks in the case of a block comment, the dartdoc is
209 * unprocessed markdown. This data is omitted if there is no referenced element, or if the element
210 * has no dartdoc.
211 */
212 public String getDartdoc() {
213 return dartdoc;
214 }
215
216 /**
217 * A human-readable description of the element being referenced. This data is omitted if there is
218 * no referenced element.
219 */
220 public String getElementDescription() {
221 return elementDescription;
222 }
223
224 /**
225 * A human-readable description of the kind of element being referenced (such as "class" or
226 * "function type alias"). This data is omitted if there is no referenced element.
227 */
228 public String getElementKind() {
229 return elementKind;
230 }
231
232 /**
233 * True if the referenced element is deprecated.
234 */
235 public Boolean getIsDeprecated() {
236 return isDeprecated;
237 }
238
239 /**
240 * The length of the range of characters that encompasses the cursor position and has the same
241 * hover information as the cursor position.
242 */
243 public int getLength() {
244 return length;
245 }
246
247 /**
248 * The offset of the range of characters that encompasses the cursor position and has the same
249 * hover information as the cursor position.
250 */
251 public int getOffset() {
252 return offset;
253 }
254
255 /**
256 * A human-readable description of the parameter corresponding to the expression being hovered
257 * over. This data is omitted if the location is not in an argument to a function.
258 */
259 public String getParameter() {
260 return parameter;
261 }
262
263 /**
264 * The name of the propagated type of the expression. This data is omitted if the location does not
265 * correspond to an expression or if there is no propagated type information.
266 */
267 public String getPropagatedType() {
268 return propagatedType;
269 }
270
271 /**
272 * The name of the static type of the expression. This data is omitted if the location does not
273 * correspond to an expression.
274 */
275 public String getStaticType() {
276 return staticType;
277 }
278
279 @Override
280 public int hashCode() {
281 HashCodeBuilder builder = new HashCodeBuilder();
282 builder.append(offset);
283 builder.append(length);
284 builder.append(containingLibraryPath);
285 builder.append(containingLibraryName);
286 builder.append(containingClassDescription);
287 builder.append(dartdoc);
288 builder.append(elementDescription);
289 builder.append(elementKind);
290 builder.append(isDeprecated);
291 builder.append(parameter);
292 builder.append(propagatedType);
293 builder.append(staticType);
294 return builder.toHashCode();
295 }
296
297 public JsonObject toJson() {
298 JsonObject jsonObject = new JsonObject();
299 jsonObject.addProperty("offset", offset);
300 jsonObject.addProperty("length", length);
301 if (containingLibraryPath != null) {
302 jsonObject.addProperty("containingLibraryPath", containingLibraryPath);
303 }
304 if (containingLibraryName != null) {
305 jsonObject.addProperty("containingLibraryName", containingLibraryName);
306 }
307 if (containingClassDescription != null) {
308 jsonObject.addProperty("containingClassDescription", containingClassDescription);
309 }
310 if (dartdoc != null) {
311 jsonObject.addProperty("dartdoc", dartdoc);
312 }
313 if (elementDescription != null) {
314 jsonObject.addProperty("elementDescription", elementDescription);
315 }
316 if (elementKind != null) {
317 jsonObject.addProperty("elementKind", elementKind);
318 }
319 if (isDeprecated != null) {
320 jsonObject.addProperty("isDeprecated", isDeprecated);
321 }
322 if (parameter != null) {
323 jsonObject.addProperty("parameter", parameter);
324 }
325 if (propagatedType != null) {
326 jsonObject.addProperty("propagatedType", propagatedType);
327 }
328 if (staticType != null) {
329 jsonObject.addProperty("staticType", staticType);
330 }
331 return jsonObject;
332 }
333
334 @Override
335 public String toString() {
336 StringBuilder builder = new StringBuilder();
337 builder.append("[");
338 builder.append("offset=");
339 builder.append(offset + ", ");
340 builder.append("length=");
341 builder.append(length + ", ");
342 builder.append("containingLibraryPath=");
343 builder.append(containingLibraryPath + ", ");
344 builder.append("containingLibraryName=");
345 builder.append(containingLibraryName + ", ");
346 builder.append("containingClassDescription=");
347 builder.append(containingClassDescription + ", ");
348 builder.append("dartdoc=");
349 builder.append(dartdoc + ", ");
350 builder.append("elementDescription=");
351 builder.append(elementDescription + ", ");
352 builder.append("elementKind=");
353 builder.append(elementKind + ", ");
354 builder.append("isDeprecated=");
355 builder.append(isDeprecated + ", ");
356 builder.append("parameter=");
357 builder.append(parameter + ", ");
358 builder.append("propagatedType=");
359 builder.append(propagatedType + ", ");
360 builder.append("staticType=");
361 builder.append(staticType);
362 builder.append("]");
363 return builder.toString();
364 }
365
366}
HoverInformation(int offset, int length, String containingLibraryPath, String containingLibraryName, String containingClassDescription, String dartdoc, String elementDescription, String elementKind, Boolean isDeprecated, String parameter, String propagatedType, String staticType)
static HoverInformation fromJson(JsonObject jsonObject)
static List< HoverInformation > fromJsonArray(JsonArray jsonArray)
size_t length
SeparatedVector2 offset