diff --git a/src/Server/TextDocument.php b/src/Server/TextDocument.php index 2e8e4bf..982a245 100644 --- a/src/Server/TextDocument.php +++ b/src/Server/TextDocument.php @@ -221,15 +221,18 @@ class TextDocument return []; } } - $refDocuments = yield Promise\all(array_map( - [$this->documentLoader, 'getOrLoad'], - $this->index->getReferenceUris($fqn) - )); - foreach ($refDocuments as $document) { - $refs = $document->getReferenceNodesByFqn($fqn); - if ($refs !== null) { - foreach ($refs as $ref) { - $locations[] = Location::fromNode($ref); + $referenceUris = $this->index->getReferenceUris($fqn); + if (!empty($referenceUris)) { + $refDocuments = yield Promise\all(array_map( + [$this->documentLoader, 'getOrLoad'], + $referenceUris + )); + foreach ($refDocuments as $document) { + $refs = $document->getReferenceNodesByFqn($fqn); + if ($refs !== null) { + foreach ($refs as $ref) { + $locations[] = Location::fromNode($ref); + } } } }