New optional enum input, CompletionCaseMatchingMode, in DAS getSuggestions2 request.

Change-Id: Ibddcd7db4f51266c29a104d2b46e93c29ddf5465
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/232422
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Jaime Wren <jwren@google.com>
This commit is contained in:
Jaime Wren 2022-02-15 00:15:00 +00:00 committed by Commit Bot
parent 201557fb1d
commit a2f887ea59
10 changed files with 299 additions and 15 deletions

File diff suppressed because one or more lines are too long

View file

@ -138,6 +138,8 @@ const String COMPLETION_NOTIFICATION_RESULTS_REPLACEMENT_OFFSET =
const String COMPLETION_NOTIFICATION_RESULTS_RESULTS = 'results';
const String COMPLETION_REQUEST_GET_SUGGESTIONS = 'completion.getSuggestions';
const String COMPLETION_REQUEST_GET_SUGGESTIONS2 = 'completion.getSuggestions2';
const String COMPLETION_REQUEST_GET_SUGGESTIONS2_COMPLETION_CASE_MATCHING_MODE =
'completionCaseMatchingMode';
const String COMPLETION_REQUEST_GET_SUGGESTIONS2_COMPLETION_MODE =
'completionMode';
const String COMPLETION_REQUEST_GET_SUGGESTIONS2_FILE = 'file';

View file

