@@ -397,11 +397,7 @@ impl LanguageServer for Backend {
397397 . supports_type_hierarchy_dynamic_registration
398398 . load ( Ordering :: Acquire )
399399 {
400- registrations. push ( Registration {
401- id : "type-hierarchy" . to_string ( ) ,
402- method : "textDocument/prepareTypeHierarchy" . to_string ( ) ,
403- register_options : None ,
404- } ) ;
400+ registrations. push ( type_hierarchy_registration ( ) ) ;
405401 }
406402
407403 // Register file watchers for staleness detection. The client
@@ -1588,6 +1584,27 @@ impl LanguageServer for Backend {
15881584 }
15891585}
15901586
1587+ fn type_hierarchy_registration ( ) -> Registration {
1588+ Registration {
1589+ id : "type-hierarchy" . to_string ( ) ,
1590+ method : "textDocument/prepareTypeHierarchy" . to_string ( ) ,
1591+ register_options : Some (
1592+ serde_json:: to_value ( TypeHierarchyRegistrationOptions {
1593+ text_document_registration_options : TextDocumentRegistrationOptions {
1594+ document_selector : Some ( vec ! [ DocumentFilter {
1595+ language: Some ( "php" . to_string( ) ) ,
1596+ scheme: None ,
1597+ pattern: None ,
1598+ } ] ) ,
1599+ } ,
1600+ type_hierarchy_options : TypeHierarchyOptions :: default ( ) ,
1601+ static_registration_options : StaticRegistrationOptions :: default ( ) ,
1602+ } )
1603+ . expect ( "type hierarchy registration options serialize" ) ,
1604+ ) ,
1605+ }
1606+ }
1607+
15911608/// Convert a `Vec<Location>` into a `GotoDefinitionResponse`.
15921609///
15931610/// Returns `Scalar` for a single location, `Array` for multiple, and
@@ -1603,6 +1620,26 @@ fn wrap_locations(locations: Vec<Location>) -> Option<GotoDefinitionResponse> {
16031620 }
16041621}
16051622
1623+ #[ cfg( test) ]
1624+ mod tests {
1625+ use super :: * ;
1626+
1627+ #[ test]
1628+ fn type_hierarchy_registration_includes_php_document_selector ( ) {
1629+ let registration = type_hierarchy_registration ( ) ;
1630+
1631+ assert_eq ! ( registration. id, "type-hierarchy" ) ;
1632+ assert_eq ! ( registration. method, "textDocument/prepareTypeHierarchy" ) ;
1633+
1634+ let options = registration
1635+ . register_options
1636+ . expect ( "type hierarchy registration should include options" ) ;
1637+ assert_eq ! ( options[ "documentSelector" ] [ 0 ] [ "language" ] , "php" ) ;
1638+ assert ! ( options[ "documentSelector" ] [ 0 ] . get( "scheme" ) . is_none( ) ) ;
1639+ assert ! ( options[ "documentSelector" ] [ 0 ] . get( "pattern" ) . is_none( ) ) ;
1640+ }
1641+ }
1642+
16061643// ─── Self-scan helpers ──────────────────────────────────────────────────────
16071644
16081645impl Backend {
0 commit comments