CompletionSuggestion API for arg list text ranges.

BUG=
R=brianwilkerson@google.com

Review-Url: https://codereview.chromium.org/2726923003 .
This commit is contained in:
pq 2017-03-01 16:10:46 -08:00
parent c6d1a0d381
commit b17f4b2b5d
5 changed files with 97 additions and 4 deletions

View file

@ -2804,6 +2804,17 @@ a:focus, a:hover {
A default String for use in generating argument list
source contents on the client side.
</p>
</dd><dt class="field"><b>defaultArgumentListTextRanges (<span style="color:#999999">optional</span> List&lt;int&gt;)</b></dt><dd>
<p>
Pairs of offsets and lengths describing 'defaultArgumentListString'
text ranges suitable for use by clients to set up linked edits of
default argument source contents. For example, given an argument
list string 'x, y', the corresponding text range [0, 1, 3, 1],
indicates two text ranges of length 1, starting at offsets 0 and 3.
Clients can use these ranges to treat the 'x' and 'y' values
specially for linked edits.
</p>
</dd><dt class="field"><b>element (<span style="color:#999999">optional</span> <a href="#type_Element">Element</a>)</b></dt><dd>
<p>

View file

@ -8971,6 +8971,7 @@ class ChangeContentOverlay implements HasToJson {
* "docComplete": optional String
* "declaringType": optional String
* "defaultArgumentListString": optional String
* "defaultArgumentListTextRanges": optional List<int>
* "element": optional Element
* "returnType": optional String
* "parameterNames": optional List<String>
@ -9007,6 +9008,8 @@ class CompletionSuggestion implements HasToJson {
String _defaultArgumentListString;
List<int> _defaultArgumentListTextRanges;
Element _element;
String _returnType;
@ -9186,6 +9189,28 @@ class CompletionSuggestion implements HasToJson {
this._defaultArgumentListString = value;
}
/**
* Pairs of offsets and lengths describing 'defaultArgumentListString' text
* ranges suitable for use by clients to set up linked edits of default
* argument source contents. For example, given an argument list string 'x,
* y', the corresponding text range [0, 1, 3, 1], indicates two text ranges
* of length 1, starting at offsets 0 and 3. Clients can use these ranges to
* treat the 'x' and 'y' values specially for linked edits.
*/
List<int> get defaultArgumentListTextRanges => _defaultArgumentListTextRanges;
/**
* Pairs of offsets and lengths describing 'defaultArgumentListString' text
* ranges suitable for use by clients to set up linked edits of default
* argument source contents. For example, given an argument list string 'x,
* y', the corresponding text range [0, 1, 3, 1], indicates two text ranges
* of length 1, starting at offsets 0 and 3. Clients can use these ranges to
* treat the 'x' and 'y' values specially for linked edits.
*/
void set defaultArgumentListTextRanges(List<int> value) {
this._defaultArgumentListTextRanges = value;
}
/**
* Information about the element reference being suggested.
*/
@ -9316,7 +9341,7 @@ class CompletionSuggestion implements HasToJson {
this._importUri = value;
}
CompletionSuggestion(CompletionSuggestionKind kind, int relevance, String completion, int selectionOffset, int selectionLength, bool isDeprecated, bool isPotential, {String docSummary, String docComplete, String declaringType, String defaultArgumentListString, Element element, String returnType, List<String> parameterNames, List<String> parameterTypes, int requiredParameterCount, bool hasNamedParameters, String parameterName, String parameterType, String importUri}) {
CompletionSuggestion(CompletionSuggestionKind kind, int relevance, String completion, int selectionOffset, int selectionLength, bool isDeprecated, bool isPotential, {String docSummary, String docComplete, String declaringType, String defaultArgumentListString, List<int> defaultArgumentListTextRanges, Element element, String returnType, List<String> parameterNames, List<String> parameterTypes, int requiredParameterCount, bool hasNamedParameters, String parameterName, String parameterType, String importUri}) {
this.kind = kind;
this.relevance = relevance;
this.completion = completion;
@ -9328,6 +9353,7 @@ class CompletionSuggestion implements HasToJson {
this.docComplete = docComplete;
this.declaringType = declaringType;
this.defaultArgumentListString = defaultArgumentListString;
this.defaultArgumentListTextRanges = defaultArgumentListTextRanges;
this.element = element;
this.returnType = returnType;
this.parameterNames = parameterNames;
@ -9402,6 +9428,10 @@ class CompletionSuggestion implements HasToJson {
if (json.containsKey("defaultArgumentListString")) {
defaultArgumentListString = jsonDecoder.decodeString(jsonPath + ".defaultArgumentListString", json["defaultArgumentListString"]);
}
List<int> defaultArgumentListTextRanges;
if (json.containsKey("defaultArgumentListTextRanges")) {
defaultArgumentListTextRanges = jsonDecoder.decodeList(jsonPath + ".defaultArgumentListTextRanges", json["defaultArgumentListTextRanges"], jsonDecoder.decodeInt);
}
Element element;
if (json.containsKey("element")) {
element = new Element.fromJson(jsonDecoder, jsonPath + ".element", json["element"]);
@ -9438,7 +9468,7 @@ class CompletionSuggestion implements HasToJson {
if (json.containsKey("importUri")) {
importUri = jsonDecoder.decodeString(jsonPath + ".importUri", json["importUri"]);
}
return new CompletionSuggestion(kind, relevance, completion, selectionOffset, selectionLength, isDeprecated, isPotential, docSummary: docSummary, docComplete: docComplete, declaringType: declaringType, defaultArgumentListString: defaultArgumentListString, element: element, returnType: returnType, parameterNames: parameterNames, parameterTypes: parameterTypes, requiredParameterCount: requiredParameterCount, hasNamedParameters: hasNamedParameters, parameterName: parameterName, parameterType: parameterType, importUri: importUri);
return new CompletionSuggestion(kind, relevance, completion, selectionOffset, selectionLength, isDeprecated, isPotential, docSummary: docSummary, docComplete: docComplete, declaringType: declaringType, defaultArgumentListString: defaultArgumentListString, defaultArgumentListTextRanges: defaultArgumentListTextRanges, element: element, returnType: returnType, parameterNames: parameterNames, parameterTypes: parameterTypes, requiredParameterCount: requiredParameterCount, hasNamedParameters: hasNamedParameters, parameterName: parameterName, parameterType: parameterType, importUri: importUri);
} else {
throw jsonDecoder.mismatch(jsonPath, "CompletionSuggestion", json);
}
@ -9465,6 +9495,9 @@ class CompletionSuggestion implements HasToJson {
if (defaultArgumentListString != null) {
result["defaultArgumentListString"] = defaultArgumentListString;
}
if (defaultArgumentListTextRanges != null) {
result["defaultArgumentListTextRanges"] = defaultArgumentListTextRanges;
}
if (element != null) {
result["element"] = element.toJson();
}
@ -9512,6 +9545,7 @@ class CompletionSuggestion implements HasToJson {
docComplete == other.docComplete &&
declaringType == other.declaringType &&
defaultArgumentListString == other.defaultArgumentListString &&
listEqual(defaultArgumentListTextRanges, other.defaultArgumentListTextRanges, (int a, int b) => a == b) &&
element == other.element &&
returnType == other.returnType &&
listEqual(parameterNames, other.parameterNames, (String a, String b) => a == b) &&
@ -9539,6 +9573,7 @@ class CompletionSuggestion implements HasToJson {
hash = JenkinsSmiHash.combine(hash, docComplete.hashCode);
hash = JenkinsSmiHash.combine(hash, declaringType.hashCode);
hash = JenkinsSmiHash.combine(hash, defaultArgumentListString.hashCode);
hash = JenkinsSmiHash.combine(hash, defaultArgumentListTextRanges.hashCode);
hash = JenkinsSmiHash.combine(hash, element.hashCode);
hash = JenkinsSmiHash.combine(hash, returnType.hashCode);
hash = JenkinsSmiHash.combine(hash, parameterNames.hashCode);

View file

@ -1264,6 +1264,7 @@ final Matcher isCompletionId = isString;
* "docComplete": optional String
* "declaringType": optional String
* "defaultArgumentListString": optional String
* "defaultArgumentListTextRanges": optional List<int>
* "element": optional Element
* "returnType": optional String
* "parameterNames": optional List<String>
@ -1289,6 +1290,7 @@ final Matcher isCompletionSuggestion = new LazyMatcher(() => new MatchesJsonObje
"docComplete": isString,
"declaringType": isString,
"defaultArgumentListString": isString,
"defaultArgumentListTextRanges": isListOf(isInt),
"element": isElement,
"returnType": isString,
"parameterNames": isListOf(isString),

View file

@ -106,6 +106,15 @@ public class CompletionSuggestion {
*/
private final String defaultArgumentListString;
/**
* Pairs of offsets and lengths describing 'defaultArgumentListString' text ranges suitable for use
* by clients to set up linked edits of default argument source contents. For example, given an
* argument list string 'x, y', the corresponding text range [0, 1, 3, 1], indicates two text
* ranges of length 1, starting at offsets 0 and 3. Clients can use these ranges to treat the 'x'
* and 'y' values specially for linked edits.
*/
private final int[] defaultArgumentListTextRanges;
/**
* Information about the element reference being suggested.
*/
@ -162,7 +171,7 @@ public class CompletionSuggestion {
/**
* Constructor for {@link CompletionSuggestion}.
*/
public CompletionSuggestion(String kind, int relevance, String completion, int selectionOffset, int selectionLength, boolean isDeprecated, boolean isPotential, String docSummary, String docComplete, String declaringType, String defaultArgumentListString, Element element, String returnType, List<String> parameterNames, List<String> parameterTypes, Integer requiredParameterCount, Boolean hasNamedParameters, String parameterName, String parameterType, String importUri) {
public CompletionSuggestion(String kind, int relevance, String completion, int selectionOffset, int selectionLength, boolean isDeprecated, boolean isPotential, String docSummary, String docComplete, String declaringType, String defaultArgumentListString, int[] defaultArgumentListTextRanges, Element element, String returnType, List<String> parameterNames, List<String> parameterTypes, Integer requiredParameterCount, Boolean hasNamedParameters, String parameterName, String parameterType, String importUri) {
this.kind = kind;
this.relevance = relevance;
this.completion = completion;
@ -174,6 +183,7 @@ public class CompletionSuggestion {
this.docComplete = docComplete;
this.declaringType = declaringType;
this.defaultArgumentListString = defaultArgumentListString;
this.defaultArgumentListTextRanges = defaultArgumentListTextRanges;
this.element = element;
this.returnType = returnType;
this.parameterNames = parameterNames;
@ -201,6 +211,7 @@ public class CompletionSuggestion {
ObjectUtilities.equals(other.docComplete, docComplete) &&
ObjectUtilities.equals(other.declaringType, declaringType) &&
ObjectUtilities.equals(other.defaultArgumentListString, defaultArgumentListString) &&
Arrays.equals(other.defaultArgumentListTextRanges, defaultArgumentListTextRanges) &&
ObjectUtilities.equals(other.element, element) &&
ObjectUtilities.equals(other.returnType, returnType) &&
ObjectUtilities.equals(other.parameterNames, parameterNames) &&
@ -226,6 +237,7 @@ public class CompletionSuggestion {
String docComplete = jsonObject.get("docComplete") == null ? null : jsonObject.get("docComplete").getAsString();
String declaringType = jsonObject.get("declaringType") == null ? null : jsonObject.get("declaringType").getAsString();
String defaultArgumentListString = jsonObject.get("defaultArgumentListString") == null ? null : jsonObject.get("defaultArgumentListString").getAsString();
int[] defaultArgumentListTextRanges = jsonObject.get("defaultArgumentListTextRanges") == null ? null : JsonUtilities.decodeIntArray(jsonObject.get("defaultArgumentListTextRanges").getAsJsonArray());
Element element = jsonObject.get("element") == null ? null : Element.fromJson(jsonObject.get("element").getAsJsonObject());
String returnType = jsonObject.get("returnType") == null ? null : jsonObject.get("returnType").getAsString();
List<String> parameterNames = jsonObject.get("parameterNames") == null ? null : JsonUtilities.decodeStringList(jsonObject.get("parameterNames").getAsJsonArray());
@ -235,7 +247,7 @@ public class CompletionSuggestion {
String parameterName = jsonObject.get("parameterName") == null ? null : jsonObject.get("parameterName").getAsString();
String parameterType = jsonObject.get("parameterType") == null ? null : jsonObject.get("parameterType").getAsString();
String importUri = jsonObject.get("importUri") == null ? null : jsonObject.get("importUri").getAsString();
return new CompletionSuggestion(kind, relevance, completion, selectionOffset, selectionLength, isDeprecated, isPotential, docSummary, docComplete, declaringType, defaultArgumentListString, element, returnType, parameterNames, parameterTypes, requiredParameterCount, hasNamedParameters, parameterName, parameterType, importUri);
return new CompletionSuggestion(kind, relevance, completion, selectionOffset, selectionLength, isDeprecated, isPotential, docSummary, docComplete, declaringType, defaultArgumentListString, defaultArgumentListTextRanges, element, returnType, parameterNames, parameterTypes, requiredParameterCount, hasNamedParameters, parameterName, parameterType, importUri);
}
public static List<CompletionSuggestion> fromJsonArray(JsonArray jsonArray) {
@ -274,6 +286,17 @@ public class CompletionSuggestion {
return defaultArgumentListString;
}
/**
* Pairs of offsets and lengths describing 'defaultArgumentListString' text ranges suitable for use
* by clients to set up linked edits of default argument source contents. For example, given an
* argument list string 'x, y', the corresponding text range [0, 1, 3, 1], indicates two text
* ranges of length 1, starting at offsets 0 and 3. Clients can use these ranges to treat the 'x'
* and 'y' values specially for linked edits.
*/
public int[] getDefaultArgumentListTextRanges() {
return defaultArgumentListTextRanges;
}
/**
* The Dartdoc associated with the element being suggested, This field is omitted if there is no
* Dartdoc associated with the element.
@ -419,6 +442,7 @@ public class CompletionSuggestion {
builder.append(docComplete);
builder.append(declaringType);
builder.append(defaultArgumentListString);
builder.append(defaultArgumentListTextRanges);
builder.append(element);
builder.append(returnType);
builder.append(parameterNames);
@ -452,6 +476,13 @@ public class CompletionSuggestion {
if (defaultArgumentListString != null) {
jsonObject.addProperty("defaultArgumentListString", defaultArgumentListString);
}
if (defaultArgumentListTextRanges != null) {
JsonArray jsonArrayDefaultArgumentListTextRanges = new JsonArray();
for (int elt : defaultArgumentListTextRanges) {
jsonArrayDefaultArgumentListTextRanges.add(new JsonPrimitive(elt));
}
jsonObject.add("defaultArgumentListTextRanges", jsonArrayDefaultArgumentListTextRanges);
}
if (element != null) {
jsonObject.add("element", element.toJson());
}
@ -516,6 +547,8 @@ public class CompletionSuggestion {
builder.append(declaringType + ", ");
builder.append("defaultArgumentListString=");
builder.append(defaultArgumentListString + ", ");
builder.append("defaultArgumentListTextRanges=");
builder.append(StringUtils.join(defaultArgumentListTextRanges, ", ") + ", ");
builder.append("element=");
builder.append(element + ", ");
builder.append("returnType=");

View file

@ -2439,6 +2439,18 @@
source contents on the client side.
</p>
</field>
<field name="defaultArgumentListTextRanges" optional="true">
<list><ref>int</ref></list>
<p>
Pairs of offsets and lengths describing 'defaultArgumentListString'
text ranges suitable for use by clients to set up linked edits of
default argument source contents. For example, given an argument
list string 'x, y', the corresponding text range [0, 1, 3, 1],
indicates two text ranges of length 1, starting at offsets 0 and 3.
Clients can use these ranges to treat the 'x' and 'y' values
specially for linked edits.
</p>
</field>
<field name="element" optional="true">
<ref>Element</ref>
<p>