@@ -35,6 +35,27 @@ class InitializationTest extends AbstractLspAnalysisServerTest {
35
35
await pumpEventQueue (times: 5000 );
36
36
}
37
37
38
+ Future <void > assertDynamicRegistration (
39
+ String name, Set <Method > expectedResult) async {
40
+ // Check that when the server calls client/registerCapability it only includes
41
+ // the items we advertised dynamic registration support for.
42
+ final registrations = < Registration > [];
43
+ await monitorDynamicRegistrations (
44
+ registrations,
45
+ () => initialize (
46
+ textDocumentCapabilities: withGivenTextDocumentDynamicRegistrations (
47
+ emptyTextDocumentClientCapabilities, name),
48
+ workspaceCapabilities: withGivenWorkspaceDynamicRegistrations (
49
+ emptyWorkspaceClientCapabilities, name)),
50
+ );
51
+
52
+ final registeredMethods =
53
+ registrations.map ((registration) => registration.method).toSet ();
54
+ final result = expectedResult.map ((method) => method.toJson ()).toSet ();
55
+
56
+ expect (registeredMethods, equals (result));
57
+ }
58
+
38
59
TextDocumentRegistrationOptions registrationOptionsFor (
39
60
List <Registration > registrations,
40
61
Method method,
@@ -243,6 +264,97 @@ class InitializationTest extends AbstractLspAnalysisServerTest {
243
264
await Future .wait ([registrationsDone, unregistrationsDone]);
244
265
}
245
266
267
+ Future <void > test_dynamicRegistration_config_allHierarchy () =>
268
+ assertDynamicRegistration (
269
+ 'callHierarchy' , {Method .textDocument_prepareCallHierarchy});
270
+
271
+ Future <void > test_dynamicRegistration_config_codeAction () =>
272
+ assertDynamicRegistration ('codeAction' , {Method .textDocument_codeAction});
273
+
274
+ Future <void > test_dynamicRegistration_config_colorProvider () =>
275
+ assertDynamicRegistration (
276
+ 'colorProvider' , {Method .textDocument_documentColor});
277
+
278
+ Future <void > test_dynamicRegistration_config_completion () =>
279
+ assertDynamicRegistration ('completion' , {Method .textDocument_completion});
280
+
281
+ Future <void > test_dynamicRegistration_config_definition () =>
282
+ assertDynamicRegistration ('definition' , {Method .textDocument_definition});
283
+
284
+ Future <void > test_dynamicRegistration_config_didChangeConfiguration () =>
285
+ assertDynamicRegistration (
286
+ 'didChangeConfiguration' , {Method .workspace_didChangeConfiguration});
287
+
288
+ Future <void > test_dynamicRegistration_config_documentHighlight () =>
289
+ assertDynamicRegistration (
290
+ 'documentHighlight' , {Method .textDocument_documentHighlight});
291
+
292
+ Future <void > test_dynamicRegistration_config_documentSymbol () =>
293
+ assertDynamicRegistration (
294
+ 'documentSymbol' , {Method .textDocument_documentSymbol});
295
+
296
+ Future <void > test_dynamicRegistration_config_fileOperations () =>
297
+ assertDynamicRegistration (
298
+ 'fileOperations' , {Method .workspace_willRenameFiles});
299
+
300
+ Future <void > test_dynamicRegistration_config_foldingRange () =>
301
+ assertDynamicRegistration (
302
+ 'foldingRange' , {Method .textDocument_foldingRange});
303
+
304
+ Future <void > test_dynamicRegistration_config_formatting () =>
305
+ assertDynamicRegistration ('formatting' , {Method .textDocument_formatting});
306
+
307
+ Future <void > test_dynamicRegistration_config_hover () =>
308
+ assertDynamicRegistration ('hover' , {Method .textDocument_hover});
309
+
310
+ Future <void > test_dynamicRegistration_config_implementation () =>
311
+ assertDynamicRegistration (
312
+ 'implementation' , {Method .textDocument_implementation});
313
+
314
+ Future <void > test_dynamicRegistration_config_inlayHint () =>
315
+ assertDynamicRegistration ('inlayHint' , {Method .textDocument_inlayHint});
316
+
317
+ Future <void > test_dynamicRegistration_config_onTypeFormatting () =>
318
+ assertDynamicRegistration (
319
+ 'onTypeFormatting' , {Method .textDocument_onTypeFormatting});
320
+
321
+ Future <void > test_dynamicRegistration_config_rangeFormatting () =>
322
+ assertDynamicRegistration (
323
+ 'rangeFormatting' , {Method .textDocument_rangeFormatting});
324
+
325
+ Future <void > test_dynamicRegistration_config_references () =>
326
+ assertDynamicRegistration ('references' , {Method .textDocument_references});
327
+
328
+ Future <void > test_dynamicRegistration_config_rename () =>
329
+ assertDynamicRegistration ('rename' , {Method .textDocument_rename});
330
+
331
+ Future <void > test_dynamicRegistration_config_selectionRange () =>
332
+ assertDynamicRegistration (
333
+ 'selectionRange' , {Method .textDocument_selectionRange});
334
+
335
+ Future <void > test_dynamicRegistration_config_semanticTokens () =>
336
+ assertDynamicRegistration (
337
+ 'semanticTokens' , {CustomMethods .semanticTokenDynamicRegistration});
338
+
339
+ Future <void > test_dynamicRegistration_config_signatureHelp () =>
340
+ assertDynamicRegistration (
341
+ 'signatureHelp' , {Method .textDocument_signatureHelp});
342
+
343
+ Future <void > test_dynamicRegistration_config_synchronization () =>
344
+ assertDynamicRegistration ('synchronization' , {
345
+ Method .textDocument_didOpen,
346
+ Method .textDocument_didChange,
347
+ Method .textDocument_didClose
348
+ });
349
+
350
+ Future <void > test_dynamicRegistration_config_typeDefinition () =>
351
+ assertDynamicRegistration (
352
+ 'typeDefinition' , {Method .textDocument_typeDefinition});
353
+
354
+ Future <void > test_dynamicRegistration_config_typeHierarchy () =>
355
+ assertDynamicRegistration (
356
+ 'typeHierarchy' , {Method .textDocument_prepareTypeHierarchy});
357
+
246
358
Future <void > test_dynamicRegistration_containsAppropriateSettings () async {
247
359
// Basic check that the server responds with the capabilities we'd expect,
248
360
// for ex including analysis_options.yaml in text synchronization but not
@@ -355,22 +467,6 @@ class InitializationTest extends AbstractLspAnalysisServerTest {
355
467
expect (didGetRegisterCapabilityRequest, isFalse);
356
468
}
357
469
358
- Future <void > test_dynamicRegistration_onlyForClientSupportedMethods () async {
359
- // Check that when the server calls client/registerCapability it only includes
360
- // the items we advertised dynamic registration support for.
361
- final registrations = < Registration > [];
362
- await monitorDynamicRegistrations (
363
- registrations,
364
- () => initialize (
365
- textDocumentCapabilities: withHoverDynamicRegistration (
366
- emptyTextDocumentClientCapabilities)),
367
- );
368
-
369
- expect (registrations, hasLength (1 ));
370
- expect (registrations.single.method,
371
- equals (Method .textDocument_hover.toJson ()));
372
- }
373
-
374
470
Future <void > test_dynamicRegistration_suppressesStaticRegistration () async {
375
471
// If the client sends dynamicRegistration settings then there
376
472
// should not be static registrations for the same capabilities.
0 commit comments