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;
31@SuppressWarnings(
"unused")
55 private final String containingLibraryPath;
62 private final String containingLibraryName;
68 private final String containingClassDescription;
76 private final String dartdoc;
82 private final String elementDescription;
88 private final String elementKind;
93 private final Boolean isDeprecated;
99 private final String parameter;
105 private final String propagatedType;
111 private final String staticType;
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) {
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;
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);
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);
169 if (jsonArray ==
null) {
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()));
185 return containingClassDescription;
194 return containingLibraryName;
203 return containingLibraryPath;
221 return elementDescription;
268 return propagatedType;
281 HashCodeBuilder
builder =
new HashCodeBuilder();
284 builder.append(containingLibraryPath);
285 builder.append(containingLibraryName);
286 builder.append(containingClassDescription);
288 builder.append(elementDescription);
292 builder.append(propagatedType);
298 JsonObject jsonObject =
new JsonObject();
299 jsonObject.addProperty(
"offset",
offset);
300 jsonObject.addProperty(
"length",
length);
301 if (containingLibraryPath !=
null) {
302 jsonObject.addProperty(
"containingLibraryPath", containingLibraryPath);
304 if (containingLibraryName !=
null) {
305 jsonObject.addProperty(
"containingLibraryName", containingLibraryName);
307 if (containingClassDescription !=
null) {
308 jsonObject.addProperty(
"containingClassDescription", containingClassDescription);
310 if (dartdoc !=
null) {
311 jsonObject.addProperty(
"dartdoc", dartdoc);
313 if (elementDescription !=
null) {
314 jsonObject.addProperty(
"elementDescription", elementDescription);
316 if (elementKind !=
null) {
317 jsonObject.addProperty(
"elementKind", elementKind);
319 if (isDeprecated !=
null) {
320 jsonObject.addProperty(
"isDeprecated", isDeprecated);
322 if (parameter !=
null) {
323 jsonObject.addProperty(
"parameter", parameter);
325 if (propagatedType !=
null) {
326 jsonObject.addProperty(
"propagatedType", propagatedType);
328 if (staticType !=
null) {
329 jsonObject.addProperty(
"staticType", staticType);
336 StringBuilder
builder =
new StringBuilder();
342 builder.append(
"containingLibraryPath=");
343 builder.append(containingLibraryPath +
", ");
344 builder.append(
"containingLibraryName=");
345 builder.append(containingLibraryName +
", ");
346 builder.append(
"containingClassDescription=");
347 builder.append(containingClassDescription +
", ");
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 +
", ");
357 builder.append(parameter +
", ");
358 builder.append(
"propagatedType=");
359 builder.append(propagatedType +
", ");