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

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

Issue 2726923003: CompletionSuggestion API for arg list text ranges. (Closed)
Patch Set: Added API example. Created 3 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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 * element is not a member of a class. 100 * element is not a member of a class.
101 */ 101 */
102 private final String declaringType; 102 private final String declaringType;
103 103
104 /** 104 /**
105 * A default String for use in generating argument list source contents on the client side. 105 * A default String for use in generating argument list source contents on the client side.
106 */ 106 */
107 private final String defaultArgumentListString; 107 private final String defaultArgumentListString;
108 108
109 /** 109 /**
110 * Pairs of offsets and lengths describing 'defaultArgumentListString' text ra nges suitable for use
111 * by clients to set up linked edits of default argument source contents. For example, given an
112 * argument list string 'x, y', the corresponding text range [0, 1, 3, 1], ind icates two text
113 * ranges of length 1, starting at offsets 0 and 3. Clients can use these rang es to treat the 'x'
114 * and 'y' values specially for linked edits.
115 */
116 private final int[] defaultArgumentListTextRanges;
117
118 /**
110 * Information about the element reference being suggested. 119 * Information about the element reference being suggested.
111 */ 120 */
112 private final Element element; 121 private final Element element;
113 122
114 /** 123 /**
115 * The return type of the getter, function or method or the type of the field being suggested. This 124 * The return type of the getter, function or method or the type of the field being suggested. This
116 * field is omitted if the suggested element is not a getter, function or meth od. 125 * field is omitted if the suggested element is not a getter, function or meth od.
117 */ 126 */
118 private final String returnType; 127 private final String returnType;
119 128
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 164
156 /** 165 /**
157 * The import to be added if the suggestion is out of scope and needs an impor t to be added to be 166 * The import to be added if the suggestion is out of scope and needs an impor t to be added to be
158 * in scope. 167 * in scope.
159 */ 168 */
160 private final String importUri; 169 private final String importUri;
161 170
162 /** 171 /**
163 * Constructor for {@link CompletionSuggestion}. 172 * Constructor for {@link CompletionSuggestion}.
164 */ 173 */
165 public CompletionSuggestion(String kind, int relevance, String completion, int selectionOffset, int selectionLength, boolean isDeprecated, boolean isPotential , String docSummary, String docComplete, String declaringType, String defaultArg umentListString, Element element, String returnType, List<String> parameterNames , List<String> parameterTypes, Integer requiredParameterCount, Boolean hasNamedP arameters, String parameterName, String parameterType, String importUri) { 174 public CompletionSuggestion(String kind, int relevance, String completion, int selectionOffset, int selectionLength, boolean isDeprecated, boolean isPotential , String docSummary, String docComplete, String declaringType, String defaultArg umentListString, int[] defaultArgumentListTextRanges, Element element, String re turnType, List<String> parameterNames, List<String> parameterTypes, Integer requ iredParameterCount, Boolean hasNamedParameters, String parameterName, String par ameterType, String importUri) {
166 this.kind = kind; 175 this.kind = kind;
167 this.relevance = relevance; 176 this.relevance = relevance;
168 this.completion = completion; 177 this.completion = completion;
169 this.selectionOffset = selectionOffset; 178 this.selectionOffset = selectionOffset;
170 this.selectionLength = selectionLength; 179 this.selectionLength = selectionLength;
171 this.isDeprecated = isDeprecated; 180 this.isDeprecated = isDeprecated;
172 this.isPotential = isPotential; 181 this.isPotential = isPotential;
173 this.docSummary = docSummary; 182 this.docSummary = docSummary;
174 this.docComplete = docComplete; 183 this.docComplete = docComplete;
175 this.declaringType = declaringType; 184 this.declaringType = declaringType;
176 this.defaultArgumentListString = defaultArgumentListString; 185 this.defaultArgumentListString = defaultArgumentListString;
186 this.defaultArgumentListTextRanges = defaultArgumentListTextRanges;
177 this.element = element; 187 this.element = element;
178 this.returnType = returnType; 188 this.returnType = returnType;
179 this.parameterNames = parameterNames; 189 this.parameterNames = parameterNames;
180 this.parameterTypes = parameterTypes; 190 this.parameterTypes = parameterTypes;
181 this.requiredParameterCount = requiredParameterCount; 191 this.requiredParameterCount = requiredParameterCount;
182 this.hasNamedParameters = hasNamedParameters; 192 this.hasNamedParameters = hasNamedParameters;
183 this.parameterName = parameterName; 193 this.parameterName = parameterName;
184 this.parameterType = parameterType; 194 this.parameterType = parameterType;
185 this.importUri = importUri; 195 this.importUri = importUri;
186 } 196 }
187 197
188 @Override 198 @Override
189 public boolean equals(Object obj) { 199 public boolean equals(Object obj) {
190 if (obj instanceof CompletionSuggestion) { 200 if (obj instanceof CompletionSuggestion) {
191 CompletionSuggestion other = (CompletionSuggestion) obj; 201 CompletionSuggestion other = (CompletionSuggestion) obj;
192 return 202 return
193 ObjectUtilities.equals(other.kind, kind) && 203 ObjectUtilities.equals(other.kind, kind) &&
194 other.relevance == relevance && 204 other.relevance == relevance &&
195 ObjectUtilities.equals(other.completion, completion) && 205 ObjectUtilities.equals(other.completion, completion) &&
196 other.selectionOffset == selectionOffset && 206 other.selectionOffset == selectionOffset &&
197 other.selectionLength == selectionLength && 207 other.selectionLength == selectionLength &&
198 other.isDeprecated == isDeprecated && 208 other.isDeprecated == isDeprecated &&
199 other.isPotential == isPotential && 209 other.isPotential == isPotential &&
200 ObjectUtilities.equals(other.docSummary, docSummary) && 210 ObjectUtilities.equals(other.docSummary, docSummary) &&
201 ObjectUtilities.equals(other.docComplete, docComplete) && 211 ObjectUtilities.equals(other.docComplete, docComplete) &&
202 ObjectUtilities.equals(other.declaringType, declaringType) && 212 ObjectUtilities.equals(other.declaringType, declaringType) &&
203 ObjectUtilities.equals(other.defaultArgumentListString, defaultArgumentL istString) && 213 ObjectUtilities.equals(other.defaultArgumentListString, defaultArgumentL istString) &&
214 Arrays.equals(other.defaultArgumentListTextRanges, defaultArgumentListTe xtRanges) &&
204 ObjectUtilities.equals(other.element, element) && 215 ObjectUtilities.equals(other.element, element) &&
205 ObjectUtilities.equals(other.returnType, returnType) && 216 ObjectUtilities.equals(other.returnType, returnType) &&
206 ObjectUtilities.equals(other.parameterNames, parameterNames) && 217 ObjectUtilities.equals(other.parameterNames, parameterNames) &&
207 ObjectUtilities.equals(other.parameterTypes, parameterTypes) && 218 ObjectUtilities.equals(other.parameterTypes, parameterTypes) &&
208 ObjectUtilities.equals(other.requiredParameterCount, requiredParameterCo unt) && 219 ObjectUtilities.equals(other.requiredParameterCount, requiredParameterCo unt) &&
209 ObjectUtilities.equals(other.hasNamedParameters, hasNamedParameters) && 220 ObjectUtilities.equals(other.hasNamedParameters, hasNamedParameters) &&
210 ObjectUtilities.equals(other.parameterName, parameterName) && 221 ObjectUtilities.equals(other.parameterName, parameterName) &&
211 ObjectUtilities.equals(other.parameterType, parameterType) && 222 ObjectUtilities.equals(other.parameterType, parameterType) &&
212 ObjectUtilities.equals(other.importUri, importUri); 223 ObjectUtilities.equals(other.importUri, importUri);
213 } 224 }
214 return false; 225 return false;
215 } 226 }
216 227
217 public static CompletionSuggestion fromJson(JsonObject jsonObject) { 228 public static CompletionSuggestion fromJson(JsonObject jsonObject) {
218 String kind = jsonObject.get("kind").getAsString(); 229 String kind = jsonObject.get("kind").getAsString();
219 int relevance = jsonObject.get("relevance").getAsInt(); 230 int relevance = jsonObject.get("relevance").getAsInt();
220 String completion = jsonObject.get("completion").getAsString(); 231 String completion = jsonObject.get("completion").getAsString();
221 int selectionOffset = jsonObject.get("selectionOffset").getAsInt(); 232 int selectionOffset = jsonObject.get("selectionOffset").getAsInt();
222 int selectionLength = jsonObject.get("selectionLength").getAsInt(); 233 int selectionLength = jsonObject.get("selectionLength").getAsInt();
223 boolean isDeprecated = jsonObject.get("isDeprecated").getAsBoolean(); 234 boolean isDeprecated = jsonObject.get("isDeprecated").getAsBoolean();
224 boolean isPotential = jsonObject.get("isPotential").getAsBoolean(); 235 boolean isPotential = jsonObject.get("isPotential").getAsBoolean();
225 String docSummary = jsonObject.get("docSummary") == null ? null : jsonObject .get("docSummary").getAsString(); 236 String docSummary = jsonObject.get("docSummary") == null ? null : jsonObject .get("docSummary").getAsString();
226 String docComplete = jsonObject.get("docComplete") == null ? null : jsonObje ct.get("docComplete").getAsString(); 237 String docComplete = jsonObject.get("docComplete") == null ? null : jsonObje ct.get("docComplete").getAsString();
227 String declaringType = jsonObject.get("declaringType") == null ? null : json Object.get("declaringType").getAsString(); 238 String declaringType = jsonObject.get("declaringType") == null ? null : json Object.get("declaringType").getAsString();
228 String defaultArgumentListString = jsonObject.get("defaultArgumentListString ") == null ? null : jsonObject.get("defaultArgumentListString").getAsString(); 239 String defaultArgumentListString = jsonObject.get("defaultArgumentListString ") == null ? null : jsonObject.get("defaultArgumentListString").getAsString();
240 int[] defaultArgumentListTextRanges = jsonObject.get("defaultArgumentListTex tRanges") == null ? null : JsonUtilities.decodeIntArray(jsonObject.get("defaultA rgumentListTextRanges").getAsJsonArray());
229 Element element = jsonObject.get("element") == null ? null : Element.fromJso n(jsonObject.get("element").getAsJsonObject()); 241 Element element = jsonObject.get("element") == null ? null : Element.fromJso n(jsonObject.get("element").getAsJsonObject());
230 String returnType = jsonObject.get("returnType") == null ? null : jsonObject .get("returnType").getAsString(); 242 String returnType = jsonObject.get("returnType") == null ? null : jsonObject .get("returnType").getAsString();
231 List<String> parameterNames = jsonObject.get("parameterNames") == null ? nul l : JsonUtilities.decodeStringList(jsonObject.get("parameterNames").getAsJsonArr ay()); 243 List<String> parameterNames = jsonObject.get("parameterNames") == null ? nul l : JsonUtilities.decodeStringList(jsonObject.get("parameterNames").getAsJsonArr ay());
232 List<String> parameterTypes = jsonObject.get("parameterTypes") == null ? nul l : JsonUtilities.decodeStringList(jsonObject.get("parameterTypes").getAsJsonArr ay()); 244 List<String> parameterTypes = jsonObject.get("parameterTypes") == null ? nul l : JsonUtilities.decodeStringList(jsonObject.get("parameterTypes").getAsJsonArr ay());
233 Integer requiredParameterCount = jsonObject.get("requiredParameterCount") == null ? null : jsonObject.get("requiredParameterCount").getAsInt(); 245 Integer requiredParameterCount = jsonObject.get("requiredParameterCount") == null ? null : jsonObject.get("requiredParameterCount").getAsInt();
234 Boolean hasNamedParameters = jsonObject.get("hasNamedParameters") == null ? null : jsonObject.get("hasNamedParameters").getAsBoolean(); 246 Boolean hasNamedParameters = jsonObject.get("hasNamedParameters") == null ? null : jsonObject.get("hasNamedParameters").getAsBoolean();
235 String parameterName = jsonObject.get("parameterName") == null ? null : json Object.get("parameterName").getAsString(); 247 String parameterName = jsonObject.get("parameterName") == null ? null : json Object.get("parameterName").getAsString();
236 String parameterType = jsonObject.get("parameterType") == null ? null : json Object.get("parameterType").getAsString(); 248 String parameterType = jsonObject.get("parameterType") == null ? null : json Object.get("parameterType").getAsString();
237 String importUri = jsonObject.get("importUri") == null ? null : jsonObject.g et("importUri").getAsString(); 249 String importUri = jsonObject.get("importUri") == null ? null : jsonObject.g et("importUri").getAsString();
238 return new CompletionSuggestion(kind, relevance, completion, selectionOffset , selectionLength, isDeprecated, isPotential, docSummary, docComplete, declaring Type, defaultArgumentListString, element, returnType, parameterNames, parameterT ypes, requiredParameterCount, hasNamedParameters, parameterName, parameterType, importUri); 250 return new CompletionSuggestion(kind, relevance, completion, selectionOffset , selectionLength, isDeprecated, isPotential, docSummary, docComplete, declaring Type, defaultArgumentListString, defaultArgumentListTextRanges, element, returnT ype, parameterNames, parameterTypes, requiredParameterCount, hasNamedParameters, parameterName, parameterType, importUri);
239 } 251 }
240 252
241 public static List<CompletionSuggestion> fromJsonArray(JsonArray jsonArray) { 253 public static List<CompletionSuggestion> fromJsonArray(JsonArray jsonArray) {
242 if (jsonArray == null) { 254 if (jsonArray == null) {
243 return EMPTY_LIST; 255 return EMPTY_LIST;
244 } 256 }
245 ArrayList<CompletionSuggestion> list = new ArrayList<CompletionSuggestion>(j sonArray.size()); 257 ArrayList<CompletionSuggestion> list = new ArrayList<CompletionSuggestion>(j sonArray.size());
246 Iterator<JsonElement> iterator = jsonArray.iterator(); 258 Iterator<JsonElement> iterator = jsonArray.iterator();
247 while (iterator.hasNext()) { 259 while (iterator.hasNext()) {
248 list.add(fromJson(iterator.next().getAsJsonObject())); 260 list.add(fromJson(iterator.next().getAsJsonObject()));
(...skipping 19 matching lines...) Expand all
268 } 280 }
269 281
270 /** 282 /**
271 * A default String for use in generating argument list source contents on the client side. 283 * A default String for use in generating argument list source contents on the client side.
272 */ 284 */
273 public String getDefaultArgumentListString() { 285 public String getDefaultArgumentListString() {
274 return defaultArgumentListString; 286 return defaultArgumentListString;
275 } 287 }
276 288
277 /** 289 /**
290 * Pairs of offsets and lengths describing 'defaultArgumentListString' text ra nges suitable for use
291 * by clients to set up linked edits of default argument source contents. For example, given an
292 * argument list string 'x, y', the corresponding text range [0, 1, 3, 1], ind icates two text
293 * ranges of length 1, starting at offsets 0 and 3. Clients can use these rang es to treat the 'x'
294 * and 'y' values specially for linked edits.
295 */
296 public int[] getDefaultArgumentListTextRanges() {
297 return defaultArgumentListTextRanges;
298 }
299
300 /**
278 * The Dartdoc associated with the element being suggested, This field is omit ted if there is no 301 * The Dartdoc associated with the element being suggested, This field is omit ted if there is no
279 * Dartdoc associated with the element. 302 * Dartdoc associated with the element.
280 */ 303 */
281 public String getDocComplete() { 304 public String getDocComplete() {
282 return docComplete; 305 return docComplete;
283 } 306 }
284 307
285 /** 308 /**
286 * An abbreviated version of the Dartdoc associated with the element being sug gested, This field is 309 * An abbreviated version of the Dartdoc associated with the element being sug gested, This field is
287 * omitted if there is no Dartdoc associated with the element. 310 * omitted if there is no Dartdoc associated with the element.
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
412 builder.append(relevance); 435 builder.append(relevance);
413 builder.append(completion); 436 builder.append(completion);
414 builder.append(selectionOffset); 437 builder.append(selectionOffset);
415 builder.append(selectionLength); 438 builder.append(selectionLength);
416 builder.append(isDeprecated); 439 builder.append(isDeprecated);
417 builder.append(isPotential); 440 builder.append(isPotential);
418 builder.append(docSummary); 441 builder.append(docSummary);
419 builder.append(docComplete); 442 builder.append(docComplete);
420 builder.append(declaringType); 443 builder.append(declaringType);
421 builder.append(defaultArgumentListString); 444 builder.append(defaultArgumentListString);
445 builder.append(defaultArgumentListTextRanges);
422 builder.append(element); 446 builder.append(element);
423 builder.append(returnType); 447 builder.append(returnType);
424 builder.append(parameterNames); 448 builder.append(parameterNames);
425 builder.append(parameterTypes); 449 builder.append(parameterTypes);
426 builder.append(requiredParameterCount); 450 builder.append(requiredParameterCount);
427 builder.append(hasNamedParameters); 451 builder.append(hasNamedParameters);
428 builder.append(parameterName); 452 builder.append(parameterName);
429 builder.append(parameterType); 453 builder.append(parameterType);
430 builder.append(importUri); 454 builder.append(importUri);
431 return builder.toHashCode(); 455 return builder.toHashCode();
(...skipping 13 matching lines...) Expand all
445 } 469 }
446 if (docComplete != null) { 470 if (docComplete != null) {
447 jsonObject.addProperty("docComplete", docComplete); 471 jsonObject.addProperty("docComplete", docComplete);
448 } 472 }
449 if (declaringType != null) { 473 if (declaringType != null) {
450 jsonObject.addProperty("declaringType", declaringType); 474 jsonObject.addProperty("declaringType", declaringType);
451 } 475 }
452 if (defaultArgumentListString != null) { 476 if (defaultArgumentListString != null) {
453 jsonObject.addProperty("defaultArgumentListString", defaultArgumentListStr ing); 477 jsonObject.addProperty("defaultArgumentListString", defaultArgumentListStr ing);
454 } 478 }
479 if (defaultArgumentListTextRanges != null) {
480 JsonArray jsonArrayDefaultArgumentListTextRanges = new JsonArray();
481 for (int elt : defaultArgumentListTextRanges) {
482 jsonArrayDefaultArgumentListTextRanges.add(new JsonPrimitive(elt));
483 }
484 jsonObject.add("defaultArgumentListTextRanges", jsonArrayDefaultArgumentLi stTextRanges);
485 }
455 if (element != null) { 486 if (element != null) {
456 jsonObject.add("element", element.toJson()); 487 jsonObject.add("element", element.toJson());
457 } 488 }
458 if (returnType != null) { 489 if (returnType != null) {
459 jsonObject.addProperty("returnType", returnType); 490 jsonObject.addProperty("returnType", returnType);
460 } 491 }
461 if (parameterNames != null) { 492 if (parameterNames != null) {
462 JsonArray jsonArrayParameterNames = new JsonArray(); 493 JsonArray jsonArrayParameterNames = new JsonArray();
463 for (String elt : parameterNames) { 494 for (String elt : parameterNames) {
464 jsonArrayParameterNames.add(new JsonPrimitive(elt)); 495 jsonArrayParameterNames.add(new JsonPrimitive(elt));
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
509 builder.append("isPotential="); 540 builder.append("isPotential=");
510 builder.append(isPotential + ", "); 541 builder.append(isPotential + ", ");
511 builder.append("docSummary="); 542 builder.append("docSummary=");
512 builder.append(docSummary + ", "); 543 builder.append(docSummary + ", ");
513 builder.append("docComplete="); 544 builder.append("docComplete=");
514 builder.append(docComplete + ", "); 545 builder.append(docComplete + ", ");
515 builder.append("declaringType="); 546 builder.append("declaringType=");
516 builder.append(declaringType + ", "); 547 builder.append(declaringType + ", ");
517 builder.append("defaultArgumentListString="); 548 builder.append("defaultArgumentListString=");
518 builder.append(defaultArgumentListString + ", "); 549 builder.append(defaultArgumentListString + ", ");
550 builder.append("defaultArgumentListTextRanges=");
551 builder.append(StringUtils.join(defaultArgumentListTextRanges, ", ") + ", ") ;
519 builder.append("element="); 552 builder.append("element=");
520 builder.append(element + ", "); 553 builder.append(element + ", ");
521 builder.append("returnType="); 554 builder.append("returnType=");
522 builder.append(returnType + ", "); 555 builder.append(returnType + ", ");
523 builder.append("parameterNames="); 556 builder.append("parameterNames=");
524 builder.append(StringUtils.join(parameterNames, ", ") + ", "); 557 builder.append(StringUtils.join(parameterNames, ", ") + ", ");
525 builder.append("parameterTypes="); 558 builder.append("parameterTypes=");
526 builder.append(StringUtils.join(parameterTypes, ", ") + ", "); 559 builder.append(StringUtils.join(parameterTypes, ", ") + ", ");
527 builder.append("requiredParameterCount="); 560 builder.append("requiredParameterCount=");
528 builder.append(requiredParameterCount + ", "); 561 builder.append(requiredParameterCount + ", ");
529 builder.append("hasNamedParameters="); 562 builder.append("hasNamedParameters=");
530 builder.append(hasNamedParameters + ", "); 563 builder.append(hasNamedParameters + ", ");
531 builder.append("parameterName="); 564 builder.append("parameterName=");
532 builder.append(parameterName + ", "); 565 builder.append(parameterName + ", ");
533 builder.append("parameterType="); 566 builder.append("parameterType=");
534 builder.append(parameterType + ", "); 567 builder.append(parameterType + ", ");
535 builder.append("importUri="); 568 builder.append("importUri=");
536 builder.append(importUri); 569 builder.append(importUri);
537 builder.append("]"); 570 builder.append("]");
538 return builder.toString(); 571 return builder.toString();
539 } 572 }
540 573
541 } 574 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/test/integration/protocol_matchers.dart ('k') | pkg/analysis_server/tool/spec/spec_input.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698