Restrict workspace/symbol results to non-dependency symbols (#426)
This improves performance a lot and matches what other language servers dopull/429/head
parent
f43ce50d5a
commit
00552120ad
|
@ -33,7 +33,7 @@ class Workspace
|
||||||
*
|
*
|
||||||
* @var ProjectIndex
|
* @var ProjectIndex
|
||||||
*/
|
*/
|
||||||
private $index;
|
private $projectIndex;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var DependenciesIndex
|
* @var DependenciesIndex
|
||||||
|
@ -57,17 +57,17 @@ class Workspace
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param LanguageClient $client LanguageClient instance used to signal updated results
|
* @param LanguageClient $client LanguageClient instance used to signal updated results
|
||||||
* @param ProjectIndex $index Index that is searched on a workspace/symbol request
|
* @param ProjectIndex $projectIndex Index that is used to wait for full index completeness
|
||||||
* @param DependenciesIndex $dependenciesIndex Index that is used on a workspace/xreferences request
|
* @param DependenciesIndex $dependenciesIndex Index that is used on a workspace/xreferences request
|
||||||
* @param DependenciesIndex $sourceIndex Index that is used on a workspace/xreferences request
|
* @param DependenciesIndex $sourceIndex Index that is used on a workspace/xreferences request
|
||||||
* @param \stdClass $composerLock The parsed composer.lock of the project, if any
|
* @param \stdClass $composerLock The parsed composer.lock of the project, if any
|
||||||
* @param PhpDocumentLoader $documentLoader PhpDocumentLoader instance to load documents
|
* @param PhpDocumentLoader $documentLoader PhpDocumentLoader instance to load documents
|
||||||
*/
|
*/
|
||||||
public function __construct(LanguageClient $client, ProjectIndex $index, DependenciesIndex $dependenciesIndex, Index $sourceIndex, \stdClass $composerLock = null, PhpDocumentLoader $documentLoader, \stdClass $composerJson = null)
|
public function __construct(LanguageClient $client, ProjectIndex $projectIndex, DependenciesIndex $dependenciesIndex, Index $sourceIndex, \stdClass $composerLock = null, PhpDocumentLoader $documentLoader, \stdClass $composerJson = null)
|
||||||
{
|
{
|
||||||
$this->client = $client;
|
$this->client = $client;
|
||||||
$this->sourceIndex = $sourceIndex;
|
$this->sourceIndex = $sourceIndex;
|
||||||
$this->index = $index;
|
$this->projectIndex = $projectIndex;
|
||||||
$this->dependenciesIndex = $dependenciesIndex;
|
$this->dependenciesIndex = $dependenciesIndex;
|
||||||
$this->composerLock = $composerLock;
|
$this->composerLock = $composerLock;
|
||||||
$this->documentLoader = $documentLoader;
|
$this->documentLoader = $documentLoader;
|
||||||
|
@ -84,11 +84,11 @@ class Workspace
|
||||||
{
|
{
|
||||||
return coroutine(function () use ($query) {
|
return coroutine(function () use ($query) {
|
||||||
// Wait until indexing for definitions finished
|
// Wait until indexing for definitions finished
|
||||||
if (!$this->index->isStaticComplete()) {
|
if (!$this->sourceIndex->isStaticComplete()) {
|
||||||
yield waitForEvent($this->index, 'static-complete');
|
yield waitForEvent($this->sourceIndex, 'static-complete');
|
||||||
}
|
}
|
||||||
$symbols = [];
|
$symbols = [];
|
||||||
foreach ($this->index->getDefinitions() as $fqn => $definition) {
|
foreach ($this->sourceIndex->getDefinitions() as $fqn => $definition) {
|
||||||
if ($query === '' || stripos($fqn, $query) !== false) {
|
if ($query === '' || stripos($fqn, $query) !== false) {
|
||||||
$symbols[] = $definition->symbolInformation;
|
$symbols[] = $definition->symbolInformation;
|
||||||
}
|
}
|
||||||
|
@ -126,8 +126,8 @@ class Workspace
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
// Wait until indexing finished
|
// Wait until indexing finished
|
||||||
if (!$this->index->isComplete()) {
|
if (!$this->projectIndex->isComplete()) {
|
||||||
yield waitForEvent($this->index, 'complete');
|
yield waitForEvent($this->projectIndex, 'complete');
|
||||||
}
|
}
|
||||||
/** Map from URI to array of referenced FQNs in dependencies */
|
/** Map from URI to array of referenced FQNs in dependencies */
|
||||||
$refs = [];
|
$refs = [];
|
||||||
|
|
Loading…
Reference in New Issue