Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(413)

Side by Side Diff: pkg/analysis_server/tool/spec/generated/java/types/AnalysisError.java

Issue 1774913006: Add error codes to server protocol (#25958). (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2015, the Dart project authors. 2 * Copyright (c) 2015, the Dart project authors.
3 * 3 *
4 * Licensed under the Eclipse Public License v1.0 (the "License"); you may not u se this file except 4 * Licensed under the Eclipse Public License v1.0 (the "License"); you may not u se this file except
5 * in compliance with the License. You may obtain a copy of the License at 5 * in compliance with the License. You may obtain a copy of the License at
6 * 6 *
7 * http://www.eclipse.org/legal/epl-v10.html 7 * http://www.eclipse.org/legal/epl-v10.html
8 * 8 *
9 * Unless required by applicable law or agreed to in writing, software distribut ed under the License 9 * Unless required by applicable law or agreed to in writing, software distribut ed under the License
10 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY K IND, either express 10 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY K IND, either express
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 private final String message; 65 private final String message;
66 66
67 /** 67 /**
68 * The correction message to be displayed for this error. The correction messa ge should indicate 68 * The correction message to be displayed for this error. The correction messa ge should indicate
69 * how the user can fix the error. The field is omitted if there is no correct ion message 69 * how the user can fix the error. The field is omitted if there is no correct ion message
70 * associated with the error code. 70 * associated with the error code.
71 */ 71 */
72 private final String correction; 72 private final String correction;
73 73
74 /** 74 /**
75 * The name, as a string, of the error code associated with this error.
76 */
77 private final String code;
78
79 /**
75 * A hint to indicate to interested clients that this error has an associated fix (or fixes). The 80 * A hint to indicate to interested clients that this error has an associated fix (or fixes). The
76 * absence of this field implies there are not known to be fixes. Note that si nce the operation to 81 * absence of this field implies there are not known to be fixes. Note that si nce the operation to
77 * calculate whether fixes apply needs to be performant it is possible that co mplicated tests will 82 * calculate whether fixes apply needs to be performant it is possible that co mplicated tests will
78 * be skipped and a false negative returned. For this reason, this attribute s hould be treated as a 83 * be skipped and a false negative returned. For this reason, this attribute s hould be treated as a
79 * "hint". Despite the possibility of false negatives, no false positives shou ld be returned. If a 84 * "hint". Despite the possibility of false negatives, no false positives shou ld be returned. If a
80 * client sees this flag set they can proceed with the confidence that there a re in fact associated 85 * client sees this flag set they can proceed with the confidence that there a re in fact associated
81 * fixes. 86 * fixes.
82 */ 87 */
83 private final Boolean hasFix; 88 private final Boolean hasFix;
84 89
85 /** 90 /**
86 * Constructor for {@link AnalysisError}. 91 * Constructor for {@link AnalysisError}.
87 */ 92 */
88 public AnalysisError(String severity, String type, Location location, String m essage, String correction, Boolean hasFix) { 93 public AnalysisError(String severity, String type, Location location, String m essage, String correction, String code, Boolean hasFix) {
89 this.severity = severity; 94 this.severity = severity;
90 this.type = type; 95 this.type = type;
91 this.location = location; 96 this.location = location;
92 this.message = message; 97 this.message = message;
93 this.correction = correction; 98 this.correction = correction;
99 this.code = code;
94 this.hasFix = hasFix; 100 this.hasFix = hasFix;
95 } 101 }
96 102
97 @Override 103 @Override
98 public boolean equals(Object obj) { 104 public boolean equals(Object obj) {
99 if (obj instanceof AnalysisError) { 105 if (obj instanceof AnalysisError) {
100 AnalysisError other = (AnalysisError) obj; 106 AnalysisError other = (AnalysisError) obj;
101 return 107 return
102 ObjectUtilities.equals(other.severity, severity) && 108 ObjectUtilities.equals(other.severity, severity) &&
103 ObjectUtilities.equals(other.type, type) && 109 ObjectUtilities.equals(other.type, type) &&
104 ObjectUtilities.equals(other.location, location) && 110 ObjectUtilities.equals(other.location, location) &&
105 ObjectUtilities.equals(other.message, message) && 111 ObjectUtilities.equals(other.message, message) &&
106 ObjectUtilities.equals(other.correction, correction) && 112 ObjectUtilities.equals(other.correction, correction) &&
113 ObjectUtilities.equals(other.code, code) &&
107 ObjectUtilities.equals(other.hasFix, hasFix); 114 ObjectUtilities.equals(other.hasFix, hasFix);
108 } 115 }
109 return false; 116 return false;
110 } 117 }
111 118
112 public static AnalysisError fromJson(JsonObject jsonObject) { 119 public static AnalysisError fromJson(JsonObject jsonObject) {
113 String severity = jsonObject.get("severity").getAsString(); 120 String severity = jsonObject.get("severity").getAsString();
114 String type = jsonObject.get("type").getAsString(); 121 String type = jsonObject.get("type").getAsString();
115 Location location = Location.fromJson(jsonObject.get("location").getAsJsonOb ject()); 122 Location location = Location.fromJson(jsonObject.get("location").getAsJsonOb ject());
116 String message = jsonObject.get("message").getAsString(); 123 String message = jsonObject.get("message").getAsString();
117 String correction = jsonObject.get("correction") == null ? null : jsonObject .get("correction").getAsString(); 124 String correction = jsonObject.get("correction") == null ? null : jsonObject .get("correction").getAsString();
125 String code = jsonObject.get("code").getAsString();
118 Boolean hasFix = jsonObject.get("hasFix") == null ? null : jsonObject.get("h asFix").getAsBoolean(); 126 Boolean hasFix = jsonObject.get("hasFix") == null ? null : jsonObject.get("h asFix").getAsBoolean();
119 return new AnalysisError(severity, type, location, message, correction, hasF ix); 127 return new AnalysisError(severity, type, location, message, correction, code , hasFix);
120 } 128 }
121 129
122 public static List<AnalysisError> fromJsonArray(JsonArray jsonArray) { 130 public static List<AnalysisError> fromJsonArray(JsonArray jsonArray) {
123 if (jsonArray == null) { 131 if (jsonArray == null) {
124 return EMPTY_LIST; 132 return EMPTY_LIST;
125 } 133 }
126 ArrayList<AnalysisError> list = new ArrayList<AnalysisError>(jsonArray.size( )); 134 ArrayList<AnalysisError> list = new ArrayList<AnalysisError>(jsonArray.size( ));
127 Iterator<JsonElement> iterator = jsonArray.iterator(); 135 Iterator<JsonElement> iterator = jsonArray.iterator();
128 while (iterator.hasNext()) { 136 while (iterator.hasNext()) {
129 list.add(fromJson(iterator.next().getAsJsonObject())); 137 list.add(fromJson(iterator.next().getAsJsonObject()));
130 } 138 }
131 return list; 139 return list;
132 } 140 }
133 141
134 /** 142 /**
143 * The name, as a string, of the error code associated with this error.
144 */
145 public String getCode() {
146 return code;
147 }
148
149 /**
135 * The correction message to be displayed for this error. The correction messa ge should indicate 150 * The correction message to be displayed for this error. The correction messa ge should indicate
136 * how the user can fix the error. The field is omitted if there is no correct ion message 151 * how the user can fix the error. The field is omitted if there is no correct ion message
137 * associated with the error code. 152 * associated with the error code.
138 */ 153 */
139 public String getCorrection() { 154 public String getCorrection() {
140 return correction; 155 return correction;
141 } 156 }
142 157
143 /** 158 /**
144 * A hint to indicate to interested clients that this error has an associated fix (or fixes). The 159 * A hint to indicate to interested clients that this error has an associated fix (or fixes). The
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 } 198 }
184 199
185 @Override 200 @Override
186 public int hashCode() { 201 public int hashCode() {
187 HashCodeBuilder builder = new HashCodeBuilder(); 202 HashCodeBuilder builder = new HashCodeBuilder();
188 builder.append(severity); 203 builder.append(severity);
189 builder.append(type); 204 builder.append(type);
190 builder.append(location); 205 builder.append(location);
191 builder.append(message); 206 builder.append(message);
192 builder.append(correction); 207 builder.append(correction);
208 builder.append(code);
193 builder.append(hasFix); 209 builder.append(hasFix);
194 return builder.toHashCode(); 210 return builder.toHashCode();
195 } 211 }
196 212
197 public JsonObject toJson() { 213 public JsonObject toJson() {
198 JsonObject jsonObject = new JsonObject(); 214 JsonObject jsonObject = new JsonObject();
199 jsonObject.addProperty("severity", severity); 215 jsonObject.addProperty("severity", severity);
200 jsonObject.addProperty("type", type); 216 jsonObject.addProperty("type", type);
201 jsonObject.add("location", location.toJson()); 217 jsonObject.add("location", location.toJson());
202 jsonObject.addProperty("message", message); 218 jsonObject.addProperty("message", message);
203 if (correction != null) { 219 if (correction != null) {
204 jsonObject.addProperty("correction", correction); 220 jsonObject.addProperty("correction", correction);
205 } 221 }
222 jsonObject.addProperty("code", code);
206 if (hasFix != null) { 223 if (hasFix != null) {
207 jsonObject.addProperty("hasFix", hasFix); 224 jsonObject.addProperty("hasFix", hasFix);
208 } 225 }
209 return jsonObject; 226 return jsonObject;
210 } 227 }
211 228
212 @Override 229 @Override
213 public String toString() { 230 public String toString() {
214 StringBuilder builder = new StringBuilder(); 231 StringBuilder builder = new StringBuilder();
215 builder.append("["); 232 builder.append("[");
216 builder.append("severity="); 233 builder.append("severity=");
217 builder.append(severity + ", "); 234 builder.append(severity + ", ");
218 builder.append("type="); 235 builder.append("type=");
219 builder.append(type + ", "); 236 builder.append(type + ", ");
220 builder.append("location="); 237 builder.append("location=");
221 builder.append(location + ", "); 238 builder.append(location + ", ");
222 builder.append("message="); 239 builder.append("message=");
223 builder.append(message + ", "); 240 builder.append(message + ", ");
224 builder.append("correction="); 241 builder.append("correction=");
225 builder.append(correction + ", "); 242 builder.append(correction + ", ");
243 builder.append("code=");
244 builder.append(code + ", ");
226 builder.append("hasFix="); 245 builder.append("hasFix=");
227 builder.append(hasFix); 246 builder.append(hasFix);
228 builder.append("]"); 247 builder.append("]");
229 return builder.toString(); 248 return builder.toString();
230 } 249 }
231 250
232 } 251 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698