@@ -2,6 +2,8 @@ use crate::common::{create_test_backend, create_test_backend_with_stubs};
22use phpantom_lsp:: Backend ;
33use phpantom_lsp:: atom:: atom;
44use phpantom_lsp:: php_type:: PhpType ;
5+ use phpantom_lsp:: types:: { ClassInfo , ClassLikeKind } ;
6+ use std:: sync:: Arc ;
57use tower_lsp:: LanguageServer ;
68use tower_lsp:: lsp_types:: * ;
79
@@ -812,6 +814,19 @@ async fn test_unloaded_classes_pass_through_filter() {
812814 "file:///vendor/mystery.php" . to_string ( ) ,
813815 ) ;
814816 }
817+ // Also insert into fqn_class_index so check_context_match can verify the kind.
818+ {
819+ let mut idx = backend. fqn_class_index ( ) . write ( ) ;
820+ idx. insert (
821+ "UnknownKind\\ MysteryClass" . to_string ( ) ,
822+ Arc :: new ( ClassInfo {
823+ kind : ClassLikeKind :: Interface ,
824+ name : atom ( "MysteryClass" ) ,
825+ file_namespace : Some ( atom ( "UnknownKind" ) ) ,
826+ ..Default :: default ( )
827+ } ) ,
828+ ) ;
829+ }
815830
816831 let uri = Url :: parse ( "file:///test_unloaded.php" ) . unwrap ( ) ;
817832 let text = "<?php\n class Foo implements Mystery" ;
@@ -1715,6 +1730,37 @@ async fn test_implements_demotes_abstract_looking_names() {
17151730 "file:///vendor/c.php" . to_string ( ) ,
17161731 ) ;
17171732 }
1733+ // Insert into fqn_class_index so check_context_match can verify their kind.
1734+ {
1735+ let mut idx = backend. fqn_class_index ( ) . write ( ) ;
1736+ idx. insert (
1737+ "App\\ YxLoggable" . to_string ( ) ,
1738+ Arc :: new ( ClassInfo {
1739+ kind : ClassLikeKind :: Interface ,
1740+ name : atom ( "YxLoggable" ) ,
1741+ file_namespace : Some ( atom ( "App" ) ) ,
1742+ ..Default :: default ( )
1743+ } ) ,
1744+ ) ;
1745+ idx. insert (
1746+ "App\\ AbstractYxHandler" . to_string ( ) ,
1747+ Arc :: new ( ClassInfo {
1748+ kind : ClassLikeKind :: Interface ,
1749+ name : atom ( "AbstractYxHandler" ) ,
1750+ file_namespace : Some ( atom ( "App" ) ) ,
1751+ ..Default :: default ( )
1752+ } ) ,
1753+ ) ;
1754+ idx. insert (
1755+ "App\\ BaseYxController" . to_string ( ) ,
1756+ Arc :: new ( ClassInfo {
1757+ kind : ClassLikeKind :: Interface ,
1758+ name : atom ( "BaseYxController" ) ,
1759+ file_namespace : Some ( atom ( "App" ) ) ,
1760+ ..Default :: default ( )
1761+ } ) ,
1762+ ) ;
1763+ }
17181764
17191765 let uri = Url :: parse ( "file:///test_impl_demote.php" ) . unwrap ( ) ;
17201766 // Partial "Yx" matches YxLoggable; separate requests for the others.
@@ -1786,6 +1832,37 @@ async fn test_trait_use_demotes_non_trait_looking_names() {
17861832 "file:///vendor/c.php" . to_string ( ) ,
17871833 ) ;
17881834 }
1835+ // Insert into fqn_class_index so check_context_match can verify their kind.
1836+ {
1837+ let mut idx = backend. fqn_class_index ( ) . write ( ) ;
1838+ idx. insert (
1839+ "App\\ WxHasTimestamps" . to_string ( ) ,
1840+ Arc :: new ( ClassInfo {
1841+ kind : ClassLikeKind :: Trait ,
1842+ name : atom ( "WxHasTimestamps" ) ,
1843+ file_namespace : Some ( atom ( "App" ) ) ,
1844+ ..Default :: default ( )
1845+ } ) ,
1846+ ) ;
1847+ idx. insert (
1848+ "App\\ WxUserInterface" . to_string ( ) ,
1849+ Arc :: new ( ClassInfo {
1850+ kind : ClassLikeKind :: Trait ,
1851+ name : atom ( "WxUserInterface" ) ,
1852+ file_namespace : Some ( atom ( "App" ) ) ,
1853+ ..Default :: default ( )
1854+ } ) ,
1855+ ) ;
1856+ idx. insert (
1857+ "App\\ AbstractWxModel" . to_string ( ) ,
1858+ Arc :: new ( ClassInfo {
1859+ kind : ClassLikeKind :: Trait ,
1860+ name : atom ( "AbstractWxModel" ) ,
1861+ file_namespace : Some ( atom ( "App" ) ) ,
1862+ ..Default :: default ( )
1863+ } ) ,
1864+ ) ;
1865+ }
17891866
17901867 let uri = Url :: parse ( "file:///test_use_demote.php" ) . unwrap ( ) ;
17911868 // Partial "Wx" matches WxHasTimestamps and WxUserInterface.
@@ -1898,6 +1975,28 @@ async fn test_extends_interface_does_not_demote_interface_names() {
18981975 "file:///vendor/b.php" . to_string ( ) ,
18991976 ) ;
19001977 }
1978+ // Insert into fqn_class_index so check_context_match can verify their kind.
1979+ {
1980+ let mut idx = backend. fqn_class_index ( ) . write ( ) ;
1981+ idx. insert (
1982+ "App\\ LoggerInterface" . to_string ( ) ,
1983+ Arc :: new ( ClassInfo {
1984+ kind : ClassLikeKind :: Interface ,
1985+ name : atom ( "LoggerInterface" ) ,
1986+ file_namespace : Some ( atom ( "App" ) ) ,
1987+ ..Default :: default ( )
1988+ } ) ,
1989+ ) ;
1990+ idx. insert (
1991+ "App\\ Loggable" . to_string ( ) ,
1992+ Arc :: new ( ClassInfo {
1993+ kind : ClassLikeKind :: Interface ,
1994+ name : atom ( "Loggable" ) ,
1995+ file_namespace : Some ( atom ( "App" ) ) ,
1996+ ..Default :: default ( )
1997+ } ) ,
1998+ ) ;
1999+ }
19012000
19022001 let uri = Url :: parse ( "file:///test_ext_iface_sort.php" ) . unwrap ( ) ;
19032002 let text = "<?php\n interface Foo extends Log" ;
0 commit comments