Skip to content

Commit a2f887e

Browse files
jwrenCommit Bot
authored and
Commit Bot
committed
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 <[email protected]> Reviewed-by: Brian Wilkerson <[email protected]> Commit-Queue: Jaime Wren <[email protected]>
1 parent 201557f commit a2f887e

File tree

10 files changed

+299
-15
lines changed

10 files changed

+299
-15
lines changed

pkg/analysis_server/doc/api.html

Lines changed: 23 additions & 1 deletion
Large diffs are not rendered by default.

pkg/analysis_server/lib/protocol/protocol_constants.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,8 @@ const String COMPLETION_NOTIFICATION_RESULTS_REPLACEMENT_OFFSET =
138138
const String COMPLETION_NOTIFICATION_RESULTS_RESULTS = 'results';
139139
const String COMPLETION_REQUEST_GET_SUGGESTIONS = 'completion.getSuggestions';
140140
const String COMPLETION_REQUEST_GET_SUGGESTIONS2 = 'completion.getSuggestions2';
141+
const String COMPLETION_REQUEST_GET_SUGGESTIONS2_COMPLETION_CASE_MATCHING_MODE =
142+
'completionCaseMatchingMode';
141143
const String COMPLETION_REQUEST_GET_SUGGESTIONS2_COMPLETION_MODE =
142144
'completionMode';
143145
const String COMPLETION_REQUEST_GET_SUGGESTIONS2_FILE = 'file';

pkg/analysis_server/lib/protocol/protocol_generated.dart

Lines changed: 86 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4215,6 +4215,68 @@ class CompletionAvailableSuggestionsParams implements HasToJson {
42154215
);
42164216
}
42174217

