-
Notifications
You must be signed in to change notification settings - Fork 185
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for method/property completion
- Loading branch information
1 parent
429114f
commit 44d26ba
Showing
9 changed files
with
197 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<?php | ||
|
||
$obj = new TestClass; | ||
$obj->t |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?php | ||
declare(strict_types = 1); | ||
|
||
namespace LanguageServer\Tests\Server\TextDocument; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use LanguageServer\Tests\MockProtocolStream; | ||
use LanguageServer\{Server, LanguageClient, Project}; | ||
use LanguageServer\Protocol\{TextDocumentIdentifier, Position, ClientCapabilities, CompletionItem, CompletionItemKind}; | ||
use function LanguageServer\pathToUri; | ||
|
||
class CompletionTest extends TestCase | ||
{ | ||
/** | ||
* @var Server\TextDocument | ||
*/ | ||
private $textDocument; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
private $completionUri; | ||
|
||
public function setUp() | ||
{ | ||
$client = new LanguageClient(new MockProtocolStream, new MockProtocolStream); | ||
$project = new Project($client, new ClientCapabilities); | ||
$this->completionUri = pathToUri(__DIR__ . '/../../../fixtures/completion.php'); | ||
$project->loadDocument(pathToUri(__DIR__ . '/../../../fixtures/global_symbols.php')); | ||
$project->openDocument($this->completionUri, file_get_contents($this->completionUri)); | ||
$this->textDocument = new Server\TextDocument($project, $client); | ||
} | ||
|
||
public function testCompletion() | ||
{ | ||
$items = $this->textDocument->completion( | ||
new TextDocumentIdentifier($this->completionUri), | ||
new Position(3, 7) | ||
)->wait(); | ||
$this->assertEquals([ | ||
new CompletionItem( | ||
'testProperty', | ||
CompletionItemKind::PROPERTY, | ||
'\TestClass', // Type of the property | ||
'Reprehenderit magna velit mollit ipsum do.' | ||
), | ||
new CompletionItem( | ||
'testMethod', | ||
CompletionItemKind::METHOD, | ||
'\TestClass', // Return type of the method | ||
'Non culpa nostrud mollit esse sunt laboris in irure ullamco cupidatat amet.' | ||
) | ||
], $items); | ||
} | ||
} |