@@ -49,6 +49,34 @@ public function testHandleNoSuggestions(): void
49
49
$ this ->assertFalse ($ response ->result ->isIncomplete );
50
50
}
51
51
52
+ public function testHandleWithDisabledCapability (): void
53
+ {
54
+ $ tester = $ this ->create (
55
+ [
56
+ Suggestion::create ('hello ' ),
57
+ Suggestion::create ('goodbye ' ),
58
+ ],
59
+ true ,
60
+ false ,
61
+ [],
62
+ [],
63
+ false
64
+ );
65
+ $ response = $ tester ->requestAndWait (
66
+ 'textDocument/completion ' ,
67
+ [
68
+ 'textDocument ' => ProtocolFactory::textDocumentIdentifier (self ::EXAMPLE_URI ),
69
+ 'position ' => ProtocolFactory::position (0 , 0 )
70
+ ]
71
+ );
72
+ $ this ->assertInstanceOf (CompletionList::class, $ response ->result );
73
+ $ this ->assertEquals ([
74
+ self ::completionItem ('hello ' , null ),
75
+ self ::completionItem ('goodbye ' , null ),
76
+ ], $ response ->result ->items );
77
+ $ this ->assertFalse ($ response ->result ->isIncomplete );
78
+ }
79
+
52
80
public function testHandleACompleteListOfSuggestions (): void
53
81
{
54
82
$ tester = $ this ->create ([
@@ -380,7 +408,8 @@ private function create(
380
408
bool $ supportSnippets = true ,
381
409
bool $ isIncomplete = false ,
382
410
array $ importNameTextEdits = [],
383
- array $ aliases = []
411
+ array $ aliases = [],
412
+ bool $ supportCompletion = true
384
413
): LanguageServerTester {
385
414
$ completor = $ this ->createCompletor ($ suggestions , $ isIncomplete );
386
415
$ registry = new TypedCompletorRegistry ([
@@ -392,7 +421,7 @@ private function create(
392
421
$ registry ,
393
422
new SuggestionNameFormatter (true ),
394
423
$ this ->createNameImporter ($ suggestions , $ aliases , $ importNameTextEdits ),
395
- $ this ->createClientCapabilities (true , $ supportSnippets ),
424
+ $ this ->createClientCapabilities ($ supportCompletion , $ supportSnippets ),
396
425
true
397
426
))->build ();
398
427
$ tester ->textDocument ()->open (self ::EXAMPLE_URI , self ::EXAMPLE_TEXT );
0 commit comments