4218+
/// CompletionCaseMatchingMode
4219+
///
4220+
/// enum {
4221+
/// FIRST_CHAR
4222+
/// ALL_CHARS
4223+
/// NONE
4224+
/// }
4225+
///
4226+
/// Clients may not extend, implement or mix-in this class.
4227+
class CompletionCaseMatchingMode implements Enum {
4228+
/// Match the first character case only when filtering completions, the
4229+
/// default for this enumeration.
4230+
static const CompletionCaseMatchingMode FIRST_CHAR =
4231+
CompletionCaseMatchingMode._('FIRST_CHAR');
4232+
4233+
/// Match all character cases when filtering completion lists.
4234+
static const CompletionCaseMatchingMode ALL_CHARS =
4235+
CompletionCaseMatchingMode._('ALL_CHARS');
4236+
4237+
/// Do not match character cases when filtering completion lists.
4238+
static const CompletionCaseMatchingMode NONE =
4239+
CompletionCaseMatchingMode._('NONE');
4240+
4241+
/// A list containing all of the enum values that are defined.
4242+
static const List<CompletionCaseMatchingMode> VALUES =
4243+
<CompletionCaseMatchingMode>[FIRST_CHAR, ALL_CHARS, NONE];
4244+
4245+
@override
4246+
final String name;
4247+
4248+
const CompletionCaseMatchingMode._(this.name);
4249+
4250+
factory CompletionCaseMatchingMode(String name) {
4251+
switch (name) {
4252+
case 'FIRST_CHAR':
4253+
return FIRST_CHAR;
4254+
case 'ALL_CHARS':
4255+
return ALL_CHARS;
4256+
case 'NONE':
4257+
return NONE;
4258+
}
4259+
throw Exception('Illegal enum value: $name');
4260+
}
4261+
4262+
factory CompletionCaseMatchingMode.fromJson(
4263+
JsonDecoder jsonDecoder, String jsonPath, Object? json) {
4264+
if (json is String) {
4265+
try {
4266+
return CompletionCaseMatchingMode(json);
4267+
} catch (_) {
4268+
// Fall through
4269+
}
4270+
}
4271+
throw jsonDecoder.mismatch(jsonPath, 'CompletionCaseMatchingMode', json);
4272+
}
4273+
4274+
@override
4275+
String toString() => 'CompletionCaseMatchingMode.$name';
4276+
4277+
String toJson() => name;
4278+
}
4279+
42184280
/// completion.existingImports params
42194281
///
42204282
/// {
@@ -4683,6 +4745,7 @@ class CompletionGetSuggestionDetailsResult implements ResponseResult {
46834745
/// "file": FilePath
46844746
/// "offset": int
46854747
/// "maxResults": int
4748+
/// "completionCaseMatchingMode": optional CompletionCaseMatchingMode
46864749
/// }
46874750
///
46884751
/// Clients may not extend, implement or mix-in this class.
@@ -4698,6 +4761,10 @@ class CompletionGetSuggestions2Params implements RequestParams {
46984761
/// to true.
46994762
int maxResults;
47004763

4764+
/// The mode of code completion being invoked. If no value is provided,
4765+
/// MATCH_FIRST_CHAR will be assumed.
4766+
CompletionCaseMatchingMode? completionCaseMatchingMode;
4767+
47014768
/// The mode of code completion being invoked. If no value is provided, BASIC
47024769
/// will be assumed. BASIC is also the only currently supported.
47034770
CompletionMode? completionMode;
@@ -4714,7 +4781,10 @@ class CompletionGetSuggestions2Params implements RequestParams {
47144781
int? timeout;
47154782

47164783
CompletionGetSuggestions2Params(this.file, this.offset, this.maxResults,
4717-
{this.completionMode, this.invocationCount, this.timeout});
4784+
{this.completionCaseMatchingMode,
4785+
this.completionMode,
4786+
this.invocationCount,
4787+
this.timeout});
47184788

47194789
factory CompletionGetSuggestions2Params.fromJson(
47204790
JsonDecoder jsonDecoder, String jsonPath, Object? json) {
@@ -4739,6 +4809,13 @@ class CompletionGetSuggestions2Params implements RequestParams {
47394809
} else {
47404810
throw jsonDecoder.mismatch(jsonPath, 'maxResults');
47414811
}
4812+
CompletionCaseMatchingMode? completionCaseMatchingMode;
4813+
if (json.containsKey('completionCaseMatchingMode')) {
4814+
completionCaseMatchingMode = CompletionCaseMatchingMode.fromJson(
4815+
jsonDecoder,
4816+
jsonPath + '.completionCaseMatchingMode',
4817+
json['completionCaseMatchingMode']);
4818+
}
47424819
CompletionMode? completionMode;
47434820
if (json.containsKey('completionMode')) {
47444821
completionMode = CompletionMode.fromJson(
@@ -4754,6 +4831,7 @@ class CompletionGetSuggestions2Params implements RequestParams {
47544831
timeout = jsonDecoder.decodeInt(jsonPath + '.timeout', json['timeout']);
47554832
}
47564833
return CompletionGetSuggestions2Params(file, offset, maxResults,
4834+
completionCaseMatchingMode: completionCaseMatchingMode,
47574835
completionMode: completionMode,
47584836
invocationCount: invocationCount,
47594837
timeout: timeout);
@@ -4774,6 +4852,11 @@ class CompletionGetSuggestions2Params implements RequestParams {
47744852
result['file'] = file;
47754853
result['offset'] = offset;
47764854
result['maxResults'] = maxResults;
4855+
var completionCaseMatchingMode = this.completionCaseMatchingMode;
4856+
if (completionCaseMatchingMode != null) {
4857+
result['completionCaseMatchingMode'] =
4858+
completionCaseMatchingMode.toJson();
4859+
}
47774860
var completionMode = this.completionMode;
47784861
if (completionMode != null) {
47794862
result['completionMode'] = completionMode.toJson();
@@ -4803,6 +4886,7 @@ class CompletionGetSuggestions2Params implements RequestParams {
48034886
return file == other.file &&
48044887
offset == other.offset &&
48054888
maxResults == other.maxResults &&
4889+
completionCaseMatchingMode == other.completionCaseMatchingMode &&
48064890
completionMode == other.completionMode &&
48074891
invocationCount == other.invocationCount &&
48084892
timeout == other.timeout;
@@ -4815,6 +4899,7 @@ class CompletionGetSuggestions2Params implements RequestParams {
48154899
file,
48164900
offset,
48174901
maxResults,
4902+
completionCaseMatchingMode,
48184903
completionMode,
48194904
invocationCount,
48204905
timeout,

pkg/analysis_server/test/integration/support/integration_test_methods.dart

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -993,6 +993,11 @@ abstract class IntegrationTestMixin {
993993
/// suggestions after filtering is greater than the maxResults, then
994994
/// isIncomplete is set to true.
995995
///
996+
/// completionCaseMatchingMode: CompletionCaseMatchingMode (optional)
997+
///
998+
/// The mode of code completion being invoked. If no value is provided,
999+
/// MATCH_FIRST_CHAR will be assumed.
1000+
///
9961001
/// Returns
9971002
///
9981003
/// replacementOffset: int
@@ -1029,10 +1034,12 @@ abstract class IntegrationTestMixin {
10291034
/// requested maxResults.
10301035
Future<CompletionGetSuggestions2Result> sendCompletionGetSuggestions2(
10311036
String file, int offset, int maxResults,
1032-
{CompletionMode? completionMode,
1037+
{CompletionCaseMatchingMode? completionCaseMatchingMode,
1038+
CompletionMode? completionMode,
10331039
int? invocationCount,
10341040
int? timeout}) async {
10351041
var params = CompletionGetSuggestions2Params(file, offset, maxResults,
1042+
completionCaseMatchingMode: completionCaseMatchingMode,
10361043
completionMode: completionMode,
10371044
invocationCount: invocationCount,
10381045
timeout: timeout)

pkg/analysis_server/test/integration/support/protocol_matchers.dart

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,16 @@ final Matcher isChangeContentOverlay = LazyMatcher(() => MatchesJsonObject(
230230
final Matcher isClosingLabel = LazyMatcher(() => MatchesJsonObject(
231231
'ClosingLabel', {'offset': isInt, 'length': isInt, 'label': isString}));
232232

233+
/// CompletionCaseMatchingMode
234+
///
235+
/// enum {
236+
/// FIRST_CHAR
237+
/// ALL_CHARS
238+
/// NONE
239+
/// }
240+
final Matcher isCompletionCaseMatchingMode = MatchesEnum(
241+
'CompletionCaseMatchingMode', ['FIRST_CHAR', 'ALL_CHARS', 'NONE']);
242+
233243
/// CompletionId
234244
///
235245
/// String
@@ -2148,17 +2158,19 @@ final Matcher isCompletionGetSuggestionDetailsResult = LazyMatcher(() =>
21482158
/// "file": FilePath
21492159
/// "offset": int
21502160
/// "maxResults": int
2161+
/// "completionCaseMatchingMode": optional CompletionCaseMatchingMode
21512162
/// }
2152-
final Matcher isCompletionGetSuggestions2Params = LazyMatcher(() =>
2153-
MatchesJsonObject('completion.getSuggestions2 params', {
2154-
'file': isFilePath,
2155-
'offset': isInt,
2156-
'maxResults': isInt
2157-
}, optionalFields: {
2158-
'completionMode': isCompletionMode,
2159-
'invocationCount': isInt,
2160-
'timeout': isInt
2161-
}));
2163+
final Matcher isCompletionGetSuggestions2Params =
2164+
LazyMatcher(() => MatchesJsonObject('completion.getSuggestions2 params', {
2165+
'file': isFilePath,
2166+
'offset': isInt,
2167+
'maxResults': isInt
2168+
}, optionalFields: {
2169+
'completionCaseMatchingMode': isCompletionCaseMatchingMode,
2170+
'completionMode': isCompletionMode,
2171+
'invocationCount': isInt,
2172+
'timeout': isInt
2173+
}));
21622174

21632175
/// completion.getSuggestions2 result
21642176
///

pkg/analysis_server/tool/spec/generated/java/AnalysisServer.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,8 @@ public interface AnalysisServer {
440440
* @param offset The offset within the file at which suggestions are to be made.
441441
* @param maxResults The maximum number of suggestions to return. If the number of suggestions
442442
* after filtering is greater than the maxResults, then isIncomplete is set to true.
443+
* @param completionCaseMatchingMode The mode of code completion being invoked. If no value is
444+
* provided, MATCH_FIRST_CHAR will be assumed.
443445
* @param completionMode The mode of code completion being invoked. If no value is provided, BASIC
444446
* will be assumed. BASIC is also the only currently supported.
445447
* @param invocationCount The number of times that the user has invoked code completion at the same
@@ -449,7 +451,7 @@ public interface AnalysisServer {
449451
* field is intended to be used for benchmarking, and usually should not be provided, so
450452
* that the default timeout is used.
451453
*/
452-
public void completion_getSuggestions2(String file, int offset, int maxResults, String completionMode, int invocationCount, int timeout, GetSuggestions2Consumer consumer);
454+
public void completion_getSuggestions2(String file, int offset, int maxResults, String completionCaseMatchingMode, String completionMode, int invocationCount, int timeout, GetSuggestions2Consumer consumer);
453455

454456
/**
455457
* {@code completion.registerLibraryPaths}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
* Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
3+
* for details. All rights reserved. Use of this source code is governed by a
4+
* BSD-style license that can be found in the LICENSE file.
5+
*
6+
* This file has been automatically generated. Please do not edit it manually.
7+
* To regenerate the file, use the script "pkg/analysis_server/tool/spec/generate_files".
8+
*/
9+
package org.dartlang.analysis.server.protocol;
10+
11+
/**
12+
* An enumeration of the character case matching modes that the user may set in the client.
13+
*
14+
* @coverage dart.server.generated.types
15+
*/
16+
public class CompletionCaseMatchingMode {
17+
18+
/**
19+
* Match the first character case only when filtering completions, the default for this
20+
* enumeration.
21+
*/
22+
public static final String FIRST_CHAR = "FIRST_CHAR";
23+
24+
/**
25+
* Match all character cases when filtering completion lists.
26+
*/
27+
public static final String ALL_CHARS = "ALL_CHARS";
28+
29+
/**
30+
* Do not match character cases when filtering completion lists.
31+
*/
32+
public static final String NONE = "NONE";
33+
34+
}

pkg/analysis_server/tool/spec/spec_input.html

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1507,6 +1507,13 @@ <h4>Options</h4>
15071507
then <tt>isIncomplete</tt> is set to <tt>true</tt>.
15081508
</p>
15091509
</field>
1510+
<field name="completionCaseMatchingMode" optional="true">
1511+
<ref>CompletionCaseMatchingMode</ref>
1512+
<p>
1513+
The mode of code completion being invoked. If no value is provided,
1514+
<tt>MATCH_FIRST_CHAR</tt> will be assumed.
1515+
</p>
1516+
</field>
15101517
<field name="completionMode" experimental="true" optional="true">
15111518
<ref>CompletionMode</ref>
15121519
<p>
@@ -4146,6 +4153,32 @@ <h2 class="domain"><a name="types">Types</a></h2>
41464153
</value>
41474154
</enum>
41484155
</type>
4156+
<type name="CompletionCaseMatchingMode">
4157+
<p>
4158+
An enumeration of the character case matching modes that the user may set in the client.
4159+
</p>
4160+
<enum>
4161+
<value>
4162+
<code>FIRST_CHAR</code>
4163+
<p>
4164+
Match the first character case only when filtering completions, the default for this
4165+
enumeration.
4166+
</p>
4167+
</value>
4168+
<value>
4169+
<code>ALL_CHARS</code>
4170+
<p>
4171+
Match all character cases when filtering completion lists.
4172+
</p>
4173+
</value>
4174+
<value>
4175+
<code>NONE</code>
4176+
<p>
4177+
Do not match character cases when filtering completion lists.
4178+
</p>
4179+
</value>
4180+
</enum>
4181+
</type>
41494182
<type name="RuntimeCompletionExpression">
41504183
<p>
41514184
An expression for which we want to know its runtime type.

pkg/analysis_server_client/lib/src/protocol/protocol_constants.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,8 @@ const String COMPLETION_NOTIFICATION_RESULTS_REPLACEMENT_OFFSET =
138138
const String COMPLETION_NOTIFICATION_RESULTS_RESULTS = 'results';
139139
const String COMPLETION_REQUEST_GET_SUGGESTIONS = 'completion.getSuggestions';
140140
const String COMPLETION_REQUEST_GET_SUGGESTIONS2 = 'completion.getSuggestions2';
141+
const String COMPLETION_REQUEST_GET_SUGGESTIONS2_COMPLETION_CASE_MATCHING_MODE =
142+
'completionCaseMatchingMode';
141143
const String COMPLETION_REQUEST_GET_SUGGESTIONS2_COMPLETION_MODE =
142144
'completionMode';
143145
const String COMPLETION_REQUEST_GET_SUGGESTIONS2_FILE = 'file';

0 commit comments

Comments
 (0)