Flutter Engine
The Flutter Engine
NavigationTarget.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 description of a target to which the user can navigate.
28 *
29 * @coverage dart.server.generated.types
30 */
31@SuppressWarnings("unused")
32public class NavigationTarget {
33
34 public static final NavigationTarget[] EMPTY_ARRAY = new NavigationTarget[0];
35
36 public static final List<NavigationTarget> EMPTY_LIST = Lists.newArrayList();
37
38 /**
39 * The kind of the element.
40 */
41 private final String kind;
42
43 /**
44 * The index of the file (in the enclosing navigation response) to navigate to.
45 */
46 private final int fileIndex;
47
48 /**
49 * The offset of the name of the target to which the user can navigate.
50 */
51 private final int offset;
52
53 /**
54 * The length of the name of the target to which the user can navigate.
55 */
56 private final int length;
57
58 /**
59 * The one-based index of the line containing the first character of the name of the target.
60 */
61 private final int startLine;
62
63 /**
64 * The one-based index of the column containing the first character of the name of the target.
65 */
66 private final int startColumn;
67
68 /**
69 * The offset of the target code to which the user can navigate.
70 */
71 private final Integer codeOffset;
72
73 /**
74 * The length of the target code to which the user can navigate.
75 */
76 private final Integer codeLength;
77
78 private String file;
79
80 /**
81 * Constructor for {@link NavigationTarget}.
82 */
83 public NavigationTarget(String kind, int fileIndex, int offset, int length, int startLine, int startColumn, Integer codeOffset, Integer codeLength) {
84 this.kind = kind;
85 this.fileIndex = fileIndex;
86 this.offset = offset;
87 this.length = length;
88 this.startLine = startLine;
89 this.startColumn = startColumn;
90 this.codeOffset = codeOffset;
91 this.codeLength = codeLength;
92 }
93
94 @Override
95 public boolean equals(Object obj) {
96 if (obj instanceof NavigationTarget) {
98 return
99 ObjectUtilities.equals(other.kind, kind) &&
100 other.fileIndex == fileIndex &&
101 other.offset == offset &&
102 other.length == length &&
103 other.startLine == startLine &&
104 other.startColumn == startColumn &&
105 ObjectUtilities.equals(other.codeOffset, codeOffset) &&
106 ObjectUtilities.equals(other.codeLength, codeLength);
107 }
108 return false;
109 }
110
111 public static NavigationTarget fromJson(JsonObject jsonObject) {
112 String kind = jsonObject.get("kind").getAsString();
113 int fileIndex = jsonObject.get("fileIndex").getAsInt();
114 int offset = jsonObject.get("offset").getAsInt();
115 int length = jsonObject.get("length").getAsInt();
116 int startLine = jsonObject.get("startLine").getAsInt();
117 int startColumn = jsonObject.get("startColumn").getAsInt();
118 Integer codeOffset = jsonObject.get("codeOffset") == null ? null : jsonObject.get("codeOffset").getAsInt();
119 Integer codeLength = jsonObject.get("codeLength") == null ? null : jsonObject.get("codeLength").getAsInt();
120 return new NavigationTarget(kind, fileIndex, offset, length, startLine, startColumn, codeOffset, codeLength);
121 }
122
123 public static List<NavigationTarget> fromJsonArray(JsonArray jsonArray) {
124 if (jsonArray == null) {
125 return EMPTY_LIST;
126 }
127 ArrayList<NavigationTarget> list = new ArrayList<NavigationTarget>(jsonArray.size());
128 Iterator<JsonElement> iterator = jsonArray.iterator();
129 while (iterator.hasNext()) {
130 list.add(fromJson(iterator.next().getAsJsonObject()));
131 }
132 return list;
133 }
134
135 public String getFile() {
136 return file;
137 }
138
139 /**
140 * The length of the target code to which the user can navigate.
141 */
142 public Integer getCodeLength() {
143 return codeLength;
144 }
145
146 /**
147 * The offset of the target code to which the user can navigate.
148 */
149 public Integer getCodeOffset() {
150 return codeOffset;
151 }
152
153 /**
154 * The index of the file (in the enclosing navigation response) to navigate to.
155 */
156 public int getFileIndex() {
157 return fileIndex;
158 }
159
160 /**
161 * The kind of the element.
162 */
163 public String getKind() {
164 return kind;
165 }
166
167 /**
168 * The length of the name of the target to which the user can navigate.
169 */
170 public int getLength() {
171 return length;
172 }
173
174 /**
175 * The offset of the name of the target to which the user can navigate.
176 */
177 public int getOffset() {
178 return offset;
179 }
180
181 /**
182 * The one-based index of the column containing the first character of the name of the target.
183 */
184 public int getStartColumn() {
185 return startColumn;
186 }
187
188 /**
189 * The one-based index of the line containing the first character of the name of the target.
190 */
191 public int getStartLine() {
192 return startLine;
193 }
194
195 @Override
196 public int hashCode() {
197 HashCodeBuilder builder = new HashCodeBuilder();
198 builder.append(kind);
199 builder.append(fileIndex);
200 builder.append(offset);
201 builder.append(length);
202 builder.append(startLine);
203 builder.append(startColumn);
204 builder.append(codeOffset);
205 builder.append(codeLength);
206 return builder.toHashCode();
207 }
208
209 public void lookupFile(String[] allTargetFiles) {
210 file = allTargetFiles[fileIndex];
211 }
212
213 public JsonObject toJson() {
214 JsonObject jsonObject = new JsonObject();
215 jsonObject.addProperty("kind", kind);
216 jsonObject.addProperty("fileIndex", fileIndex);
217 jsonObject.addProperty("offset", offset);
218 jsonObject.addProperty("length", length);
219 jsonObject.addProperty("startLine", startLine);
220 jsonObject.addProperty("startColumn", startColumn);
221 if (codeOffset != null) {
222 jsonObject.addProperty("codeOffset", codeOffset);
223 }
224 if (codeLength != null) {
225 jsonObject.addProperty("codeLength", codeLength);
226 }
227 return jsonObject;
228 }
229
230 @Override
231 public String toString() {
232 StringBuilder builder = new StringBuilder();
233 builder.append("[");
234 builder.append("kind=");
235 builder.append(kind + ", ");
236 builder.append("fileIndex=");
237 builder.append(fileIndex + ", ");
238 builder.append("offset=");
239 builder.append(offset + ", ");
240 builder.append("length=");
241 builder.append(length + ", ");
242 builder.append("startLine=");
243 builder.append(startLine + ", ");
244 builder.append("startColumn=");
245 builder.append(startColumn + ", ");
246 builder.append("codeOffset=");
247 builder.append(codeOffset + ", ");
248 builder.append("codeLength=");
249 builder.append(codeLength);
250 builder.append("]");
251 return builder.toString();
252 }
253
254}
static NavigationTarget fromJson(JsonObject jsonObject)
NavigationTarget(String kind, int fileIndex, int offset, int length, int startLine, int startColumn, Integer codeOffset, Integer codeLength)
static List< NavigationTarget > fromJsonArray(JsonArray jsonArray)
size_t length
SeparatedVector2 offset