From ee5b66abc6281ac04dbfdfbd7f46da2235997366 Mon Sep 17 00:00:00 2001 From: Felix Becker Date: Thu, 22 Jun 2017 19:16:13 +0200 Subject: [PATCH] Fixes --- src/Server/TextDocument.php | 7 ++++--- src/Server/Workspace.php | 8 ++++++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/Server/TextDocument.php b/src/Server/TextDocument.php index df97acd..5a2819e 100644 --- a/src/Server/TextDocument.php +++ b/src/Server/TextDocument.php @@ -396,7 +396,8 @@ class TextDocument } if ( $def === null - || ($def->symbolInformation !== null && Uri\parse($def->symbolInformation->location->uri)['scheme'] === 'phpstubs') + || $def->symbolInformation === null + || Uri\parse($def->symbolInformation->location->uri)['scheme'] === 'phpstubs' ) { return []; } @@ -406,8 +407,8 @@ class TextDocument if (!$packageName && $this->composerJson !== null) { $packageName = $this->composerJson->name; } - $symbol = new SymbolDescriptor($def->fqn, new PackageDescriptor($packageName)); - return [new SymbolLocationInformation($symbol, $symbol->location)]; + $descriptor = new SymbolDescriptor($def->fqn, new PackageDescriptor($packageName)); + return [new SymbolLocationInformation($descriptor, $def->symbolInformation->location)]; }); } } diff --git a/src/Server/Workspace.php b/src/Server/Workspace.php index 3f5e438..07481ce 100644 --- a/src/Server/Workspace.php +++ b/src/Server/Workspace.php @@ -13,7 +13,8 @@ use LanguageServer\Protocol\{ PackageDescriptor, ReferenceInformation, DependencyReference, - Location + Location, + MessageType }; use Sabre\Event\Promise; use function Sabre\Event\coroutine; @@ -148,7 +149,10 @@ class Workspace foreach ($refs as $uri => $fqns) { foreach ($fqns as $fqn) { $def = $this->dependenciesIndex->getDefinition($fqn); - $symbol->fqsen = $fqn; + if ($def === null) { + $this->client->window->logMessage(MessageType::WARNING, "Reference $fqn not found in index"); + continue; + } // Find out package name $packageName = getPackageName($def->symbolInformation->location->uri, $this->composerJson); $symbol = new SymbolDescriptor($fqn, new PackageDescriptor($packageName));