Skip to content

Commit 2bd91e8

Browse files
DanTupCommit Queue
authored andcommitted
[analysis_server] Rename some LSP types to match upcoming LSP 3.18
In the upcoming LSP 3.18 spec, many types that were previously inline literal types with no names (that resulted in us auto-generating names) have been made real types with names. In order to reduce the size of the change when LSP 3.18 arrives, this change renames some of our existing types to match the new names that they will get with LSP 3.18. There are no functional changes here, I simple added the names to the rename list (removing any redundant values that were previously being renamed differently), regenerated the code, and then updated any remaining references (in non-generated code) to those types to match. Change-Id: Ic556ce6e52ba94a8d42099371be18288230cd5ef Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/389160 Reviewed-by: Samuel Rawlins <[email protected]> Reviewed-by: Brian Wilkerson <[email protected]> Commit-Queue: Samuel Rawlins <[email protected]>
1 parent 7e0834a commit 2bd91e8

25 files changed

+1442
-1392
lines changed

pkg/analysis_server/lib/src/lsp/constants.dart

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ const dartSignatureHelpTriggerCharacters = <String>['('];
4545
/// Characters to trigger formatting when format-on-type is enabled.
4646
const dartTypeFormattingCharacters = ['}', ';'];
4747

48-
/// A [TextDocumentFilterWithScheme] for Analysis Options files.
49-
final analysisOptionsFile = TextDocumentFilterWithScheme(
48+
/// A [TextDocumentFilterScheme] for Analysis Options files.
49+
final analysisOptionsFile = TextDocumentFilterScheme(
5050
language: 'yaml', scheme: 'file', pattern: '**/analysis_options.yaml');
5151

5252
/// A [ProgressToken] used for reporting progress while the server is analyzing.
@@ -73,14 +73,14 @@ final fileOperationRegistrationOptions = FileOperationRegistrationOptions(
7373
],
7474
);
7575

