Allow overriding (#229)
* Add missing documentLoader property * Make PhpDocumentLoader->contentRetriever publicpull/189/merge v4.1.2
parent
662143abad
commit
49245fd4d3
|
@ -54,27 +54,32 @@ class LanguageServer extends AdvancedJsonRpc\Dispatcher
|
|||
/**
|
||||
* @var ProtocolReader
|
||||
*/
|
||||
private $protocolReader;
|
||||
protected $protocolReader;
|
||||
|
||||
/**
|
||||
* @var ProtocolWriter
|
||||
*/
|
||||
private $protocolWriter;
|
||||
protected $protocolWriter;
|
||||
|
||||
/**
|
||||
* @var LanguageClient
|
||||
*/
|
||||
private $client;
|
||||
protected $client;
|
||||
|
||||
/**
|
||||
* @var FilesFinder
|
||||
*/
|
||||
private $filesFinder;
|
||||
protected $filesFinder;
|
||||
|
||||
/**
|
||||
* @var ContentRetriever
|
||||
*/
|
||||
private $contentRetriever;
|
||||
protected $contentRetriever;
|
||||
|
||||
/**
|
||||
* @var PhpDocumentLoader
|
||||
*/
|
||||
protected $documentLoader;
|
||||
|
||||
/**
|
||||
* @param PotocolReader $reader
|
||||
|
@ -139,6 +144,8 @@ class LanguageServer extends AdvancedJsonRpc\Dispatcher
|
|||
{
|
||||
return coroutine(function () use ($capabilities, $rootPath, $processId) {
|
||||
|
||||
yield null;
|
||||
|
||||
if ($capabilities->xfilesProvider) {
|
||||
$this->filesFinder = new ClientFilesFinder($this->client);
|
||||
} else {
|
||||
|
@ -165,9 +172,7 @@ class LanguageServer extends AdvancedJsonRpc\Dispatcher
|
|||
);
|
||||
|
||||
if ($rootPath !== null) {
|
||||
$pattern = Path::makeAbsolute('**/*.php', $rootPath);
|
||||
$uris = yield $this->filesFinder->find($pattern);
|
||||
$this->index($uris)->otherwise('\\LanguageServer\\crash');
|
||||
$this->index($rootPath)->otherwise('\\LanguageServer\\crash');
|
||||
}
|
||||
|
||||
$this->textDocument = new Server\TextDocument(
|
||||
|
@ -228,11 +233,15 @@ class LanguageServer extends AdvancedJsonRpc\Dispatcher
|
|||
/**
|
||||
* Will read and parse the passed source files in the project and add them to the appropiate indexes
|
||||
*
|
||||
* @param string $rootPath
|
||||
* @return Promise <void>
|
||||
*/
|
||||
private function index(array $uris): Promise
|
||||
protected function index(string $rootPath): Promise
|
||||
{
|
||||
return coroutine(function () use ($uris) {
|
||||
return coroutine(function () use ($rootPath) {
|
||||
|
||||
$pattern = Path::makeAbsolute('**/*.php', $rootPath);
|
||||
$uris = yield $this->filesFinder->find($pattern);
|
||||
|
||||
$count = count($uris);
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ class PhpDocumentLoader
|
|||
/**
|
||||
* @var ContentRetriever
|
||||
*/
|
||||
private $contentRetriever;
|
||||
public $contentRetriever;
|
||||
|
||||
/**
|
||||
* @var ProjectIndex
|
||||
|
|
Loading…
Reference in New Issue