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
|
* @var ProtocolReader
|
||||||
*/
|
*/
|
||||||
private $protocolReader;
|
protected $protocolReader;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var ProtocolWriter
|
* @var ProtocolWriter
|
||||||
*/
|
*/
|
||||||
private $protocolWriter;
|
protected $protocolWriter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var LanguageClient
|
* @var LanguageClient
|
||||||
*/
|
*/
|
||||||
private $client;
|
protected $client;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var FilesFinder
|
* @var FilesFinder
|
||||||
*/
|
*/
|
||||||
private $filesFinder;
|
protected $filesFinder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var ContentRetriever
|
* @var ContentRetriever
|
||||||
*/
|
*/
|
||||||
private $contentRetriever;
|
protected $contentRetriever;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var PhpDocumentLoader
|
||||||
|
*/
|
||||||
|
protected $documentLoader;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param PotocolReader $reader
|
* @param PotocolReader $reader
|
||||||
|
@ -139,6 +144,8 @@ class LanguageServer extends AdvancedJsonRpc\Dispatcher
|
||||||
{
|
{
|
||||||
return coroutine(function () use ($capabilities, $rootPath, $processId) {
|
return coroutine(function () use ($capabilities, $rootPath, $processId) {
|
||||||
|
|
||||||
|
yield null;
|
||||||
|
|
||||||
if ($capabilities->xfilesProvider) {
|
if ($capabilities->xfilesProvider) {
|
||||||
$this->filesFinder = new ClientFilesFinder($this->client);
|
$this->filesFinder = new ClientFilesFinder($this->client);
|
||||||
} else {
|
} else {
|
||||||
|
@ -165,9 +172,7 @@ class LanguageServer extends AdvancedJsonRpc\Dispatcher
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($rootPath !== null) {
|
if ($rootPath !== null) {
|
||||||
$pattern = Path::makeAbsolute('**/*.php', $rootPath);
|
$this->index($rootPath)->otherwise('\\LanguageServer\\crash');
|
||||||
$uris = yield $this->filesFinder->find($pattern);
|
|
||||||
$this->index($uris)->otherwise('\\LanguageServer\\crash');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->textDocument = new Server\TextDocument(
|
$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
|
* Will read and parse the passed source files in the project and add them to the appropiate indexes
|
||||||
*
|
*
|
||||||
|
* @param string $rootPath
|
||||||
* @return Promise <void>
|
* @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);
|
$count = count($uris);
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ class PhpDocumentLoader
|
||||||
/**
|
/**
|
||||||
* @var ContentRetriever
|
* @var ContentRetriever
|
||||||
*/
|
*/
|
||||||
private $contentRetriever;
|
public $contentRetriever;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var ProjectIndex
|
* @var ProjectIndex
|
||||||
|
|
Loading…
Reference in New Issue