@ -4215,6 +4215,68 @@ class CompletionAvailableSuggestionsParams implements HasToJson {
);
}
/// CompletionCaseMatchingMode
///
/// enum {
/// FIRST_CHAR
/// ALL_CHARS
/// NONE
/// }
///
/// Clients may not extend, implement or mix-in this class.
class CompletionCaseMatchingMode implements Enum {
/// Match the first character case only when filtering completions, the
/// default for this enumeration.
static const CompletionCaseMatchingMode FIRST_CHAR =
CompletionCaseMatchingMode._('FIRST_CHAR');
/// Match all character cases when filtering completion lists.
static const CompletionCaseMatchingMode ALL_CHARS =
CompletionCaseMatchingMode._('ALL_CHARS');
/// Do not match character cases when filtering completion lists.
static const CompletionCaseMatchingMode NONE =
CompletionCaseMatchingMode._('NONE');
/// A list containing all of the enum values that are defined.
static const List<CompletionCaseMatchingMode> VALUES =
<CompletionCaseMatchingMode>[FIRST_CHAR, ALL_CHARS, NONE];
@override
final String name;
const CompletionCaseMatchingMode._(this.name);
factory CompletionCaseMatchingMode(String name) {
switch (name) {
case 'FIRST_CHAR':
return FIRST_CHAR;
case 'ALL_CHARS':
return ALL_CHARS;
case 'NONE':
return NONE;
}
throw Exception('Illegal enum value: $name');
}
factory CompletionCaseMatchingMode.fromJson(
JsonDecoder jsonDecoder, String jsonPath, Object? json) {
if (json is String) {
try {
return CompletionCaseMatchingMode(json);
} catch (_) {
// Fall through
}
}
throw jsonDecoder.mismatch(jsonPath, 'CompletionCaseMatchingMode', json);
}
@override
String toString() => 'CompletionCaseMatchingMode.$name';
String toJson() => name;
}
/// completion.existingImports params
///
/// {
@ -4683,6 +4745,7 @@ class CompletionGetSuggestionDetailsResult implements ResponseResult {
/// "file": FilePath
/// "offset": int
/// "maxResults": int
/// "completionCaseMatchingMode": optional CompletionCaseMatchingMode
/// }
///
/// Clients may not extend, implement or mix-in this class.
@ -4698,6 +4761,10 @@ class CompletionGetSuggestions2Params implements RequestParams {
/// to true.
int maxResults;
/// The mode of code completion being invoked. If no value is provided,
/// MATCH_FIRST_CHAR will be assumed.
CompletionCaseMatchingMode? completionCaseMatchingMode;
/// The mode of code completion being invoked. If no value is provided, BASIC
/// will be assumed. BASIC is also the only currently supported.
CompletionMode? completionMode;
@ -4714,7 +4781,10 @@ class CompletionGetSuggestions2Params implements RequestParams {
int? timeout;
CompletionGetSuggestions2Params(this.file, this.offset, this.maxResults,
{this.completionMode, this.invocationCount, this.timeout});
{this.completionCaseMatchingMode,
this.completionMode,
this.invocationCount,
this.timeout});
factory CompletionGetSuggestions2Params.fromJson(
JsonDecoder jsonDecoder, String jsonPath, Object? json) {
@ -4739,6 +4809,13 @@ class CompletionGetSuggestions2Params implements RequestParams {
} else {
throw jsonDecoder.mismatch(jsonPath, 'maxResults');
}
CompletionCaseMatchingMode? completionCaseMatchingMode;
if (json.containsKey('completionCaseMatchingMode')) {
completionCaseMatchingMode = CompletionCaseMatchingMode.fromJson(
jsonDecoder,
jsonPath + '.completionCaseMatchingMode',
json['completionCaseMatchingMode']);
}
CompletionMode? completionMode;
if (json.containsKey('completionMode')) {
completionMode = CompletionMode.fromJson(
@ -4754,6 +4831,7 @@ class CompletionGetSuggestions2Params implements RequestParams {
timeout = jsonDecoder.decodeInt(jsonPath + '.timeout', json['timeout']);
}
return CompletionGetSuggestions2Params(file, offset, maxResults,
completionCaseMatchingMode: completionCaseMatchingMode,
completionMode: completionMode,
invocationCount: invocationCount,
timeout: timeout);
@ -4774,6 +4852,11 @@ class CompletionGetSuggestions2Params implements RequestParams {
result['file'] = file;
result['offset'] = offset;
result['maxResults'] = maxResults;
var completionCaseMatchingMode = this.completionCaseMatchingMode;
if (completionCaseMatchingMode != null) {
result['completionCaseMatchingMode'] =
completionCaseMatchingMode.toJson();
}
var completionMode = this.completionMode;
if (completionMode != null) {
result['completionMode'] = completionMode.toJson();
@ -4803,6 +4886,7 @@ class CompletionGetSuggestions2Params implements RequestParams {
return file == other.file &&
offset == other.offset &&
maxResults == other.maxResults &&
completionCaseMatchingMode == other.completionCaseMatchingMode &&
completionMode == other.completionMode &&
invocationCount == other.invocationCount &&
timeout == other.timeout;
@ -4815,6 +4899,7 @@ class CompletionGetSuggestions2Params implements RequestParams {
file,
offset,
maxResults,
completionCaseMatchingMode,
completionMode,
invocationCount,
timeout,

View file

@ -993,6 +993,11 @@ abstract class IntegrationTestMixin {
/// suggestions after filtering is greater than the maxResults, then
/// isIncomplete is set to true.
///
/// completionCaseMatchingMode: CompletionCaseMatchingMode (optional)
///
/// The mode of code completion being invoked. If no value is provided,
/// MATCH_FIRST_CHAR will be assumed.
///
/// Returns
///
/// replacementOffset: int
@ -1029,10 +1034,12 @@ abstract class IntegrationTestMixin {
/// requested maxResults.
Future<CompletionGetSuggestions2Result> sendCompletionGetSuggestions2(
String file, int offset, int maxResults,
{CompletionMode? completionMode,
{CompletionCaseMatchingMode? completionCaseMatchingMode,
CompletionMode? completionMode,
int? invocationCount,
int? timeout}) async {
var params = CompletionGetSuggestions2Params(file, offset, maxResults,
completionCaseMatchingMode: completionCaseMatchingMode,
completionMode: completionMode,
invocationCount: invocationCount,
timeout: timeout)

View file

@ -230,6 +230,16 @@ final Matcher isChangeContentOverlay = LazyMatcher(() => MatchesJsonObject(
final Matcher isClosingLabel = LazyMatcher(() => MatchesJsonObject(
'ClosingLabel', {'offset': isInt, 'length': isInt, 'label': isString}));
/// CompletionCaseMatchingMode
///
/// enum {
/// FIRST_CHAR
/// ALL_CHARS
/// NONE
/// }
final Matcher isCompletionCaseMatchingMode = MatchesEnum(
'CompletionCaseMatchingMode', ['FIRST_CHAR', 'ALL_CHARS', 'NONE']);
/// CompletionId
///
/// String
@ -2148,17 +2158,19 @@ final Matcher isCompletionGetSuggestionDetailsResult = LazyMatcher(() =>
/// "file": FilePath
/// "offset": int
/// "maxResults": int
/// "completionCaseMatchingMode": optional CompletionCaseMatchingMode
/// }
final Matcher isCompletionGetSuggestions2Params = LazyMatcher(() =>
MatchesJsonObject('completion.getSuggestions2 params', {
'file': isFilePath,
'offset': isInt,
'maxResults': isInt
}, optionalFields: {
'completionMode': isCompletionMode,
'invocationCount': isInt,
'timeout': isInt
}));
final Matcher isCompletionGetSuggestions2Params =
LazyMatcher(() => MatchesJsonObject('completion.getSuggestions2 params', {
'file': isFilePath,
'offset': isInt,
'maxResults': isInt
}, optionalFields: {
'completionCaseMatchingMode': isCompletionCaseMatchingMode,
'completionMode': isCompletionMode,
'invocationCount': isInt,
'timeout': isInt
}));
/// completion.getSuggestions2 result
///

View file

@ -440,6 +440,8 @@ public interface AnalysisServer {
* @param offset The offset within the file at which suggestions are to be made.
* @param maxResults The maximum number of suggestions to return. If the number of suggestions
* after filtering is greater than the maxResults, then isIncomplete is set to true.
* @param completionCaseMatchingMode The mode of code completion being invoked. If no value is
* provided, MATCH_FIRST_CHAR will be assumed.
* @param completionMode The mode of code completion being invoked. If no value is provided, BASIC
* will be assumed. BASIC is also the only currently supported.
* @param invocationCount The number of times that the user has invoked code completion at the same
@ -449,7 +451,7 @@ public interface AnalysisServer {
* field is intended to be used for benchmarking, and usually should not be provided, so
* that the default timeout is used.
*/
public void completion_getSuggestions2(String file, int offset, int maxResults, String completionMode, int invocationCount, int timeout, GetSuggestions2Consumer consumer);
public void completion_getSuggestions2(String file, int offset, int maxResults, String completionCaseMatchingMode, String completionMode, int invocationCount, int timeout, GetSuggestions2Consumer consumer);
/**
* {@code completion.registerLibraryPaths}

View file

@ -0,0 +1,34 @@
/*
* Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
* for details. All rights reserved. Use of this source code is governed by a
* BSD-style license that can be found in the LICENSE file.
*
* This file has been automatically generated. Please do not edit it manually.
* To regenerate the file, use the script "pkg/analysis_server/tool/spec/generate_files".
*/
package org.dartlang.analysis.server.protocol;
/**
* An enumeration of the character case matching modes that the user may set in the client.
*
* @coverage dart.server.generated.types
*/
public class CompletionCaseMatchingMode {
/**
* Match the first character case only when filtering completions, the default for this
* enumeration.
*/
public static final String FIRST_CHAR = "FIRST_CHAR";
/**
* Match all character cases when filtering completion lists.
*/
public static final String ALL_CHARS = "ALL_CHARS";
/**
* Do not match character cases when filtering completion lists.
*/
public static final String NONE = "NONE";
}

View file

@ -1507,6 +1507,13 @@
then <tt>isIncomplete</tt> is set to <tt>true</tt>.
</p>
</field>
<field name="completionCaseMatchingMode" optional="true">
<ref>CompletionCaseMatchingMode</ref>
<p>
The mode of code completion being invoked. If no value is provided,
<tt>MATCH_FIRST_CHAR</tt> will be assumed.
</p>
</field>
<field name="completionMode" experimental="true" optional="true">
<ref>CompletionMode</ref>
<p>
@ -4146,6 +4153,32 @@
</value>
</enum>
</type>
<type name="CompletionCaseMatchingMode">
<p>
An enumeration of the character case matching modes that the user may set in the client.
</p>
<enum>
<value>
<code>FIRST_CHAR</code>
<p>
Match the first character case only when filtering completions, the default for this
enumeration.
</p>
</value>
<value>
<code>ALL_CHARS</code>
<p>
Match all character cases when filtering completion lists.
</p>
</value>
<value>
<code>NONE</code>
<p>
Do not match character cases when filtering completion lists.
</p>
</value>
</enum>
</type>
<type name="RuntimeCompletionExpression">
<p>
An expression for which we want to know its runtime type.

View file

@ -138,6 +138,8 @@ const String COMPLETION_NOTIFICATION_RESULTS_REPLACEMENT_OFFSET =
const String COMPLETION_NOTIFICATION_RESULTS_RESULTS = 'results';
const String COMPLETION_REQUEST_GET_SUGGESTIONS = 'completion.getSuggestions';
const String COMPLETION_REQUEST_GET_SUGGESTIONS2 = 'completion.getSuggestions2';
const String COMPLETION_REQUEST_GET_SUGGESTIONS2_COMPLETION_CASE_MATCHING_MODE =
'completionCaseMatchingMode';
const String COMPLETION_REQUEST_GET_SUGGESTIONS2_COMPLETION_MODE =
'completionMode';
const String COMPLETION_REQUEST_GET_SUGGESTIONS2_FILE = 'file';

View file

@ -4215,6 +4215,68 @@ class CompletionAvailableSuggestionsParams implements HasToJson {
);
}
/// CompletionCaseMatchingMode
///
/// enum {
/// FIRST_CHAR
/// ALL_CHARS
/// NONE
/// }
///
/// Clients may not extend, implement or mix-in this class.
class CompletionCaseMatchingMode implements Enum {
/// Match the first character case only when filtering completions, the
/// default for this enumeration.
static const CompletionCaseMatchingMode FIRST_CHAR =
CompletionCaseMatchingMode._('FIRST_CHAR');
/// Match all character cases when filtering completion lists.
static const CompletionCaseMatchingMode ALL_CHARS =
CompletionCaseMatchingMode._('ALL_CHARS');
/// Do not match character cases when filtering completion lists.
static const CompletionCaseMatchingMode NONE =
CompletionCaseMatchingMode._('NONE');
/// A list containing all of the enum values that are defined.
static const List<CompletionCaseMatchingMode> VALUES =
<CompletionCaseMatchingMode>[FIRST_CHAR, ALL_CHARS, NONE];
@override
final String name;
const CompletionCaseMatchingMode._(this.name);
factory CompletionCaseMatchingMode(String name) {
switch (name) {
case 'FIRST_CHAR':
return FIRST_CHAR;
case 'ALL_CHARS':
return ALL_CHARS;
case 'NONE':
return NONE;
}
throw Exception('Illegal enum value: $name');
}
factory CompletionCaseMatchingMode.fromJson(
JsonDecoder jsonDecoder, String jsonPath, Object? json) {
if (json is String) {
try {
return CompletionCaseMatchingMode(json);
} catch (_) {
// Fall through
}
}
throw jsonDecoder.mismatch(jsonPath, 'CompletionCaseMatchingMode', json);
}
@override
String toString() => 'CompletionCaseMatchingMode.$name';
String toJson() => name;
}
/// completion.existingImports params
///
/// {
@ -4683,6 +4745,7 @@ class CompletionGetSuggestionDetailsResult implements ResponseResult {
/// "file": FilePath
/// "offset": int
/// "maxResults": int
/// "completionCaseMatchingMode": optional CompletionCaseMatchingMode
/// }
///
/// Clients may not extend, implement or mix-in this class.
@ -4698,6 +4761,10 @@ class CompletionGetSuggestions2Params implements RequestParams {
/// to true.
int maxResults;
/// The mode of code completion being invoked. If no value is provided,
/// MATCH_FIRST_CHAR will be assumed.
CompletionCaseMatchingMode? completionCaseMatchingMode;
/// The mode of code completion being invoked. If no value is provided, BASIC
/// will be assumed. BASIC is also the only currently supported.
CompletionMode? completionMode;
@ -4714,7 +4781,10 @@ class CompletionGetSuggestions2Params implements RequestParams {
int? timeout;
CompletionGetSuggestions2Params(this.file, this.offset, this.maxResults,
{this.completionMode, this.invocationCount, this.timeout});
{this.completionCaseMatchingMode,
this.completionMode,
this.invocationCount,
this.timeout});
factory CompletionGetSuggestions2Params.fromJson(
JsonDecoder jsonDecoder, String jsonPath, Object? json) {
@ -4739,6 +4809,13 @@ class CompletionGetSuggestions2Params implements RequestParams {
} else {
throw jsonDecoder.mismatch(jsonPath, 'maxResults');
}
CompletionCaseMatchingMode? completionCaseMatchingMode;
if (json.containsKey('completionCaseMatchingMode')) {
completionCaseMatchingMode = CompletionCaseMatchingMode.fromJson(
jsonDecoder,
jsonPath + '.completionCaseMatchingMode',
json['completionCaseMatchingMode']);
}
CompletionMode? completionMode;
if (json.containsKey('completionMode')) {
completionMode = CompletionMode.fromJson(
@ -4754,6 +4831,7 @@ class CompletionGetSuggestions2Params implements RequestParams {
timeout = jsonDecoder.decodeInt(jsonPath + '.timeout', json['timeout']);
}
return CompletionGetSuggestions2Params(file, offset, maxResults,
completionCaseMatchingMode: completionCaseMatchingMode,
completionMode: completionMode,
invocationCount: invocationCount,
timeout: timeout);
@ -4774,6 +4852,11 @@ class CompletionGetSuggestions2Params implements RequestParams {
result['file'] = file;
result['offset'] = offset;
result['maxResults'] = maxResults;
var completionCaseMatchingMode = this.completionCaseMatchingMode;
if (completionCaseMatchingMode != null) {
result['completionCaseMatchingMode'] =
completionCaseMatchingMode.toJson();
}
var completionMode = this.completionMode;
if (completionMode != null) {
result['completionMode'] = completionMode.toJson();
@ -4803,6 +4886,7 @@ class CompletionGetSuggestions2Params implements RequestParams {
return file == other.file &&
offset == other.offset &&
maxResults == other.maxResults &&
completionCaseMatchingMode == other.completionCaseMatchingMode &&
completionMode == other.completionMode &&
invocationCount == other.invocationCount &&
timeout == other.timeout;
@ -4815,6 +4899,7 @@ class CompletionGetSuggestions2Params implements RequestParams {
file,
offset,
maxResults,
completionCaseMatchingMode,
completionMode,
invocationCount,
timeout,