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")
38 private static final int ABSTRACT = 0x01;
40 private static final int CONST = 0x02;
42 private static final int FINAL = 0x04;
44 private static final int TOP_LEVEL_STATIC = 0x08;
46 private static final int PRIVATE = 0x10;
48 private static final int DEPRECATED = 0x20;
53 private final String kind;
58 private final String
name;
75 private final int flags;
82 private final String parameters;
89 private final String returnType;
95 private final String typeParameters;
101 private final String aliasedType;
106 public Element(String kind, String
name,
Location location,
int flags, String parameters, String returnType, String typeParameters, String aliasedType) {
109 this.location = location;
111 this.parameters = parameters;
112 this.returnType = returnType;
113 this.typeParameters = typeParameters;
114 this.aliasedType = aliasedType;
122 ObjectUtilities.
equals(other.kind, kind) &&
123 ObjectUtilities.equals(other.name,
name) &&
124 ObjectUtilities.equals(other.location, location) &&
125 other.flags ==
flags &&
126 ObjectUtilities.equals(other.parameters, parameters) &&
127 ObjectUtilities.equals(other.returnType, returnType) &&
128 ObjectUtilities.equals(other.typeParameters, typeParameters) &&
129 ObjectUtilities.equals(other.aliasedType, aliasedType);
135 String kind = jsonObject.get(
"kind").getAsString();
136 String
name = jsonObject.get(
"name").getAsString();
137 Location location = jsonObject.get(
"location") ==
null ? null :
Location.
fromJson(jsonObject.get(
"location").getAsJsonObject());
138 int flags = jsonObject.get(
"flags").getAsInt();
139 String parameters = jsonObject.get(
"parameters") ==
null ? null : jsonObject.get(
"parameters").getAsString();
140 String returnType = jsonObject.get(
"returnType") ==
null ? null : jsonObject.get(
"returnType").getAsString();
141 String typeParameters = jsonObject.get(
"typeParameters") ==
null ? null : jsonObject.get(
"typeParameters").getAsString();
142 String aliasedType = jsonObject.get(
"aliasedType") ==
null ? null : jsonObject.get(
"aliasedType").getAsString();
143 return new Element(kind,
name, location,
flags, parameters, returnType, typeParameters, aliasedType);
147 if (jsonArray ==
null) {
150 ArrayList<Element> list =
new ArrayList<Element>(jsonArray.size());
151 Iterator<JsonElement> iterator = jsonArray.iterator();
152 while (iterator.hasNext()) {
153 list.add(fromJson(iterator.next().getAsJsonObject()));
224 return typeParameters;
229 HashCodeBuilder builder =
new HashCodeBuilder();
230 builder.append(kind);
231 builder.append(
name);
232 builder.append(location);
233 builder.append(
flags);
234 builder.append(parameters);
235 builder.append(returnType);
236 builder.append(typeParameters);
237 builder.append(aliasedType);
238 return builder.toHashCode();
242 return (
flags & ABSTRACT) != 0;
246 return (
flags & CONST) != 0;
250 return (
flags & DEPRECATED) != 0;
254 return (
flags & FINAL) != 0;
258 return (
flags & PRIVATE) != 0;
262 return (
flags & TOP_LEVEL_STATIC) != 0;
266 JsonObject jsonObject =
new JsonObject();
267 jsonObject.addProperty(
"kind", kind);
268 jsonObject.addProperty(
"name",
name);
269 if (location !=
null) {
270 jsonObject.add(
"location", location.
toJson());
272 jsonObject.addProperty(
"flags",
flags);
273 if (parameters !=
null) {
274 jsonObject.addProperty(
"parameters", parameters);
276 if (returnType !=
null) {
277 jsonObject.addProperty(
"returnType", returnType);
279 if (typeParameters !=
null) {
280 jsonObject.addProperty(
"typeParameters", typeParameters);
282 if (aliasedType !=
null) {
283 jsonObject.addProperty(
"aliasedType", aliasedType);
290 StringBuilder builder =
new StringBuilder();
292 builder.append(
"kind=");
293 builder.append(kind +
", ");
294 builder.append(
"name=");
295 builder.append(
name +
", ");
296 builder.append(
"location=");
297 builder.append(location +
", ");
298 builder.append(
"flags=");
299 builder.append(
flags +
", ");
300 builder.append(
"parameters=");
301 builder.append(parameters +
", ");
302 builder.append(
"returnType=");
303 builder.append(returnType +
", ");
304 builder.append(
"typeParameters=");
305 builder.append(typeParameters +
", ");
306 builder.append(
"aliasedType=");
307 builder.append(aliasedType);
309 return builder.toString();
static List< Element > fromJsonArray(JsonArray jsonArray)
boolean isTopLevelOrStatic()
boolean equals(Object obj)
Element(String kind, String name, Location location, int flags, String parameters, String returnType, String typeParameters, String aliasedType)
String getTypeParameters()
static Element fromJson(JsonObject jsonObject)
static Location fromJson(JsonObject jsonObject)
FlutterSemanticsFlag flags