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
file;
56 private final int startLine;
61 private final int startColumn;
66 private final Integer endLine;
71 private final Integer endColumn;
80 this.startLine = startLine;
81 this.startColumn = startColumn;
82 this.endLine = endLine;
83 this.endColumn = endColumn;
94 other.startLine == startLine &&
95 other.startColumn == startColumn &&
96 ObjectUtilities.equals(other.endLine, endLine) &&
97 ObjectUtilities.equals(other.endColumn, endColumn);
103 String
file = jsonObject.get(
"file").getAsString();
104 int offset = jsonObject.get(
"offset").getAsInt();
105 int length = jsonObject.get(
"length").getAsInt();
106 int startLine = jsonObject.get(
"startLine").getAsInt();
107 int startColumn = jsonObject.get(
"startColumn").getAsInt();
108 Integer endLine = jsonObject.get(
"endLine") ==
null ? null : jsonObject.get(
"endLine").getAsInt();
109 Integer endColumn = jsonObject.get(
"endColumn") ==
null ? null : jsonObject.get(
"endColumn").getAsInt();
114 if (jsonArray ==
null) {
117 ArrayList<Location> list =
new ArrayList<Location>(jsonArray.size());
118 Iterator<JsonElement> iterator = jsonArray.iterator();
119 while (iterator.hasNext()) {
120 list.add(fromJson(iterator.next().getAsJsonObject()));
176 HashCodeBuilder
builder =
new HashCodeBuilder();
188 JsonObject jsonObject =
new JsonObject();
189 jsonObject.addProperty(
"file",
file);
190 jsonObject.addProperty(
"offset",
offset);
191 jsonObject.addProperty(
"length",
length);
192 jsonObject.addProperty(
"startLine", startLine);
193 jsonObject.addProperty(
"startColumn", startColumn);
194 if (endLine !=
null) {
195 jsonObject.addProperty(
"endLine", endLine);
197 if (endColumn !=
null) {
198 jsonObject.addProperty(
"endColumn", endColumn);
205 StringBuilder
builder =
new StringBuilder();
214 builder.append(startLine +
", ");
215 builder.append(
"startColumn=");
216 builder.append(startColumn +
", ");
218 builder.append(endLine +
", ");
static Location fromJson(JsonObject jsonObject)
static List< Location > fromJsonArray(JsonArray jsonArray)
boolean equals(Object obj)
Location(String file, int offset, int length, int startLine, int startColumn, Integer endLine, Integer endColumn)