Flutter Engine
The Flutter Engine
RuntimeCompletionExpression.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 * An expression for which we want to know its runtime type. In expressions like 'a.b.c.where((e)
28 * => e.^)' we want to know the runtime type of 'a.b.c' to enforce it statically at the time
29 * when we compute completion suggestions, and get better type for 'e'.
30 *
31 * @coverage dart.server.generated.types
32 */
33@SuppressWarnings("unused")
35
36 public static final RuntimeCompletionExpression[] EMPTY_ARRAY = new RuntimeCompletionExpression[0];
37
38 public static final List<RuntimeCompletionExpression> EMPTY_LIST = Lists.newArrayList();
39
40 /**
41 * The offset of the expression in the code for completion.
42 */
43 private final int offset;
44
45 /**
46 * The length of the expression in the code for completion.
47 */
48 private final int length;
49
50 /**
51 * When the expression is sent from the server to the client, the type is omitted. The client
52 * should fill the type when it sends the request to the server again.
53 */
55
56 /**
57 * Constructor for {@link RuntimeCompletionExpression}.
58 */
60 this.offset = offset;
61 this.length = length;
62 this.type = type;
63 }
64
65 @Override
66 public boolean equals(Object obj) {
67 if (obj instanceof RuntimeCompletionExpression) {
69 return
70 other.offset == offset &&
71 other.length == length &&
72 ObjectUtilities.equals(other.type, type);
73 }
74 return false;
75 }
76
77 public static RuntimeCompletionExpression fromJson(JsonObject jsonObject) {
78 int offset = jsonObject.get("offset").getAsInt();
79 int length = jsonObject.get("length").getAsInt();
80 RuntimeCompletionExpressionType type = jsonObject.get("type") == null ? null : RuntimeCompletionExpressionType.fromJson(jsonObject.get("type").getAsJsonObject());
82 }
83
84 public static List<RuntimeCompletionExpression> fromJsonArray(JsonArray jsonArray) {
85 if (jsonArray == null) {
86 return EMPTY_LIST;
87 }
88 ArrayList<RuntimeCompletionExpression> list = new ArrayList<RuntimeCompletionExpression>(jsonArray.size());
89 Iterator<JsonElement> iterator = jsonArray.iterator();
90 while (iterator.hasNext()) {
91 list.add(fromJson(iterator.next().getAsJsonObject()));
92 }
93 return list;
94 }
95
96 /**
97 * The length of the expression in the code for completion.
98 */
99 public int getLength() {
100 return length;
101 }
102
103 /**
104 * The offset of the expression in the code for completion.
105 */
106 public int getOffset() {
107 return offset;
108 }
109
110 /**
111 * When the expression is sent from the server to the client, the type is omitted. The client
112 * should fill the type when it sends the request to the server again.
113 */
115 return type;
116 }
117
118 @Override
119 public int hashCode() {
120 HashCodeBuilder builder = new HashCodeBuilder();
121 builder.append(offset);
122 builder.append(length);
123 builder.append(type);
124 return builder.toHashCode();
125 }
126
127 public JsonObject toJson() {
128 JsonObject jsonObject = new JsonObject();
129 jsonObject.addProperty("offset", offset);
130 jsonObject.addProperty("length", length);
131 if (type != null) {
132 jsonObject.add("type", type.toJson());
133 }
134 return jsonObject;
135 }
136
137 @Override
138 public String toString() {
139 StringBuilder builder = new StringBuilder();
140 builder.append("[");
141 builder.append("offset=");
142 builder.append(offset + ", ");
143 builder.append("length=");
144 builder.append(length + ", ");
145 builder.append("type=");
146 builder.append(type);
147 builder.append("]");
148 return builder.toString();
149 }
150
151}
GLenum type
static RuntimeCompletionExpressionType fromJson(JsonObject jsonObject)
RuntimeCompletionExpression(int offset, int length, RuntimeCompletionExpressionType type)
static RuntimeCompletionExpression fromJson(JsonObject jsonObject)
static List< RuntimeCompletionExpression > fromJsonArray(JsonArray jsonArray)
size_t length
SeparatedVector2 offset