Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
RuntimeCompletionExpressionType.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 type at runtime.
28 *
29 * @coverage dart.server.generated.types
30 */
31@SuppressWarnings("unused")
33
34 public static final RuntimeCompletionExpressionType[] EMPTY_ARRAY = new RuntimeCompletionExpressionType[0];
35
36 public static final List<RuntimeCompletionExpressionType> EMPTY_LIST = Lists.newArrayList();
37
38 /**
39 * The path of the library that has this type. Omitted if the type is not declared in any library,
40 * e.g. "dynamic", or "void".
41 */
42 private final String libraryPath;
43
44 /**
45 * The kind of the type.
46 */
47 private final String kind;
48
49 /**
50 * The name of the type. Omitted if the type does not have a name, e.g. an inline function type.
51 */
52 private final String name;
53
54 /**
55 * The type arguments of the type. Omitted if the type does not have type parameters.
56 */
57 private final List<RuntimeCompletionExpressionType> typeArguments;
58
59 /**
60 * If the type is a function type, the return type of the function. Omitted if the type is not a
61 * function type.
62 */
63 private final RuntimeCompletionExpressionType returnType;
64
65 /**
66 * If the type is a function type, the types of the function parameters of all kinds - required,
67 * optional positional, and optional named. Omitted if the type is not a function type.
68 */
69 private final List<RuntimeCompletionExpressionType> parameterTypes;
70
71 /**
72 * If the type is a function type, the names of the function parameters of all kinds - required,
73 * optional positional, and optional named. The names of positional parameters are empty strings.
74 * Omitted if the type is not a function type.
75 */
76 private final List<String> parameterNames;
77
78 /**
79 * Constructor for {@link RuntimeCompletionExpressionType}.
80 */
81 public RuntimeCompletionExpressionType(String libraryPath, String kind, String name, List<RuntimeCompletionExpressionType> typeArguments, RuntimeCompletionExpressionType returnType, List<RuntimeCompletionExpressionType> parameterTypes, List<String> parameterNames) {
82 this.libraryPath = libraryPath;
83 this.kind = kind;
84 this.name = name;
85 this.typeArguments = typeArguments;
86 this.returnType = returnType;
87 this.parameterTypes = parameterTypes;
88 this.parameterNames = parameterNames;
89 }
90
91 @Override
92 public boolean equals(Object obj) {
93 if (obj instanceof RuntimeCompletionExpressionType) {
95 return
96 ObjectUtilities.equals(other.libraryPath, libraryPath) &&
97 ObjectUtilities.equals(other.kind, kind) &&
98 ObjectUtilities.equals(other.name, name) &&
99 ObjectUtilities.equals(other.typeArguments, typeArguments) &&
100 ObjectUtilities.equals(other.returnType, returnType) &&
101 ObjectUtilities.equals(other.parameterTypes, parameterTypes) &&
102 ObjectUtilities.equals(other.parameterNames, parameterNames);
103 }
104 return false;
105 }
106
107 public static RuntimeCompletionExpressionType fromJson(JsonObject jsonObject) {
108 String libraryPath = jsonObject.get("libraryPath") == null ? null : jsonObject.get("libraryPath").getAsString();
109 String kind = jsonObject.get("kind").getAsString();
110 String name = jsonObject.get("name") == null ? null : jsonObject.get("name").getAsString();
111 List<RuntimeCompletionExpressionType> typeArguments = jsonObject.get("typeArguments") == null ? null : RuntimeCompletionExpressionType.fromJsonArray(jsonObject.get("typeArguments").getAsJsonArray());
112 RuntimeCompletionExpressionType returnType = jsonObject.get("returnType") == null ? null : RuntimeCompletionExpressionType.fromJson(jsonObject.get("returnType").getAsJsonObject());
113 List<RuntimeCompletionExpressionType> parameterTypes = jsonObject.get("parameterTypes") == null ? null : RuntimeCompletionExpressionType.fromJsonArray(jsonObject.get("parameterTypes").getAsJsonArray());
114 List<String> parameterNames = jsonObject.get("parameterNames") == null ? null : JsonUtilities.decodeStringList(jsonObject.get("parameterNames").getAsJsonArray());
115 return new RuntimeCompletionExpressionType(libraryPath, kind, name, typeArguments, returnType, parameterTypes, parameterNames);
116 }
117
118 public static List<RuntimeCompletionExpressionType> fromJsonArray(JsonArray jsonArray) {
119 if (jsonArray == null) {
120 return EMPTY_LIST;
121 }
122 ArrayList<RuntimeCompletionExpressionType> list = new ArrayList<RuntimeCompletionExpressionType>(jsonArray.size());
123 Iterator<JsonElement> iterator = jsonArray.iterator();
124 while (iterator.hasNext()) {
125 list.add(fromJson(iterator.next().getAsJsonObject()));
126 }
127 return list;
128 }
129
130 /**
131 * The kind of the type.
132 */
133 public String getKind() {
134 return kind;
135 }
136
137 /**
138 * The path of the library that has this type. Omitted if the type is not declared in any library,
139 * e.g. "dynamic", or "void".
140 */
141 public String getLibraryPath() {
142 return libraryPath;
143 }
144
145 /**
146 * The name of the type. Omitted if the type does not have a name, e.g. an inline function type.
147 */
148 public String getName() {
149 return name;
150 }
151
152 /**
153 * If the type is a function type, the names of the function parameters of all kinds - required,
154 * optional positional, and optional named. The names of positional parameters are empty strings.
155 * Omitted if the type is not a function type.
156 */
158 return parameterNames;
159 }
160
161 /**
162 * If the type is a function type, the types of the function parameters of all kinds - required,
163 * optional positional, and optional named. Omitted if the type is not a function type.
164 */
166 return parameterTypes;
167 }
168
169 /**
170 * If the type is a function type, the return type of the function. Omitted if the type is not a
171 * function type.
172 */
174 return returnType;
175 }
176
177 /**
178 * The type arguments of the type. Omitted if the type does not have type parameters.
179 */
181 return typeArguments;
182 }
183
184 @Override
185 public int hashCode() {
186 HashCodeBuilder builder = new HashCodeBuilder();
187 builder.append(libraryPath);
188 builder.append(kind);
189 builder.append(name);
190 builder.append(typeArguments);
191 builder.append(returnType);
192 builder.append(parameterTypes);
193 builder.append(parameterNames);
194 return builder.toHashCode();
195 }
196
197 public JsonObject toJson() {
198 JsonObject jsonObject = new JsonObject();
199 if (libraryPath != null) {
200 jsonObject.addProperty("libraryPath", libraryPath);
201 }
202 jsonObject.addProperty("kind", kind);
203 if (name != null) {
204 jsonObject.addProperty("name", name);
205 }
206 if (typeArguments != null) {
207 JsonArray jsonArrayTypeArguments = new JsonArray();
208 for (RuntimeCompletionExpressionType elt : typeArguments) {
209 jsonArrayTypeArguments.add(elt.toJson());
210 }
211 jsonObject.add("typeArguments", jsonArrayTypeArguments);
212 }
213 if (returnType != null) {
214 jsonObject.add("returnType", returnType.toJson());
215 }
216 if (parameterTypes != null) {
217 JsonArray jsonArrayParameterTypes = new JsonArray();
218 for (RuntimeCompletionExpressionType elt : parameterTypes) {
219 jsonArrayParameterTypes.add(elt.toJson());
220 }
221 jsonObject.add("parameterTypes", jsonArrayParameterTypes);
222 }
223 if (parameterNames != null) {
224 JsonArray jsonArrayParameterNames = new JsonArray();
225 for (String elt : parameterNames) {
226 jsonArrayParameterNames.add(new JsonPrimitive(elt));
227 }
228 jsonObject.add("parameterNames", jsonArrayParameterNames);
229 }
230 return jsonObject;
231 }
232
233 @Override
234 public String toString() {
235 StringBuilder builder = new StringBuilder();
236 builder.append("[");
237 builder.append("libraryPath=");
238 builder.append(libraryPath + ", ");
239 builder.append("kind=");
240 builder.append(kind + ", ");
241 builder.append("name=");
242 builder.append(name + ", ");
243 builder.append("typeArguments=");
244 builder.append(StringUtils.join(typeArguments, ", ") + ", ");
245 builder.append("returnType=");
246 builder.append(returnType + ", ");
247 builder.append("parameterTypes=");
248 builder.append(StringUtils.join(parameterTypes, ", ") + ", ");
249 builder.append("parameterNames=");
250 builder.append(StringUtils.join(parameterNames, ", "));
251 builder.append("]");
252 return builder.toString();
253 }
254
255}
static List< RuntimeCompletionExpressionType > fromJsonArray(JsonArray jsonArray)
static RuntimeCompletionExpressionType fromJson(JsonObject jsonObject)
RuntimeCompletionExpressionType(String libraryPath, String kind, String name, List< RuntimeCompletionExpressionType > typeArguments, RuntimeCompletionExpressionType returnType, List< RuntimeCompletionExpressionType > parameterTypes, List< String > parameterNames)
const char * name
Definition fuchsia.cc:50