From 879c868af151aae611b0b7d8393b4b6ff0c9b817 Mon Sep 17 00:00:00 2001 From: Florian Schunk Date: Tue, 5 Nov 2019 21:05:59 +0100 Subject: [PATCH] allow rename classes --- src/Server/TextDocument.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Server/TextDocument.php b/src/Server/TextDocument.php index 988c3d2..a18d4a3 100644 --- a/src/Server/TextDocument.php +++ b/src/Server/TextDocument.php @@ -255,6 +255,13 @@ class TextDocument if ($context->includeDeclaration) { $refs = $document->getDefinitionNodeByFqn($fqn); if ($refs !== null){ + if ($refs instanceof Node\Statement\ClassDeclaration) { + if ($refs->name->getText($refs->getFileContents()) === $node->name->getText($node->getFileContents())) { + $location = LocationFactory::fromToken($refs, $refs->name); + $locations[] = $location; + } + } + foreach ($refs as $ref) { if ($ref !== null){ if ($ref instanceof Node\Expression\AssignmentExpression) { @@ -268,7 +275,7 @@ class TextDocument }elseif ($ref instanceof Node\ClassMembersNode) { foreach ($ref->classMemberDeclarations as $declaration) { if ($declaration instanceof Node\MethodDeclaration) { - if ($declaration->getName() === $node->getName()) { + if ($declaration->getName() === $node->name->getText($node->getFileContents())) { $location = LocationFactory::fromToken($declaration, $declaration->name); $locations[] = $location; }