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 severity;
46 private final String
type;
64 private final String correction;
69 private final String
code;
74 private final String url;
91 private final Boolean hasFix;
97 this.severity = severity;
99 this.location = location;
101 this.correction = correction;
104 this.contextMessages = contextMessages;
105 this.hasFix = hasFix;
113 ObjectUtilities.
equals(other.severity, severity) &&
114 ObjectUtilities.equals(other.type,
type) &&
115 ObjectUtilities.equals(other.location, location) &&
116 ObjectUtilities.equals(other.message,
message) &&
117 ObjectUtilities.equals(other.correction, correction) &&
118 ObjectUtilities.equals(other.code,
code) &&
119 ObjectUtilities.equals(other.url, url) &&
120 ObjectUtilities.equals(other.contextMessages, contextMessages) &&
121 ObjectUtilities.equals(other.hasFix, hasFix);
127 String severity = jsonObject.get(
"severity").getAsString();
128 String
type = jsonObject.get(
"type").getAsString();
130 String
message = jsonObject.get(
"message").getAsString();
131 String correction = jsonObject.get(
"correction") ==
null ? null : jsonObject.get(
"correction").getAsString();
132 String
code = jsonObject.get(
"code").getAsString();
133 String url = jsonObject.get(
"url") ==
null ? null : jsonObject.get(
"url").getAsString();
135 Boolean hasFix = jsonObject.get(
"hasFix") ==
null ? null : jsonObject.get(
"hasFix").getAsBoolean();
140 if (jsonArray ==
null) {
143 ArrayList<AnalysisError> list =
new ArrayList<AnalysisError>(jsonArray.size());
144 Iterator<JsonElement> iterator = jsonArray.iterator();
145 while (iterator.hasNext()) {
146 list.add(fromJson(iterator.next().getAsJsonObject()));
163 return contextMessages;
226 HashCodeBuilder
builder =
new HashCodeBuilder();
234 builder.append(contextMessages);
240 JsonObject jsonObject =
new JsonObject();
241 jsonObject.addProperty(
"severity", severity);
242 jsonObject.addProperty(
"type",
type);
243 jsonObject.add(
"location", location.
toJson());
244 jsonObject.addProperty(
"message",
message);
245 if (correction !=
null) {
246 jsonObject.addProperty(
"correction", correction);
248 jsonObject.addProperty(
"code",
code);
250 jsonObject.addProperty(
"url", url);
252 if (contextMessages !=
null) {
253 JsonArray jsonArrayContextMessages =
new JsonArray();
255 jsonArrayContextMessages.add(elt.toJson());
257 jsonObject.add(
"contextMessages", jsonArrayContextMessages);
259 if (hasFix !=
null) {
260 jsonObject.addProperty(
"hasFix", hasFix);
267 StringBuilder
builder =
new StringBuilder();
270 builder.append(severity +
", ");
274 builder.append(location +
", ");
278 builder.append(correction +
", ");
283 builder.append(
"contextMessages=");
284 builder.append(StringUtils.join(contextMessages,
", ") +
", ");
boolean equals(Object obj)
static AnalysisError fromJson(JsonObject jsonObject)
AnalysisError(String severity, String type, Location location, String message, String correction, String code, String url, List< DiagnosticMessage > contextMessages, Boolean hasFix)
List< DiagnosticMessage > getContextMessages()
static List< AnalysisError > fromJsonArray(JsonArray jsonArray)
static List< DiagnosticMessage > fromJsonArray(JsonArray jsonArray)
static Location fromJson(JsonObject jsonObject)