Enhance available suggestions protocol.

1. Rename includedSuggestionKinds -> includedElementKinds.

2. Add defaultArgumentListString and defaultArgumentListTextRanges.

R=brianwilkerson@google.com

Change-Id: I65c67252f6bad66c0c60a20315fd87affbeb653a
Reviewed-on: https://dart-review.googlesource.com/c/93560
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
This commit is contained in:
Konstantin Shcheglov 2019-02-19 19:51:11 +00:00 committed by commit-bot@chromium.org
parent 28eb8604e3
commit 4c1025493a
14 changed files with 303 additions and 79 deletions

View file

@ -1498,7 +1498,7 @@ a:focus, a:hover {
"<b>results</b>": List&lt;<a href="#type_CompletionSuggestion">CompletionSuggestion</a>&gt;
"<b>isLast</b>": bool
"<b>includedSuggestionSets</b>": <span style="color:#999999">optional</span> List&lt;<a href="#type_IncludedSuggestionSet">IncludedSuggestionSet</a>&gt;
"<b>includedSuggestionKinds</b>": <span style="color:#999999">optional</span> List&lt;<a href="#type_ElementKind">ElementKind</a>&gt;
"<b>includedElementKinds</b>": <span style="color:#999999">optional</span> List&lt;<a href="#type_ElementKind">ElementKind</a>&gt;
"<b>includedSuggestionRelevanceTags</b>": <span style="color:#999999">optional</span> List&lt;<a href="#type_IncludedSuggestionRelevanceTag">IncludedSuggestionRelevanceTag</a>&gt;
}
}</pre></div>
@ -1558,7 +1558,7 @@ a:focus, a:hover {
to the client. The client can include applicable names from the
referenced library in code completion suggestions.
</p>
</dd><dt class="field"><b>includedSuggestionKinds: List&lt;<a href="#type_ElementKind">ElementKind</a>&gt;<span style="color:#999999"> (optional)</span></b></dt><dd>
</dd><dt class="field"><b>includedElementKinds: List&lt;<a href="#type_ElementKind">ElementKind</a>&gt;<span style="color:#999999"> (optional)</span></b></dt><dd>
<p>
This field is experimental.

View file

@ -118,8 +118,8 @@ const String COMPLETION_NOTIFICATION_AVAILABLE_SUGGESTIONS_REMOVED_LIBRARIES =
'removedLibraries';
const String COMPLETION_NOTIFICATION_RESULTS = 'completion.results';
const String COMPLETION_NOTIFICATION_RESULTS_ID = 'id';
const String COMPLETION_NOTIFICATION_RESULTS_INCLUDED_SUGGESTION_KINDS =
'includedSuggestionKinds';
const String COMPLETION_NOTIFICATION_RESULTS_INCLUDED_ELEMENT_KINDS =
'includedElementKinds';
const String
COMPLETION_NOTIFICATION_RESULTS_INCLUDED_SUGGESTION_RELEVANCE_TAGS =
'includedSuggestionRelevanceTags';

View file

@ -5076,6 +5076,8 @@ class AnalyticsSendTimingResult implements ResponseResult {
* {
* "label": String
* "element": Element
* "defaultArgumentListString": optional String
* "defaultArgumentListTextRanges": optional List<int>
* "docComplete": optional String
* "docSummary": optional String
* "parameterNames": optional List<String>
@ -5091,6 +5093,10 @@ class AvailableSuggestion implements HasToJson {
Element _element;
String _defaultArgumentListString;
List<int> _defaultArgumentListTextRanges;
String _docComplete;
String _docSummary;
@ -5129,6 +5135,42 @@ class AvailableSuggestion implements HasToJson {
this._element = value;
}
/**
* A default String for use in generating argument list source contents on
* the client side.
*/
String get defaultArgumentListString => _defaultArgumentListString;
/**
* A default String for use in generating argument list source contents on
* the client side.
*/
void set defaultArgumentListString(String value) {
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;
}
/**
* The Dartdoc associated with the element being suggested. This field is
* omitted if there is no Dartdoc associated with the element.
@ -5214,7 +5256,9 @@ class AvailableSuggestion implements HasToJson {
}
AvailableSuggestion(String label, Element element,
{String docComplete,
{String defaultArgumentListString,
List<int> defaultArgumentListTextRanges,
String docComplete,
String docSummary,
List<String> parameterNames,
List<String> parameterTypes,
@ -5222,6 +5266,8 @@ class AvailableSuggestion implements HasToJson {
int requiredParameterCount}) {
this.label = label;
this.element = element;
this.defaultArgumentListString = defaultArgumentListString;
this.defaultArgumentListTextRanges = defaultArgumentListTextRanges;
this.docComplete = docComplete;
this.docSummary = docSummary;
this.parameterNames = parameterNames;
@ -5249,6 +5295,19 @@ class AvailableSuggestion implements HasToJson {
} else {
throw jsonDecoder.mismatch(jsonPath, "element");
}
String defaultArgumentListString;
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);
}
String docComplete;
if (json.containsKey("docComplete")) {
docComplete = jsonDecoder.decodeString(
@ -5281,6 +5340,8 @@ class AvailableSuggestion implements HasToJson {
json["requiredParameterCount"]);
}
return new AvailableSuggestion(label, element,
defaultArgumentListString: defaultArgumentListString,
defaultArgumentListTextRanges: defaultArgumentListTextRanges,
docComplete: docComplete,
docSummary: docSummary,
parameterNames: parameterNames,
@ -5297,6 +5358,12 @@ class AvailableSuggestion implements HasToJson {
Map<String, dynamic> result = {};
result["label"] = label;
result["element"] = element.toJson();
if (defaultArgumentListString != null) {
result["defaultArgumentListString"] = defaultArgumentListString;
}
if (defaultArgumentListTextRanges != null) {
result["defaultArgumentListTextRanges"] = defaultArgumentListTextRanges;
}
if (docComplete != null) {
result["docComplete"] = docComplete;
}
@ -5326,6 +5393,9 @@ class AvailableSuggestion implements HasToJson {
if (other is AvailableSuggestion) {
return label == other.label &&
element == other.element &&
defaultArgumentListString == other.defaultArgumentListString &&
listEqual(defaultArgumentListTextRanges,
other.defaultArgumentListTextRanges, (int a, int b) => a == b) &&
docComplete == other.docComplete &&
docSummary == other.docSummary &&
listEqual(parameterNames, other.parameterNames,
@ -5344,6 +5414,8 @@ class AvailableSuggestion implements HasToJson {
int hash = 0;
hash = JenkinsSmiHash.combine(hash, label.hashCode);
hash = JenkinsSmiHash.combine(hash, element.hashCode);
hash = JenkinsSmiHash.combine(hash, defaultArgumentListString.hashCode);
hash = JenkinsSmiHash.combine(hash, defaultArgumentListTextRanges.hashCode);
hash = JenkinsSmiHash.combine(hash, docComplete.hashCode);
hash = JenkinsSmiHash.combine(hash, docSummary.hashCode);
hash = JenkinsSmiHash.combine(hash, parameterNames.hashCode);
@ -6344,7 +6416,7 @@ class CompletionRegisterLibraryPathsResult implements ResponseResult {
* "results": List<CompletionSuggestion>
* "isLast": bool
* "includedSuggestionSets": optional List<IncludedSuggestionSet>
* "includedSuggestionKinds": optional List<ElementKind>
* "includedElementKinds": optional List<ElementKind>
* "includedSuggestionRelevanceTags": optional List<IncludedSuggestionRelevanceTag>
* }
*
@ -6363,7 +6435,7 @@ class CompletionResultsParams implements HasToJson {
List<IncludedSuggestionSet> _includedSuggestionSets;
List<ElementKind> _includedSuggestionKinds;
List<ElementKind> _includedElementKinds;
List<IncludedSuggestionRelevanceTag> _includedSuggestionRelevanceTags;
@ -6480,7 +6552,7 @@ class CompletionResultsParams implements HasToJson {
* IncludedSuggestionSet to decide whether or not these symbols should should
* be presented to the user.
*/
List<ElementKind> get includedSuggestionKinds => _includedSuggestionKinds;
List<ElementKind> get includedElementKinds => _includedElementKinds;
/**
* This field is experimental.
@ -6489,8 +6561,8 @@ class CompletionResultsParams implements HasToJson {
* IncludedSuggestionSet to decide whether or not these symbols should should
* be presented to the user.
*/
void set includedSuggestionKinds(List<ElementKind> value) {
this._includedSuggestionKinds = value;
void set includedElementKinds(List<ElementKind> value) {
this._includedElementKinds = value;
}
/**
@ -6528,7 +6600,7 @@ class CompletionResultsParams implements HasToJson {
CompletionResultsParams(String id, int replacementOffset,
int replacementLength, List<CompletionSuggestion> results, bool isLast,
{List<IncludedSuggestionSet> includedSuggestionSets,
List<ElementKind> includedSuggestionKinds,
List<ElementKind> includedElementKinds,
List<IncludedSuggestionRelevanceTag> includedSuggestionRelevanceTags}) {
this.id = id;
this.replacementOffset = replacementOffset;
@ -6536,7 +6608,7 @@ class CompletionResultsParams implements HasToJson {
this.results = results;
this.isLast = isLast;
this.includedSuggestionSets = includedSuggestionSets;
this.includedSuggestionKinds = includedSuggestionKinds;
this.includedElementKinds = includedElementKinds;
this.includedSuggestionRelevanceTags = includedSuggestionRelevanceTags;
}
@ -6591,11 +6663,11 @@ class CompletionResultsParams implements HasToJson {
new IncludedSuggestionSet.fromJson(
jsonDecoder, jsonPath, json));
}
List<ElementKind> includedSuggestionKinds;
if (json.containsKey("includedSuggestionKinds")) {
includedSuggestionKinds = jsonDecoder.decodeList(
jsonPath + ".includedSuggestionKinds",
json["includedSuggestionKinds"],
List<ElementKind> includedElementKinds;
if (json.containsKey("includedElementKinds")) {
includedElementKinds = jsonDecoder.decodeList(
jsonPath + ".includedElementKinds",
json["includedElementKinds"],
(String jsonPath, Object json) =>
new ElementKind.fromJson(jsonDecoder, jsonPath, json));
}
@ -6611,7 +6683,7 @@ class CompletionResultsParams implements HasToJson {
return new CompletionResultsParams(
id, replacementOffset, replacementLength, results, isLast,
includedSuggestionSets: includedSuggestionSets,
includedSuggestionKinds: includedSuggestionKinds,
includedElementKinds: includedElementKinds,
includedSuggestionRelevanceTags: includedSuggestionRelevanceTags);
} else {
throw jsonDecoder.mismatch(jsonPath, "completion.results params", json);
@ -6637,8 +6709,8 @@ class CompletionResultsParams implements HasToJson {
.map((IncludedSuggestionSet value) => value.toJson())
.toList();
}
if (includedSuggestionKinds != null) {
result["includedSuggestionKinds"] = includedSuggestionKinds
if (includedElementKinds != null) {
result["includedElementKinds"] = includedElementKinds
.map((ElementKind value) => value.toJson())
.toList();
}
@ -6669,7 +6741,7 @@ class CompletionResultsParams implements HasToJson {
isLast == other.isLast &&
listEqual(includedSuggestionSets, other.includedSuggestionSets,
(IncludedSuggestionSet a, IncludedSuggestionSet b) => a == b) &&
listEqual(includedSuggestionKinds, other.includedSuggestionKinds,
listEqual(includedElementKinds, other.includedElementKinds,
(ElementKind a, ElementKind b) => a == b) &&
listEqual(
includedSuggestionRelevanceTags,
@ -6690,7 +6762,7 @@ class CompletionResultsParams implements HasToJson {
hash = JenkinsSmiHash.combine(hash, results.hashCode);
hash = JenkinsSmiHash.combine(hash, isLast.hashCode);
hash = JenkinsSmiHash.combine(hash, includedSuggestionSets.hashCode);
hash = JenkinsSmiHash.combine(hash, includedSuggestionKinds.hashCode);
hash = JenkinsSmiHash.combine(hash, includedElementKinds.hashCode);
hash =
JenkinsSmiHash.combine(hash, includedSuggestionRelevanceTags.hashCode);
return JenkinsSmiHash.finish(hash);

View file

@ -83,7 +83,7 @@ class CompletionDomainHandler extends AbstractRequestHandler {
Future<CompletionResult> computeSuggestions(
CompletionRequestImpl request,
CompletionGetSuggestionsParams params,
Set<ElementKind> includedSuggestionKinds,
Set<ElementKind> includedElementKinds,
List<IncludedSuggestionRelevanceTag> includedSuggestionRelevanceTags,
) async {
// TODO(brianwilkerson) Determine whether this await is necessary.
@ -110,7 +110,7 @@ class CompletionDomainHandler extends AbstractRequestHandler {
performance.logStartTime(COMPUTE_SUGGESTIONS_TAG);
var manager = new DartCompletionManager(
includedSuggestionKinds: includedSuggestionKinds,
includedElementKinds: includedElementKinds,
includedSuggestionRelevanceTags: includedSuggestionRelevanceTags,
);
@ -318,10 +318,10 @@ class CompletionDomainHandler extends AbstractRequestHandler {
// If the client opted into using available suggestion sets,
// create the kinds set, so signal the completion manager about opt-in.
Set<ElementKind> includedSuggestionKinds;
Set<ElementKind> includedElementKinds;
List<IncludedSuggestionRelevanceTag> includedSuggestionRelevanceTags;
if (_subscriptions.contains(CompletionService.AVAILABLE_SUGGESTION_SETS)) {
includedSuggestionKinds = Set<ElementKind>();
includedElementKinds = Set<ElementKind>();
includedSuggestionRelevanceTags = <IncludedSuggestionRelevanceTag>[];
}
@ -329,11 +329,11 @@ class CompletionDomainHandler extends AbstractRequestHandler {
computeSuggestions(
completionRequest,
params,
includedSuggestionKinds,
includedElementKinds,
includedSuggestionRelevanceTags,
).then((CompletionResult result) {
List<IncludedSuggestionSet> includedSuggestionSets;
if (includedSuggestionKinds != null && resolvedUnit != null) {
if (includedElementKinds != null && resolvedUnit != null) {
includedSuggestionSets = computeIncludedSetList(
server.declarationsTracker,
resolvedUnit,
@ -350,7 +350,7 @@ class CompletionDomainHandler extends AbstractRequestHandler {
result.replacementLength,
result.suggestions,
includedSuggestionSets,
includedSuggestionKinds?.toList(),
includedElementKinds?.toList(),
includedSuggestionRelevanceTags,
);
performance.logElapseTime(SEND_NOTIFICATION_TAG);
@ -388,7 +388,7 @@ class CompletionDomainHandler extends AbstractRequestHandler {
int replacementLength,
Iterable<CompletionSuggestion> results,
List<IncludedSuggestionSet> includedSuggestionSets,
List<ElementKind> includedSuggestionKinds,
List<ElementKind> includedElementKinds,
List<IncludedSuggestionRelevanceTag> includedSuggestionRelevanceTags,
) {
server.sendNotification(
@ -399,7 +399,7 @@ class CompletionDomainHandler extends AbstractRequestHandler {
results,
true,
includedSuggestionSets: includedSuggestionSets,
includedSuggestionKinds: includedSuggestionKinds,
includedElementKinds: includedElementKinds,
includedSuggestionRelevanceTags: includedSuggestionRelevanceTags,
).toNotification(),
);

View file

@ -60,15 +60,15 @@ class DartCompletionManager implements CompletionContributor {
/// fill this set with kinds of elements that are applicable at the
/// completion location, so should be suggested from available suggestion
/// sets.
final Set<protocol.ElementKind> includedSuggestionKinds;
final Set<protocol.ElementKind> includedElementKinds;
/// If [includedSuggestionKinds] is not null, must be also not `null`, and
/// If [includedElementKinds] is not null, must be also not `null`, and
/// will be filled with tags for suggestions that should be given higher
/// relevance than other included suggestions.
final List<IncludedSuggestionRelevanceTag> includedSuggestionRelevanceTags;
DartCompletionManager({
this.includedSuggestionKinds,
this.includedElementKinds,
this.includedSuggestionRelevanceTags,
});
@ -121,8 +121,8 @@ class DartCompletionManager implements CompletionContributor {
new VariableNameContributor()
];
if (includedSuggestionKinds != null) {
_addIncludedSuggestionKinds(dartRequest);
if (includedElementKinds != null) {
_addIncludedElementKinds(dartRequest);
_addIncludedSuggestionRelevanceTags(dartRequest);
} else {
contributors.add(new ImportedReferenceContributor());
@ -177,12 +177,12 @@ class DartCompletionManager implements CompletionContributor {
return suggestions;
}
void _addIncludedSuggestionKinds(DartCompletionRequestImpl request) {
void _addIncludedElementKinds(DartCompletionRequestImpl request) {
var opType = request.opType;
if (!opType.includeIdentifiers) return;
var kinds = includedSuggestionKinds;
var kinds = includedElementKinds;
if (kinds != null) {
if (opType.includeTypeNameSuggestions) {
kinds.add(protocol.ElementKind.CLASS);

View file

@ -1200,7 +1200,7 @@ abstract class IntegrationTestMixin {
* client. The client can include applicable names from the referenced
* library in code completion suggestions.
*
* includedSuggestionKinds: List<ElementKind> (optional)
* includedElementKinds: List<ElementKind> (optional)
*
* This field is experimental.
*

View file

@ -169,6 +169,8 @@ final Matcher isAnalysisStatus = new LazyMatcher(() => new MatchesJsonObject(
* {
* "label": String
* "element": Element
* "defaultArgumentListString": optional String
* "defaultArgumentListTextRanges": optional List<int>
* "docComplete": optional String
* "docSummary": optional String
* "parameterNames": optional List<String>
@ -182,6 +184,8 @@ final Matcher isAvailableSuggestion =
"label": isString,
"element": isElement
}, optionalFields: {
"defaultArgumentListString": isString,
"defaultArgumentListTextRanges": isListOf(isInt),
"docComplete": isString,
"docSummary": isString,
"parameterNames": isListOf(isString),
@ -2235,7 +2239,7 @@ final Matcher isCompletionRegisterLibraryPathsResult = isNull;
* "results": List<CompletionSuggestion>
* "isLast": bool
* "includedSuggestionSets": optional List<IncludedSuggestionSet>
* "includedSuggestionKinds": optional List<ElementKind>
* "includedElementKinds": optional List<ElementKind>
* "includedSuggestionRelevanceTags": optional List<IncludedSuggestionRelevanceTag>
* }
*/
@ -2248,7 +2252,7 @@ final Matcher isCompletionResultsParams =
"isLast": isBool
}, optionalFields: {
"includedSuggestionSets": isListOf(isIncludedSuggestionSet),
"includedSuggestionKinds": isListOf(isElementKind),
"includedElementKinds": isListOf(isElementKind),
"includedSuggestionRelevanceTags":
isListOf(isIncludedSuggestionRelevanceTag)
}));

View file

@ -22,14 +22,14 @@ class GetSuggestionAvailableTest extends AvailableSuggestionsBase {
var asyncSet = await waitForSetWithUri('dart:async');
var results = await _getSuggestions(testFile, 0);
expect(results.includedSuggestionKinds, isNotEmpty);
expect(results.includedElementKinds, isNotEmpty);
var includedIdSet = results.includedSuggestionSets.map((set) => set.id);
expect(includedIdSet, contains(mathSet.id));
expect(includedIdSet, contains(asyncSet.id));
}
test_includedSuggestionKinds_type() async {
test_includedElementKinds_type() async {
addTestFile(r'''
class X extends {} // ref
''');
@ -40,7 +40,7 @@ class X extends {} // ref
);
expect(
results.includedSuggestionKinds,
results.includedElementKinds,
unorderedEquals([
ElementKind.CLASS,
ElementKind.CLASS_TYPE_ALIAS,
@ -51,7 +51,7 @@ class X extends {} // ref
);
}
test_includedSuggestionKinds_value() async {
test_includedElementKinds_value() async {
addTestFile(r'''
main() {
print(); // ref
@ -64,7 +64,7 @@ main() {
);
expect(
results.includedSuggestionKinds,
results.includedElementKinds,
unorderedEquals([
ElementKind.CLASS,
ElementKind.CLASS_TYPE_ALIAS,

View file

@ -51,6 +51,7 @@ class CodegenJavaVisitor extends HierarchicalApiVisitor with CodeGenerator {
static const Map<String, String> _typeRenames = const {
'bool': 'boolean',
'int': 'int',
'AvailableSuggestionRelevanceTag': 'String',
'ExecutionContextId': 'String',
'FilePath': 'String',
'DebugContextId': 'String',

View file

@ -46,6 +46,20 @@ public class AvailableSuggestion {
*/
private final Element element;
/**
* A default String for use in generating argument list source contents on the client side.
*/
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;
/**
* The Dartdoc associated with the element being suggested. This field is omitted if there is no
* Dartdoc associated with the element.
@ -75,16 +89,18 @@ public class AvailableSuggestion {
* This field is set if the relevance of this suggestion might be changed depending on where
* completion is requested.
*/
private final List<AvailableSuggestionRelevanceTag> relevanceTags;
private final List<String> relevanceTags;
private final Integer requiredParameterCount;
/**
* Constructor for {@link AvailableSuggestion}.
*/
public AvailableSuggestion(String label, Element element, String docComplete, String docSummary, List<String> parameterNames, List<String> parameterTypes, List<AvailableSuggestionRelevanceTag> relevanceTags, Integer requiredParameterCount) {
public AvailableSuggestion(String label, Element element, String defaultArgumentListString, int[] defaultArgumentListTextRanges, String docComplete, String docSummary, List<String> parameterNames, List<String> parameterTypes, List<String> relevanceTags, Integer requiredParameterCount) {
this.label = label;
this.element = element;
this.defaultArgumentListString = defaultArgumentListString;
this.defaultArgumentListTextRanges = defaultArgumentListTextRanges;
this.docComplete = docComplete;
this.docSummary = docSummary;
this.parameterNames = parameterNames;
@ -100,6 +116,8 @@ public class AvailableSuggestion {
return
ObjectUtilities.equals(other.label, label) &&
ObjectUtilities.equals(other.element, element) &&
ObjectUtilities.equals(other.defaultArgumentListString, defaultArgumentListString) &&
Arrays.equals(other.defaultArgumentListTextRanges, defaultArgumentListTextRanges) &&
ObjectUtilities.equals(other.docComplete, docComplete) &&
ObjectUtilities.equals(other.docSummary, docSummary) &&
ObjectUtilities.equals(other.parameterNames, parameterNames) &&
@ -113,13 +131,15 @@ public class AvailableSuggestion {
public static AvailableSuggestion fromJson(JsonObject jsonObject) {
String label = jsonObject.get("label").getAsString();
Element element = Element.fromJson(jsonObject.get("element").getAsJsonObject());
String defaultArgumentListString = jsonObject.get("defaultArgumentListString") == null ? null : jsonObject.get("defaultArgumentListString").getAsString();
int[] defaultArgumentListTextRanges = jsonObject.get("defaultArgumentListTextRanges") == null ? null : JsonUtilities.decodeIntArray(jsonObject.get("defaultArgumentListTextRanges").getAsJsonArray());
String docComplete = jsonObject.get("docComplete") == null ? null : jsonObject.get("docComplete").getAsString();
String docSummary = jsonObject.get("docSummary") == null ? null : jsonObject.get("docSummary").getAsString();
List<String> parameterNames = jsonObject.get("parameterNames") == null ? null : JsonUtilities.decodeStringList(jsonObject.get("parameterNames").getAsJsonArray());
List<String> parameterTypes = jsonObject.get("parameterTypes") == null ? null : JsonUtilities.decodeStringList(jsonObject.get("parameterTypes").getAsJsonArray());
List<AvailableSuggestionRelevanceTag> relevanceTags = jsonObject.get("relevanceTags") == null ? null : AvailableSuggestionRelevanceTag.fromJsonArray(jsonObject.get("relevanceTags").getAsJsonArray());
List<String> relevanceTags = jsonObject.get("relevanceTags") == null ? null : JsonUtilities.decodeStringList(jsonObject.get("relevanceTags").getAsJsonArray());
Integer requiredParameterCount = jsonObject.get("requiredParameterCount") == null ? null : jsonObject.get("requiredParameterCount").getAsInt();
return new AvailableSuggestion(label, element, docComplete, docSummary, parameterNames, parameterTypes, relevanceTags, requiredParameterCount);
return new AvailableSuggestion(label, element, defaultArgumentListString, defaultArgumentListTextRanges, docComplete, docSummary, parameterNames, parameterTypes, relevanceTags, requiredParameterCount);
}
public static List<AvailableSuggestion> fromJsonArray(JsonArray jsonArray) {
@ -134,6 +154,24 @@ public class AvailableSuggestion {
return list;
}
/**
* A default String for use in generating argument list source contents on the client side.
*/
public String getDefaultArgumentListString() {
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.
@ -185,7 +223,7 @@ public class AvailableSuggestion {
* This field is set if the relevance of this suggestion might be changed depending on where
* completion is requested.
*/
public List<AvailableSuggestionRelevanceTag> getRelevanceTags() {
public List<String> getRelevanceTags() {
return relevanceTags;
}
@ -198,6 +236,8 @@ public class AvailableSuggestion {
HashCodeBuilder builder = new HashCodeBuilder();
builder.append(label);
builder.append(element);
builder.append(defaultArgumentListString);
builder.append(defaultArgumentListTextRanges);
builder.append(docComplete);
builder.append(docSummary);
builder.append(parameterNames);
@ -211,6 +251,16 @@ public class AvailableSuggestion {
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty("label", label);
jsonObject.add("element", element.toJson());
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 (docComplete != null) {
jsonObject.addProperty("docComplete", docComplete);
}
@ -233,8 +283,8 @@ public class AvailableSuggestion {
}
if (relevanceTags != null) {
JsonArray jsonArrayRelevanceTags = new JsonArray();
for (AvailableSuggestionRelevanceTag elt : relevanceTags) {
jsonArrayRelevanceTags.add(elt.toJson());
for (String elt : relevanceTags) {
jsonArrayRelevanceTags.add(new JsonPrimitive(elt));
}
jsonObject.add("relevanceTags", jsonArrayRelevanceTags);
}
@ -252,6 +302,10 @@ public class AvailableSuggestion {
builder.append(label + ", ");
builder.append("element=");
builder.append(element + ", ");
builder.append("defaultArgumentListString=");
builder.append(defaultArgumentListString + ", ");
builder.append("defaultArgumentListTextRanges=");
builder.append(StringUtils.join(defaultArgumentListTextRanges, ", ") + ", ");
builder.append("docComplete=");
builder.append(docComplete + ", ");
builder.append("docSummary=");

View file

@ -40,7 +40,7 @@ public class IncludedSuggestionRelevanceTag {
/**
* The opaque value of the tag.
*/
private final AvailableSuggestionRelevanceTag tag;
private final String tag;
/**
* The boost to the relevance of the completion suggestions that match this tag, which is added to
@ -51,7 +51,7 @@ public class IncludedSuggestionRelevanceTag {
/**
* Constructor for {@link IncludedSuggestionRelevanceTag}.
*/
public IncludedSuggestionRelevanceTag(AvailableSuggestionRelevanceTag tag, int relevanceBoost) {
public IncludedSuggestionRelevanceTag(String tag, int relevanceBoost) {
this.tag = tag;
this.relevanceBoost = relevanceBoost;
}
@ -68,7 +68,7 @@ public class IncludedSuggestionRelevanceTag {
}
public static IncludedSuggestionRelevanceTag fromJson(JsonObject jsonObject) {
AvailableSuggestionRelevanceTag tag = AvailableSuggestionRelevanceTag.fromJson(jsonObject.get("tag").getAsJsonObject());
String tag = jsonObject.get("tag").getAsString();
int relevanceBoost = jsonObject.get("relevanceBoost").getAsInt();
return new IncludedSuggestionRelevanceTag(tag, relevanceBoost);
}
@ -96,7 +96,7 @@ public class IncludedSuggestionRelevanceTag {
/**
* The opaque value of the tag.
*/
public AvailableSuggestionRelevanceTag getTag() {
public String getTag() {
return tag;
}
@ -110,7 +110,7 @@ public class IncludedSuggestionRelevanceTag {
public JsonObject toJson() {
JsonObject jsonObject = new JsonObject();
jsonObject.add("tag", tag.toJson());
jsonObject.addProperty("tag", tag);
jsonObject.addProperty("relevanceBoost", relevanceBoost);
return jsonObject;
}

View file

@ -1575,7 +1575,7 @@
referenced library in code completion suggestions.
</p>
</field>
<field name="includedSuggestionKinds" optional="true">
<field name="includedElementKinds" optional="true">
<list>
<ref>ElementKind</ref>
</list>
@ -3544,6 +3544,27 @@
Information about the element reference being suggested.
</p>
</field>
<field name="defaultArgumentListString" optional="true">
<ref>String</ref>
<p>
A default String for use in generating argument list 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="docComplete" optional="true">
<ref>String</ref>
<p>

View file

@ -118,8 +118,8 @@ const String COMPLETION_NOTIFICATION_AVAILABLE_SUGGESTIONS_REMOVED_LIBRARIES =
'removedLibraries';
const String COMPLETION_NOTIFICATION_RESULTS = 'completion.results';
const String COMPLETION_NOTIFICATION_RESULTS_ID = 'id';
const String COMPLETION_NOTIFICATION_RESULTS_INCLUDED_SUGGESTION_KINDS =
'includedSuggestionKinds';
const String COMPLETION_NOTIFICATION_RESULTS_INCLUDED_ELEMENT_KINDS =
'includedElementKinds';
const String
COMPLETION_NOTIFICATION_RESULTS_INCLUDED_SUGGESTION_RELEVANCE_TAGS =
'includedSuggestionRelevanceTags';

View file

@ -5076,6 +5076,8 @@ class AnalyticsSendTimingResult implements ResponseResult {
* {
* "label": String
* "element": Element
* "defaultArgumentListString": optional String
* "defaultArgumentListTextRanges": optional List<int>
* "docComplete": optional String
* "docSummary": optional String
* "parameterNames": optional List<String>
@ -5091,6 +5093,10 @@ class AvailableSuggestion implements HasToJson {
Element _element;
String _defaultArgumentListString;
List<int> _defaultArgumentListTextRanges;
String _docComplete;
String _docSummary;
@ -5129,6 +5135,42 @@ class AvailableSuggestion implements HasToJson {
this._element = value;
}
/**
* A default String for use in generating argument list source contents on
* the client side.
*/
String get defaultArgumentListString => _defaultArgumentListString;
/**
* A default String for use in generating argument list source contents on
* the client side.
*/
void set defaultArgumentListString(String value) {
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;
}
/**
* The Dartdoc associated with the element being suggested. This field is
* omitted if there is no Dartdoc associated with the element.
@ -5214,7 +5256,9 @@ class AvailableSuggestion implements HasToJson {
}
AvailableSuggestion(String label, Element element,
{String docComplete,
{String defaultArgumentListString,
List<int> defaultArgumentListTextRanges,
String docComplete,
String docSummary,
List<String> parameterNames,
List<String> parameterTypes,
@ -5222,6 +5266,8 @@ class AvailableSuggestion implements HasToJson {
int requiredParameterCount}) {
this.label = label;
this.element = element;
this.defaultArgumentListString = defaultArgumentListString;
this.defaultArgumentListTextRanges = defaultArgumentListTextRanges;
this.docComplete = docComplete;
this.docSummary = docSummary;
this.parameterNames = parameterNames;
@ -5249,6 +5295,19 @@ class AvailableSuggestion implements HasToJson {
} else {
throw jsonDecoder.mismatch(jsonPath, "element");
}
String defaultArgumentListString;
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);
}
String docComplete;
if (json.containsKey("docComplete")) {
docComplete = jsonDecoder.decodeString(
@ -5281,6 +5340,8 @@ class AvailableSuggestion implements HasToJson {
json["requiredParameterCount"]);
}
return new AvailableSuggestion(label, element,
defaultArgumentListString: defaultArgumentListString,
defaultArgumentListTextRanges: defaultArgumentListTextRanges,
docComplete: docComplete,
docSummary: docSummary,
parameterNames: parameterNames,
@ -5297,6 +5358,12 @@ class AvailableSuggestion implements HasToJson {
Map<String, dynamic> result = {};
result["label"] = label;
result["element"] = element.toJson();
if (defaultArgumentListString != null) {
result["defaultArgumentListString"] = defaultArgumentListString;
}
if (defaultArgumentListTextRanges != null) {
result["defaultArgumentListTextRanges"] = defaultArgumentListTextRanges;
}
if (docComplete != null) {
result["docComplete"] = docComplete;
}
@ -5326,6 +5393,9 @@ class AvailableSuggestion implements HasToJson {
if (other is AvailableSuggestion) {
return label == other.label &&
element == other.element &&
defaultArgumentListString == other.defaultArgumentListString &&
listEqual(defaultArgumentListTextRanges,
other.defaultArgumentListTextRanges, (int a, int b) => a == b) &&
docComplete == other.docComplete &&
docSummary == other.docSummary &&
listEqual(parameterNames, other.parameterNames,
@ -5344,6 +5414,8 @@ class AvailableSuggestion implements HasToJson {
int hash = 0;
hash = JenkinsSmiHash.combine(hash, label.hashCode);
hash = JenkinsSmiHash.combine(hash, element.hashCode);
hash = JenkinsSmiHash.combine(hash, defaultArgumentListString.hashCode);
hash = JenkinsSmiHash.combine(hash, defaultArgumentListTextRanges.hashCode);
hash = JenkinsSmiHash.combine(hash, docComplete.hashCode);
hash = JenkinsSmiHash.combine(hash, docSummary.hashCode);
hash = JenkinsSmiHash.combine(hash, parameterNames.hashCode);
@ -6344,7 +6416,7 @@ class CompletionRegisterLibraryPathsResult implements ResponseResult {
* "results": List<CompletionSuggestion>
* "isLast": bool
* "includedSuggestionSets": optional List<IncludedSuggestionSet>
* "includedSuggestionKinds": optional List<ElementKind>
* "includedElementKinds": optional List<ElementKind>
* "includedSuggestionRelevanceTags": optional List<IncludedSuggestionRelevanceTag>
* }
*
@ -6363,7 +6435,7 @@ class CompletionResultsParams implements HasToJson {
List<IncludedSuggestionSet> _includedSuggestionSets;
List<ElementKind> _includedSuggestionKinds;
List<ElementKind> _includedElementKinds;
List<IncludedSuggestionRelevanceTag> _includedSuggestionRelevanceTags;
@ -6480,7 +6552,7 @@ class CompletionResultsParams implements HasToJson {
* IncludedSuggestionSet to decide whether or not these symbols should should
* be presented to the user.
*/
List<ElementKind> get includedSuggestionKinds => _includedSuggestionKinds;
List<ElementKind> get includedElementKinds => _includedElementKinds;
/**
* This field is experimental.
@ -6489,8 +6561,8 @@ class CompletionResultsParams implements HasToJson {
* IncludedSuggestionSet to decide whether or not these symbols should should
* be presented to the user.
*/
void set includedSuggestionKinds(List<ElementKind> value) {
this._includedSuggestionKinds = value;
void set includedElementKinds(List<ElementKind> value) {
this._includedElementKinds = value;
}
/**
@ -6528,7 +6600,7 @@ class CompletionResultsParams implements HasToJson {
CompletionResultsParams(String id, int replacementOffset,
int replacementLength, List<CompletionSuggestion> results, bool isLast,
{List<IncludedSuggestionSet> includedSuggestionSets,
List<ElementKind> includedSuggestionKinds,
List<ElementKind> includedElementKinds,
List<IncludedSuggestionRelevanceTag> includedSuggestionRelevanceTags}) {
this.id = id;
this.replacementOffset = replacementOffset;
@ -6536,7 +6608,7 @@ class CompletionResultsParams implements HasToJson {
this.results = results;
this.isLast = isLast;
this.includedSuggestionSets = includedSuggestionSets;
this.includedSuggestionKinds = includedSuggestionKinds;
this.includedElementKinds = includedElementKinds;
this.includedSuggestionRelevanceTags = includedSuggestionRelevanceTags;
}
@ -6591,11 +6663,11 @@ class CompletionResultsParams implements HasToJson {
new IncludedSuggestionSet.fromJson(
jsonDecoder, jsonPath, json));
}
List<ElementKind> includedSuggestionKinds;
if (json.containsKey("includedSuggestionKinds")) {
includedSuggestionKinds = jsonDecoder.decodeList(
jsonPath + ".includedSuggestionKinds",
json["includedSuggestionKinds"],
List<ElementKind> includedElementKinds;
if (json.containsKey("includedElementKinds")) {
includedElementKinds = jsonDecoder.decodeList(
jsonPath + ".includedElementKinds",
json["includedElementKinds"],
(String jsonPath, Object json) =>
new ElementKind.fromJson(jsonDecoder, jsonPath, json));
}
@ -6611,7 +6683,7 @@ class CompletionResultsParams implements HasToJson {
return new CompletionResultsParams(
id, replacementOffset, replacementLength, results, isLast,
includedSuggestionSets: includedSuggestionSets,
includedSuggestionKinds: includedSuggestionKinds,
includedElementKinds: includedElementKinds,
includedSuggestionRelevanceTags: includedSuggestionRelevanceTags);
} else {
throw jsonDecoder.mismatch(jsonPath, "completion.results params", json);
@ -6637,8 +6709,8 @@ class CompletionResultsParams implements HasToJson {
.map((IncludedSuggestionSet value) => value.toJson())
.toList();
}
if (includedSuggestionKinds != null) {
result["includedSuggestionKinds"] = includedSuggestionKinds
if (includedElementKinds != null) {
result["includedElementKinds"] = includedElementKinds
.map((ElementKind value) => value.toJson())
.toList();
}
@ -6669,7 +6741,7 @@ class CompletionResultsParams implements HasToJson {
isLast == other.isLast &&
listEqual(includedSuggestionSets, other.includedSuggestionSets,
(IncludedSuggestionSet a, IncludedSuggestionSet b) => a == b) &&
listEqual(includedSuggestionKinds, other.includedSuggestionKinds,
listEqual(includedElementKinds, other.includedElementKinds,
(ElementKind a, ElementKind b) => a == b) &&
listEqual(
includedSuggestionRelevanceTags,
@ -6690,7 +6762,7 @@ class CompletionResultsParams implements HasToJson {
hash = JenkinsSmiHash.combine(hash, results.hashCode);
hash = JenkinsSmiHash.combine(hash, isLast.hashCode);
hash = JenkinsSmiHash.combine(hash, includedSuggestionSets.hashCode);
hash = JenkinsSmiHash.combine(hash, includedSuggestionKinds.hashCode);
hash = JenkinsSmiHash.combine(hash, includedElementKinds.hashCode);
hash =
JenkinsSmiHash.combine(hash, includedSuggestionRelevanceTags.hashCode);
return JenkinsSmiHash.finish(hash);