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")
41 private final String kind;
46 private final int fileIndex;
61 private final int startLine;
66 private final int startColumn;
71 private final Integer codeOffset;
76 private final Integer codeLength;
83 public NavigationTarget(String kind,
int fileIndex,
int offset,
int length,
int startLine,
int startColumn, Integer codeOffset, Integer codeLength) {
85 this.fileIndex = fileIndex;
88 this.startLine = startLine;
89 this.startColumn = startColumn;
90 this.codeOffset = codeOffset;
91 this.codeLength = codeLength;
99 ObjectUtilities.
equals(other.kind, kind) &&
100 other.fileIndex == fileIndex &&
103 other.startLine == startLine &&
104 other.startColumn == startColumn &&
105 ObjectUtilities.equals(other.codeOffset, codeOffset) &&
106 ObjectUtilities.equals(other.codeLength, codeLength);
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();
124 if (jsonArray ==
null) {
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()));
197 HashCodeBuilder
builder =
new HashCodeBuilder();
210 file = allTargetFiles[fileIndex];
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);
224 if (codeLength !=
null) {
225 jsonObject.addProperty(
"codeLength", codeLength);
232 StringBuilder
builder =
new StringBuilder();
237 builder.append(fileIndex +
", ");
243 builder.append(startLine +
", ");
244 builder.append(
"startColumn=");
245 builder.append(startColumn +
", ");
247 builder.append(codeOffset +
", ");
static NavigationTarget fromJson(JsonObject jsonObject)
NavigationTarget(String kind, int fileIndex, int offset, int length, int startLine, int startColumn, Integer codeOffset, Integer codeLength)
boolean equals(Object obj)
static List< NavigationTarget > fromJsonArray(JsonArray jsonArray)
void lookupFile(String[] allTargetFiles)