Flutter Engine
The Flutter Engine
Outline.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 node in the outline structure of a file.
28 *
29 * @coverage dart.server.generated.types
30 */
31@SuppressWarnings("unused")
32public class Outline {
33
34 public static final Outline[] EMPTY_ARRAY = new Outline[0];
35
36 public static final List<Outline> EMPTY_LIST = Lists.newArrayList();
37
38 /**
39 * A description of the element represented by this node.
40 */
41 private Element element;
42
43 /**
44 * The offset of the first character of the element. This is different than the offset in the
45 * Element, which is the offset of the name of the element. It can be used, for example, to map
46 * locations in the file back to an outline.
47 */
48 private int offset;
49
50 /**
51 * The length of the element.
52 */
53 private int length;
54
55 /**
56 * The offset of the first character of the element code, which is neither documentation, nor
57 * annotation.
58 */
59 private int codeOffset;
60
61 /**
62 * The length of the element code.
63 */
64 private int codeLength;
65
66 private final Outline parent;
67
68 private List<Outline> children;
69
70 /**
71 * Constructor for {@link Outline}.
72 */
73 public Outline(Outline parent, Element element, int offset, int length, int codeOffset, int codeLength) {
74 this.parent = parent;
75 this.element = element;
76 this.offset = offset;
77 this.length = length;
78 this.codeOffset = codeOffset;
79 this.codeLength = codeLength;
80 }
81
82 public boolean containsInclusive(int x) {
83 return offset <= x && x <= offset + length;
84 }
85
86 @Override
87 public boolean equals(Object obj) {
88 if (obj instanceof Outline) {
89 Outline other = (Outline) obj;
90 return
91 ObjectUtilities.equals(other.element, element) &&
92 other.offset == offset &&
93 other.length == length &&
94 other.codeOffset == codeOffset &&
95 other.codeLength == codeLength &&
96 ObjectUtilities.equals(other.children, children);
97 }
98 return false;
99 }
100
101 public static Outline fromJson(Outline parent, JsonObject outlineObject) {
102 JsonObject elementObject = outlineObject.get("element").getAsJsonObject();
103 Element element = Element.fromJson(elementObject);
104 int offset = outlineObject.get("offset").getAsInt();
105 int length = outlineObject.get("length").getAsInt();
106 int codeOffset = outlineObject.get("codeOffset").getAsInt();
107 int codeLength = outlineObject.get("codeLength").getAsInt();
108
109 // create outline object
110 Outline outline = new Outline(parent, element, offset, length, codeOffset, codeLength);
111
112 // compute children recursively
113 List<Outline> childrenList = Lists.newArrayList();
114 JsonElement childrenJsonArray = outlineObject.get("children");
115 if (childrenJsonArray instanceof JsonArray) {
116 Iterator<JsonElement> childrenElementIterator = ((JsonArray) childrenJsonArray).iterator();
117 while (childrenElementIterator.hasNext()) {
118 JsonObject childObject = childrenElementIterator.next().getAsJsonObject();
119 childrenList.add(fromJson(outline, childObject));
120 }
121 }
122 outline.setChildren(childrenList);
123 return outline;
124 }
125
127 return parent;
128 }
129
130 /**
131 * The children of the node. The field will be omitted if the node has no children. Children are
132 * sorted by offset.
133 */
135 return children;
136 }
137
138 /**
139 * The length of the element code.
140 */
141 public int getCodeLength() {
142 return codeLength;
143 }
144
145 /**
146 * The offset of the first character of the element code, which is neither documentation, nor
147 * annotation.
148 */
149 public int getCodeOffset() {
150 return codeOffset;
151 }
152
153 /**
154 * A description of the element represented by this node.
155 */
157 return element;
158 }
159
160 /**
161 * The length of the element.
162 */
163 public int getLength() {
164 return length;
165 }
166
167 /**
168 * The offset of the first character of the element. This is different than the offset in the
169 * Element, which is the offset of the name of the element. It can be used, for example, to map
170 * locations in the file back to an outline.
171 */
172 public int getOffset() {
173 return offset;
174 }
175
176 @Override
177 public int hashCode() {
178 HashCodeBuilder builder = new HashCodeBuilder();
179 builder.append(element);
180 builder.append(offset);
181 builder.append(length);
182 builder.append(codeOffset);
183 builder.append(codeLength);
184 builder.append(children);
185 return builder.toHashCode();
186 }
187
188 /**
189 * The children of the node. The field will be omitted if the node has no children. Children are
190 * sorted by offset.
191 */
192 public void setChildren(List<Outline> children) {
193 this.children = children;
194 }
195
196 /**
197 * The length of the element code.
198 */
199 public void setCodeLength(int codeLength) {
200 this.codeLength = codeLength;
201 }
202
203 /**
204 * The offset of the first character of the element code, which is neither documentation, nor
205 * annotation.
206 */
207 public void setCodeOffset(int codeOffset) {
208 this.codeOffset = codeOffset;
209 }
210
211 /**
212 * A description of the element represented by this node.
213 */
214 public void setElement(Element element) {
215 this.element = element;
216 }
217
218 /**
219 * The length of the element.
220 */
221 public void setLength(int length) {
222 this.length = length;
223 }
224
225 /**
226 * The offset of the first character of the element. This is different than the offset in the
227 * Element, which is the offset of the name of the element. It can be used, for example, to map
228 * locations in the file back to an outline.
229 */
230 public void setOffset(int offset) {
231 this.offset = offset;
232 }
233
234 @Override
235 public String toString() {
236 StringBuilder builder = new StringBuilder();
237 builder.append("[");
238 builder.append("element=");
239 builder.append(element + ", ");
240 builder.append("offset=");
241 builder.append(offset + ", ");
242 builder.append("length=");
243 builder.append(length + ", ");
244 builder.append("codeOffset=");
245 builder.append(codeOffset + ", ");
246 builder.append("codeLength=");
247 builder.append(codeLength + ", ");
248 builder.append("children=");
249 builder.append(StringUtils.join(children, ", "));
250 builder.append("]");
251 return builder.toString();
252 }
253
254}
void add(sk_sp< SkIDChangeListener > listener) SK_EXCLUDES(fMutex)
static Element fromJson(JsonObject jsonObject)
Definition: Element.java:134
static Outline fromJson(Outline parent, JsonObject outlineObject)
Definition: Outline.java:101
void setChildren(List< Outline > children)
Definition: Outline.java:192
Outline(Outline parent, Element element, int offset, int length, int codeOffset, int codeLength)
Definition: Outline.java:73
size_t length
double x
SeparatedVector2 offset