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")
41 private final String kind;
59 private final int codeOffset;
64 private final int codeLength;
70 private final String label;
75 private final Element dartElement;
88 private final String className;
94 private final String parentAssociationLabel;
99 private final String variableName;
109 public FlutterOutline(String kind,
int offset,
int length,
int codeOffset,
int codeLength, String label,
Element dartElement,
List<FlutterOutlineAttribute> attributes, String className, String parentAssociationLabel, String variableName,
List<FlutterOutline> children) {
113 this.codeOffset = codeOffset;
114 this.codeLength = codeLength;
116 this.dartElement = dartElement;
117 this.attributes = attributes;
118 this.className = className;
119 this.parentAssociationLabel = parentAssociationLabel;
120 this.variableName = variableName;
121 this.children = children;
129 ObjectUtilities.
equals(other.kind, kind) &&
132 other.codeOffset == codeOffset &&
133 other.codeLength == codeLength &&
134 ObjectUtilities.equals(other.label, label) &&
135 ObjectUtilities.equals(other.dartElement, dartElement) &&
136 ObjectUtilities.equals(other.attributes, attributes) &&
137 ObjectUtilities.equals(other.className, className) &&
138 ObjectUtilities.equals(other.parentAssociationLabel, parentAssociationLabel) &&
139 ObjectUtilities.equals(other.variableName, variableName) &&
140 ObjectUtilities.equals(other.children, children);
146 String kind = jsonObject.get(
"kind").getAsString();
147 int offset = jsonObject.get(
"offset").getAsInt();
148 int length = jsonObject.get(
"length").getAsInt();
149 int codeOffset = jsonObject.get(
"codeOffset").getAsInt();
150 int codeLength = jsonObject.get(
"codeLength").getAsInt();
151 String label = jsonObject.get(
"label") ==
null ? null : jsonObject.get(
"label").getAsString();
152 Element dartElement = jsonObject.get(
"dartElement") ==
null ? null :
Element.
fromJson(jsonObject.get(
"dartElement").getAsJsonObject());
154 String className = jsonObject.get(
"className") ==
null ? null : jsonObject.get(
"className").getAsString();
155 String parentAssociationLabel = jsonObject.get(
"parentAssociationLabel") ==
null ? null : jsonObject.get(
"parentAssociationLabel").getAsString();
156 String variableName = jsonObject.get(
"variableName") ==
null ? null : jsonObject.get(
"variableName").getAsString();
158 return new FlutterOutline(kind,
offset,
length, codeOffset, codeLength, label, dartElement, attributes, className, parentAssociationLabel, variableName, children);
162 if (jsonArray ==
null) {
165 ArrayList<FlutterOutline> list =
new ArrayList<FlutterOutline>(jsonArray.size());
166 Iterator<JsonElement> iterator = jsonArray.iterator();
167 while (iterator.hasNext()) {
168 list.add(fromJson(iterator.next().getAsJsonObject()));
255 return parentAssociationLabel;
267 HashCodeBuilder
builder =
new HashCodeBuilder();
277 builder.append(parentAssociationLabel);
284 JsonObject jsonObject =
new JsonObject();
285 jsonObject.addProperty(
"kind", kind);
286 jsonObject.addProperty(
"offset",
offset);
287 jsonObject.addProperty(
"length",
length);
288 jsonObject.addProperty(
"codeOffset", codeOffset);
289 jsonObject.addProperty(
"codeLength", codeLength);
291 jsonObject.addProperty(
"label", label);
293 if (dartElement !=
null) {
294 jsonObject.add(
"dartElement", dartElement.
toJson());
296 if (attributes !=
null) {
297 JsonArray jsonArrayAttributes =
new JsonArray();
299 jsonArrayAttributes.add(elt.toJson());
301 jsonObject.add(
"attributes", jsonArrayAttributes);
303 if (className !=
null) {
304 jsonObject.addProperty(
"className", className);
306 if (parentAssociationLabel !=
null) {
307 jsonObject.addProperty(
"parentAssociationLabel", parentAssociationLabel);
309 if (variableName !=
null) {
310 jsonObject.addProperty(
"variableName", variableName);
312 if (children !=
null) {
313 JsonArray jsonArrayChildren =
new JsonArray();
315 jsonArrayChildren.add(elt.toJson());
317 jsonObject.add(
"children", jsonArrayChildren);
324 StringBuilder
builder =
new StringBuilder();
333 builder.append(codeOffset +
", ");
335 builder.append(codeLength +
", ");
338 builder.append(
"dartElement=");
339 builder.append(dartElement +
", ");
341 builder.append(StringUtils.join(attributes,
", ") +
", ");
343 builder.append(className +
", ");
344 builder.append(
"parentAssociationLabel=");
345 builder.append(parentAssociationLabel +
", ");
346 builder.append(
"variableName=");
347 builder.append(variableName +
", ");
349 builder.append(StringUtils.join(children,
", "));
static Element fromJson(JsonObject jsonObject)
static List< FlutterOutlineAttribute > fromJsonArray(JsonArray jsonArray)
boolean equals(Object obj)
static FlutterOutline fromJson(JsonObject jsonObject)
FlutterOutline(String kind, int offset, int length, int codeOffset, int codeLength, String label, Element dartElement, List< FlutterOutlineAttribute > attributes, String className, String parentAssociationLabel, String variableName, List< FlutterOutline > children)
static List< FlutterOutline > fromJsonArray(JsonArray jsonArray)
List< FlutterOutlineAttribute > getAttributes()
String getParentAssociationLabel()
List< FlutterOutline > getChildren()