Repository: phpactor/phpactor (php)

Issue:
symbol highlight: does not highlight name import when on name
e.g.

```
use Drupal\auth\Repository\UserRepository;
$container->add(UserRepository::class, \Drupal::service('asdfasdf'), TRUE);
```

Pull request:
Highlighting use statement when hovering the class
Fixes #1921 

Patch:
diff --git a/lib/Extension/LanguageServerReferenceFinder/Model/Highlighter.php b/lib/Extension/LanguageServerReferenceFinder/Model/Highlighter.php
index a48f310d..dbd4b5bb 100644
--- a/lib/Extension/LanguageServerReferenceFinder/Model/Highlighter.php
+++ b/lib/Extension/LanguageServerReferenceFinder/Model/Highlighter.php
@@ -16,6 +16,7 @@ use Microsoft\PhpParser\Node\PropertyDeclaration;
 use Microsoft\PhpParser\Node\QualifiedName;
 use Microsoft\PhpParser\Node\SourceFileNode;
 use Microsoft\PhpParser\Node\Statement\ClassDeclaration;
+use Microsoft\PhpParser\Node\NamespaceUseClause;
 use Microsoft\PhpParser\Parser;
 use Microsoft\PhpParser\Token;
 use Phpactor\LanguageServerProtocol\DocumentHighlight;
@@ -283,10 +284,20 @@ class Highlighter
     /**
      * @return Generator<Highlight>
      */
-    private function namespacedNames(Node $rootNode, string $fullyQualfiiedName): Generator
+    private function namespacedNames(Node $rootNode, string $fullyQualfiedName): Generator
     {
         foreach ($rootNode->getDescendantNodes() as $node) {
-            if ($node instanceof ClassDeclaration && (string)$node->getNamespacedName() === $fullyQualfiiedName) {
+            if ($node instanceof NamespaceUseClause && (string) $node->namespaceName === $fullyQualfiedName) {
+                $nameParts = $node->namespaceName->nameParts;
+                $name = end($nameParts);
+
+                yield new Highlight(
+                    $name->getStartPosition(),
+                    $name->getEndPosition(),
+                    DocumentHighlightKind::TEXT
+                );
+            }
+            if ($node instanceof ClassDeclaration && (string)$node->getNamespacedName() === $fullyQualfiedName) {
                 yield new Highlight(
                     $node->name->getStartPosition(),
                     $node->name->getEndPosition(),
@@ -294,7 +305,7 @@ class Highlighter
                 );
             }
             if ($node instanceof QualifiedName) {
-                if ($fullyQualfiiedName === (string)$node->getResolvedName()) {
+                if ($fullyQualfiedName === (string)$node->getResolvedName()) {
                     yield new Highlight(
                         $node->getStartPosition(),
                         $node->getEndPosition(),


Test patch:
diff --git a/lib/Extension/LanguageServerReferenceFinder/Tests/Integration/Model/HighlighterTest.php b/lib/Extension/LanguageServerReferenceFinder/Tests/Integration/Model/HighlighterTest.php
index 97fe40c4..f08f92c7 100644
--- a/lib/Extension/LanguageServerReferenceFinder/Tests/Integration/Model/HighlighterTest.php
+++ b/lib/Extension/LanguageServerReferenceFinder/Tests/Integration/Model/HighlighterTest.php
@@ -193,6 +193,20 @@ class HighlighterTest extends TestCase
                 self::assertEquals(DocumentHighlightKind::TEXT, $highlights->at(0)->kind);
             }
         ];
+
+        yield 'class in use statement' => [
+            '<?php use SomeNamespace\Foo; echo SomeNamespace\Fo<>o::class;',
+            function (Highlights $highlights): void {
+                self::assertCount(2, $highlights);
+            }
+        ];
+
+        yield 'class alias in use statement' => [
+            '<?php use Foo as Test; echo Tes<>t::class;',
+            function (Highlights $highlights): void {
+                self::assertCount(2, $highlights);
+            }
+        ];
     }
 
     /**