76-
/// A [TextDocumentFilterWithScheme] for Fix Data files.
77-
final fixDataFile = TextDocumentFilterWithScheme(
76+
/// A [TextDocumentFilterScheme] for Fix Data files.
77+
final fixDataFile = TextDocumentFilterScheme(
7878
language: 'yaml',
7979
scheme: 'file',
8080
pattern: '**/lib/{fix_data.yaml,fix_data/**.yaml}');
8181

82-
/// A [TextDocumentFilterWithScheme] for Pubspec files.
83-
final pubspecFile = TextDocumentFilterWithScheme(
82+
/// A [TextDocumentFilterScheme] for Pubspec files.
83+
final pubspecFile = TextDocumentFilterScheme(
8484
language: 'yaml', scheme: 'file', pattern: '**/pubspec.yaml');
8585

8686
/// IDs of client-provided commands that the server knows about.

pkg/analysis_server/lib/src/lsp/handlers/handler_completion.dart

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ class CompletionHandler
247247

248248
/// Computes all supported defaults for completion items based on
249249
/// [capabilities].
250-
CompletionListItemDefaults? _computeCompletionDefaults(
250+
CompletionItemDefaults? _computeCompletionDefaults(
251251
LspClientCapabilities capabilities,
252252
Range insertionRange,
253253
Range replacementRange,
@@ -258,7 +258,7 @@ class CompletionHandler
258258
return null;
259259
}
260260

261-
return CompletionListItemDefaults(
261+
return CompletionItemDefaults(
262262
insertTextMode:
263263
capabilities.completionDefaultTextMode ? InsertTextMode.asIs : null,
264264
editRange: _computeDefaultEditRange(
@@ -268,7 +268,7 @@ class CompletionHandler
268268

269269
/// Computes the default completion edit range based on [capabilities] and
270270
/// whether the insert/replacement ranges differ.
271-
Either2<CompletionItemEditRange, Range>? _computeDefaultEditRange(
271+
Either2<EditRangeWithInsertReplace, Range>? _computeDefaultEditRange(
272272
LspClientCapabilities capabilities,
273273
Range insertionRange,
274274
Range replacementRange,
@@ -279,10 +279,10 @@ class CompletionHandler
279279

280280
if (!capabilities.insertReplaceCompletionRanges ||
281281
insertionRange == replacementRange) {
282-
return Either2<CompletionItemEditRange, Range>.t2(replacementRange);
282+
return Either2<EditRangeWithInsertReplace, Range>.t2(replacementRange);
283283
} else {
284-
return Either2<CompletionItemEditRange, Range>.t1(
285-
CompletionItemEditRange(
284+
return Either2<EditRangeWithInsertReplace, Range>.t1(
285+
EditRangeWithInsertReplace(
286286
insert: insertionRange,
287287
replace: replacementRange,
288288
),
@@ -306,7 +306,7 @@ class CompletionHandler
306306
required int offset,
307307
required LineInfo lineInfo,
308308
required bool Function(String input) filter,
309-
CompletionListItemDefaults? defaults,
309+
CompletionItemDefaults? defaults,
310310
}) async {
311311
var request = DartSnippetRequest(
312312
unit: unit,
@@ -845,7 +845,7 @@ class CompletionRegistrations extends FeatureRegistration
845845
previewCommitCharacters ? dartCompletionCommitCharacters : null,
846846
resolveProvider: true,
847847
completionItem:
848-
CompletionOptionsCompletionItem(labelDetailsSupport: true),
848+
ServerCompletionItemOptions(labelDetailsSupport: true),
849849
),
850850
),
851851
(
@@ -862,7 +862,7 @@ class CompletionRegistrations extends FeatureRegistration
862862
///
863863
/// We use two dynamic registrations because for Dart we support trigger
864864
/// characters but for other kinds of files we do not.
865-
List<TextDocumentFilterWithScheme> get nonDartCompletionTypes {
865+
List<TextDocumentFilterScheme> get nonDartCompletionTypes {
866866
var pluginTypesExcludingDart =
867867
pluginTypes.where((filter) => filter.pattern != '**/*.dart');
868868

@@ -883,8 +883,7 @@ class CompletionRegistrations extends FeatureRegistration
883883
allCommitCharacters:
884884
previewCommitCharacters ? dartCompletionCommitCharacters : null,
885885
resolveProvider: true,
886-
completionItem:
887-
CompletionOptionsCompletionItem(labelDetailsSupport: true),
886+
completionItem: ServerCompletionItemOptions(labelDetailsSupport: true),
888887
);
889888

890889
@override
@@ -908,7 +907,7 @@ class _CompletionResults {
908907
/// Item defaults for completion items.
909908
///
910909
/// Defaults are only supported on Dart server items (not plugins).
911-
final CompletionListItemDefaults? defaults;
910+
final CompletionItemDefaults? defaults;
912911

913912
_CompletionResults({
914913
this.rankedItems = const [],

pkg/analysis_server/lib/src/lsp/handlers/handler_initialize.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ class InitializeMessageHandler
7474

7575
return success(InitializeResult(
7676
capabilities: capabilities,
77-
serverInfo: InitializeResultServerInfo(
77+
serverInfo: ServerInfo(
7878
name: 'Dart SDK LSP Analysis Server',
7979
version: sdkVersion,
8080
),

pkg/analysis_server/lib/src/lsp/handlers/handler_rename.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@ class PrepareRenameHandler extends LspMessageHandler<TextDocumentPositionParams,
8282
ServerErrorCodes.RenameNotValid, initStatus.problem!.message);
8383
}
8484

85-
return success(TextDocumentPrepareRenameResult.t1(PlaceholderAndRange(
85+
return success(
86+
TextDocumentPrepareRenameResult.t1(PrepareRenamePlaceholder(
8687
range: toRange(
8788
unit.lineInfo,
8889
// If the offset is set to -1 it means there is no location for the

pkg/analysis_server/lib/src/lsp/handlers/handler_semantic_tokens.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,8 @@ class SemanticTokensRegistrations extends FeatureRegistration
159159
ToJsonable? get options => SemanticTokensRegistrationOptions(
160160
documentSelector: fullySupportedTypes,
161161
legend: semanticTokenLegend.lspLegend,
162-
full: Either2<bool, SemanticTokensOptionsFull>.t2(
163-
SemanticTokensOptionsFull(delta: false),
162+
full: Either2<bool, SemanticTokensFullDelta>.t2(
163+
SemanticTokensFullDelta(delta: false),
164164
),
165165
range: Either2<bool, SemanticTokensOptionsRange>.t1(true),
166166
);
@@ -173,7 +173,7 @@ class SemanticTokensRegistrations extends FeatureRegistration
173173
StaticOptions get staticOptions => Either2.t1(
174174
SemanticTokensOptions(
175175
legend: semanticTokenLegend.lspLegend,
176-
full: Either2.t2(SemanticTokensOptionsFull(delta: false)),
176+
full: Either2.t2(SemanticTokensFullDelta(delta: false)),
177177
range: Either2.t1(true),
178178
),
179179
);

pkg/analysis_server/lib/src/lsp/handlers/handler_text_document_changes.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ class TextDocumentRegistrations extends FeatureRegistration
169169
@override
170170
bool get supportsDynamic => clientDynamic.textSync;
171171

172-
List<TextDocumentFilterWithScheme> get synchronisedTypes {
172+
List<TextDocumentFilterScheme> get synchronisedTypes {
173173
return {
174174
...fullySupportedTypes,
175175
pubspecFile,

pkg/analysis_server/lib/src/lsp/lsp_analysis_server.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class LspAnalysisServer extends AnalysisServer {
6161

6262
/// Information about the connected client. Will be null prior to
6363
/// initialization or if the client did not provide it.
64-
InitializeParamsClientInfo? _clientInfo;
64+
ClientInfo? _clientInfo;
6565

6666
/// Initialization options provided by the LSP client. Allows opting in/out of
6767
/// specific server functionality. Will be null prior to initialization.
@@ -213,7 +213,7 @@ class LspAnalysisServer extends AnalysisServer {
213213

214214
/// Information about the connected editor client. Will be `null` prior to
215215
/// initialization.
216-
InitializeParamsClientInfo? get clientInfo => _clientInfo;
216+
ClientInfo? get clientInfo => _clientInfo;
217217

218218
/// The name of the remote when the client is running using a remote workspace.
219219
///
@@ -407,7 +407,7 @@ class LspAnalysisServer extends AnalysisServer {
407407

408408
void handleClientConnection(
409409
ClientCapabilities capabilities,
410-
InitializeParamsClientInfo? clientInfo,
410+
ClientInfo? clientInfo,
411411
Object? initializationOptions,
412412
) {
413413
_clientCapabilities = LspClientCapabilities(capabilities);

pkg/analysis_server/lib/src/lsp/mapping.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -792,7 +792,7 @@ lsp.CompletionItem snippetToCompletionItem(
792792
LineInfo lineInfo,
793793
Position position,
794794
Snippet snippet,
795-
CompletionListItemDefaults? defaults,
795+
CompletionItemDefaults? defaults,
796796
) {
797797
assert(capabilities.completionSnippets);
798798

pkg/analysis_server/lib/src/lsp/registration/feature_registration.dart

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ abstract class FeatureRegistration {
5757
ClientDynamicRegistrations get clientDynamic => _context.clientDynamic;
5858

5959
/// A set of filters for the currently supported Dart files.
60-
List<TextDocumentFilterWithScheme> get dartFiles => _context.dartFilters;
60+
List<TextDocumentFilterScheme> get dartFiles => _context.dartFilters;
6161

6262
/// Gets all dynamic registrations for this feature.
6363
///
@@ -69,15 +69,15 @@ abstract class FeatureRegistration {
6969
/// File types like pubspec.yaml, analysis_options.yaml and fix_data files are
7070
/// not included here as their support is very limited and do not provide
7171
/// functionality in most handlers.
72-
List<TextDocumentFilterWithScheme> get fullySupportedTypes {
72+
List<TextDocumentFilterScheme> get fullySupportedTypes {
7373
return {
7474
...dartFiles,
7575
...pluginTypes,
7676
}.toList();
7777
}
7878

7979
/// Types of documents that loaded plugins are interested in.
80-
List<TextDocumentFilterWithScheme> get pluginTypes => _context.pluginTypes;
80+
List<TextDocumentFilterScheme> get pluginTypes => _context.pluginTypes;
8181

8282
/// Whether both the client, and this feature, support dynamic registration.
8383
bool get supportsDynamic;
@@ -191,7 +191,7 @@ class RegistrationContext {
191191
final ClientDynamicRegistrations clientDynamic;
192192

193193
/// Types of documents that loaded plugins are interested in.
194-
final List<TextDocumentFilterWithScheme> pluginTypes;
194+
final List<TextDocumentFilterScheme> pluginTypes;
195195

196196
/// The capabilities of the client.
197197
final LspClientCapabilities clientCapabilities;
@@ -200,7 +200,7 @@ class RegistrationContext {
200200
final LspClientConfiguration clientConfiguration;
201201

202202
/// Filters for all Dart files supported by the current server.
203-
final List<TextDocumentFilterWithScheme> dartFilters;
203+
final List<TextDocumentFilterScheme> dartFilters;
204204

205205
/// Custom schemes supported for Dart files by the current server.
206206
///

pkg/analysis_server/lib/src/lsp/server_capabilities_computer.dart

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ class ServerCapabilitiesComputer {
146146

147147
ServerCapabilitiesComputer(this._server);
148148

149-
List<TextDocumentFilterWithScheme> get pluginTypes => AnalysisServer
149+
List<TextDocumentFilterScheme> get pluginTypes => AnalysisServer
150150
.supportsPlugins
151151
? _server.pluginManager.plugins
152152
.expand(
@@ -156,9 +156,9 @@ class ServerCapabilitiesComputer {
156156
// interestingFiles. Prefix a `**/` so that the glob matches nested
157157
// folders as well.
158158
.map((glob) =>
159-
TextDocumentFilterWithScheme(scheme: 'file', pattern: '**/$glob'))
159+
TextDocumentFilterScheme(scheme: 'file', pattern: '**/$glob'))
160160
.toList()
161-
: <TextDocumentFilterWithScheme>[];
161+
: <TextDocumentFilterScheme>[];
162162

163163
ServerCapabilities computeServerCapabilities(
164164
LspClientCapabilities clientCapabilities,
@@ -194,7 +194,7 @@ class ServerCapabilitiesComputer {
194194
typeHierarchyProvider: features.typeHierarchy.staticRegistration,
195195
executeCommandProvider: features.executeCommand.staticRegistration,
196196
workspaceSymbolProvider: features.workspaceSymbol.staticRegistration,
197-
workspace: ServerCapabilitiesWorkspace(
197+
workspace: WorkspaceOptions(
198198
workspaceFolders: WorkspaceFoldersServerCapabilities(
199199
supported: true,
200200
changeNotifications: features.changeNotifications.staticRegistration,
@@ -336,7 +336,7 @@ class ServerCapabilitiesComputer {
336336
'file',
337337
..._server.uriConverter.supportedNonFileSchemes
338338
})
339-
TextDocumentFilterWithScheme(language: 'dart', scheme: scheme)
339+
TextDocumentFilterScheme(language: 'dart', scheme: scheme)
340340
],
341341
pluginTypes: pluginTypes,
342342
);

0 commit comments

Comments
 (0)