66 */
77
88use std:: collections:: HashMap ;
9+ use std:: path:: PathBuf ;
910
1011use lsp_types:: Hover ;
1112use lsp_types:: HoverContents ;
@@ -18,6 +19,7 @@ use pyrefly_python::docstring::parse_parameter_documentation;
1819use pyrefly_python:: ignore:: Ignore ;
1920use pyrefly_python:: ignore:: Tool ;
2021use pyrefly_python:: ignore:: find_comment_start_in_line;
22+ use pyrefly_python:: qname:: QName ;
2123use pyrefly_python:: symbol_kind:: SymbolKind ;
2224use pyrefly_types:: callable:: Callable ;
2325use pyrefly_types:: callable:: Param ;
@@ -32,7 +34,7 @@ use ruff_text_size::TextSize;
3234
3335use crate :: alt:: answers_solver:: AnswersSolver ;
3436use crate :: error:: error:: Error ;
35- use crate :: lsp:: module_helpers:: collect_symbol_def_paths ;
37+ use crate :: lsp:: module_helpers:: collect_symbol_def_paths_with_stdlib ;
3638use crate :: state:: lsp:: DefinitionMetadata ;
3739use crate :: state:: lsp:: FindDefinitionItemWithDocstring ;
3840use crate :: state:: lsp:: FindPreference ;
@@ -113,12 +115,12 @@ pub struct HoverValue {
113115 pub parameter_doc : Option < ( String , String ) > ,
114116 pub display : Option < String > ,
115117 pub show_go_to_links : bool ,
118+ pub symbol_def_paths : Vec < ( QName , PathBuf ) > ,
116119}
117120
118121impl HoverValue {
119122 #[ cfg( not( target_arch = "wasm32" ) ) ]
120- fn format_symbol_def_locations ( t : & Type ) -> Option < String > {
121- let symbol_paths = collect_symbol_def_paths ( t) ;
123+ fn format_symbol_def_locations ( symbol_paths : & [ ( QName , PathBuf ) ] ) -> Option < String > {
122124 let linked_names = symbol_paths
123125 . into_iter ( )
124126 . filter_map ( |( qname, file_path) | {
@@ -154,7 +156,7 @@ impl HoverValue {
154156 }
155157
156158 #[ cfg( target_arch = "wasm32" ) ]
157- fn format_symbol_def_locations ( t : & Type ) -> Option < String > {
159+ fn format_symbol_def_locations ( _symbol_paths : & [ ( QName , PathBuf ) ] ) -> Option < String > {
158160 None
159161 }
160162
@@ -187,7 +189,7 @@ impl HoverValue {
187189 . as_ref ( )
188190 . map_or ( "" . to_owned ( ) , |s| format ! ( "{s}: " ) ) ;
189191 let symbol_def_formatted = if self . show_go_to_links {
190- HoverValue :: format_symbol_def_locations ( & self . type_ ) . unwrap_or ( "" . to_owned ( ) )
192+ HoverValue :: format_symbol_def_locations ( & self . symbol_def_paths ) . unwrap_or ( "" . to_owned ( ) )
191193 } else {
192194 String :: new ( )
193195 } ;
@@ -365,6 +367,9 @@ pub fn get_hover(
365367 }
366368 }
367369
370+ let stdlib = transaction. get_stdlib ( handle) ;
371+ let symbol_def_paths = collect_symbol_def_paths_with_stdlib ( & type_, stdlib. as_ref ( ) ) ;
372+
368373 Some (
369374 HoverValue {
370375 kind,
@@ -374,6 +379,7 @@ pub fn get_hover(
374379 parameter_doc,
375380 display : type_display,
376381 show_go_to_links,
382+ symbol_def_paths,
377383 }
378384 . format ( ) ,
379385 )
0 commit comments