|
17 | 17 | Position,
|
18 | 18 | CompletionList,
|
19 | 19 | CompletionItem,
|
20 |
| - CompletionItemKind |
| 20 | + CompletionItemKind, |
| 21 | + CompletionContext, |
| 22 | + CompletionTriggerKind |
21 | 23 | };
|
22 | 24 | use function LanguageServer\pathToUri;
|
23 | 25 |
|
@@ -464,6 +466,41 @@ public function testHtmlWithPrefix()
|
464 | 466 | ], true), $items);
|
465 | 467 | }
|
466 | 468 |
|
| 469 | + public function testHtmlPrefixShouldNotTriggerCompletion() |
| 470 | + { |
| 471 | + $completionUri = pathToUri(__DIR__ . '/../../../fixtures/completion/html_no_completion.php'); |
| 472 | + $this->loader->open($completionUri, file_get_contents($completionUri)); |
| 473 | + $items = $this->textDocument->completion( |
| 474 | + new TextDocumentIdentifier($completionUri), |
| 475 | + new Position(0, 1), |
| 476 | + new CompletionContext(CompletionTriggerKind::TRIGGER_CHARACTER, '>') |
| 477 | + )->wait(); |
| 478 | + $this->assertEquals(new CompletionList([], true), $items); |
| 479 | + } |
| 480 | + |
| 481 | + public function testHtmlPrefixShouldTriggerCompletionIfManuallyInvoked() |
| 482 | + { |
| 483 | + $completionUri = pathToUri(__DIR__ . '/../../../fixtures/completion/html_no_completion.php'); |
| 484 | + $this->loader->open($completionUri, file_get_contents($completionUri)); |
| 485 | + $items = $this->textDocument->completion( |
| 486 | + new TextDocumentIdentifier($completionUri), |
| 487 | + new Position(0, 1), |
| 488 | + new CompletionContext(CompletionTriggerKind::INVOKED) |
| 489 | + )->wait(); |
| 490 | + $this->assertEquals(new CompletionList([ |
| 491 | + new CompletionItem( |
| 492 | + '<?php', |
| 493 | + CompletionItemKind::KEYWORD, |
| 494 | + null, |
| 495 | + null, |
| 496 | + null, |
| 497 | + null, |
| 498 | + null, |
| 499 | + new TextEdit(new Range(new Position(0, 1), new Position(0, 1)), '?php') |
| 500 | + ) |
| 501 | + ], true), $items); |
| 502 | + } |
| 503 | + |
467 | 504 | public function testNamespace()
|
468 | 505 | {
|
469 | 506 | $completionUri = pathToUri(__DIR__ . '/../../../fixtures/completion/namespace.php');
|
@@ -605,7 +642,7 @@ public function testThisWithoutPrefix()
|
605 | 642 | )
|
606 | 643 | ], true), $items);
|
607 | 644 | }
|
608 |
| - |
| 645 | + |
609 | 646 | public function testThisWithPrefix()
|
610 | 647 | {
|
611 | 648 | $completionUri = pathToUri(__DIR__ . '/../../../fixtures/completion/this_with_prefix.php');
|
|
0 commit comments