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 ;
@@ -33,7 +35,7 @@ use ruff_text_size::TextSize;
3335
3436use crate :: alt:: answers_solver:: AnswersSolver ;
3537use crate :: error:: error:: Error ;
36- use crate :: lsp:: module_helpers:: collect_symbol_def_paths ;
38+ use crate :: lsp:: module_helpers:: collect_symbol_def_paths_with_stdlib ;
3739use crate :: state:: lsp:: DefinitionMetadata ;
3840use crate :: state:: lsp:: FindDefinitionItemWithDocstring ;
3941use crate :: state:: lsp:: FindPreference ;
@@ -148,12 +150,12 @@ pub struct HoverValue {
148150 pub parameter_doc : Option < ( String , String ) > ,
149151 pub display : Option < String > ,
150152 pub show_go_to_links : bool ,
153+ pub symbol_def_paths : Vec < ( QName , PathBuf ) > ,
151154}
152155
153156impl HoverValue {
154157 #[ cfg( not( target_arch = "wasm32" ) ) ]
155- fn format_symbol_def_locations ( t : & Type ) -> Option < String > {
156- let symbol_paths = collect_symbol_def_paths ( t) ;
158+ fn format_symbol_def_locations ( symbol_paths : & [ ( QName , PathBuf ) ] ) -> Option < String > {
157159 let linked_names = symbol_paths
158160 . into_iter ( )
159161 . filter_map ( |( qname, file_path) | {
@@ -189,7 +191,7 @@ impl HoverValue {
189191 }
190192
191193 #[ cfg( target_arch = "wasm32" ) ]
192- fn format_symbol_def_locations ( t : & Type ) -> Option < String > {
194+ fn format_symbol_def_locations ( _symbol_paths : & [ ( QName , PathBuf ) ] ) -> Option < String > {
193195 None
194196 }
195197
@@ -222,7 +224,7 @@ impl HoverValue {
222224 . as_ref ( )
223225 . map_or ( "" . to_owned ( ) , |s| format ! ( "{s}: " ) ) ;
224226 let symbol_def_formatted = if self . show_go_to_links {
225- HoverValue :: format_symbol_def_locations ( & self . type_ ) . unwrap_or ( "" . to_owned ( ) )
227+ HoverValue :: format_symbol_def_locations ( & self . symbol_def_paths ) . unwrap_or ( "" . to_owned ( ) )
226228 } else {
227229 String :: new ( )
228230 } ;
@@ -404,6 +406,9 @@ pub fn get_hover(
404406 }
405407 }
406408
409+ let stdlib = transaction. get_stdlib ( handle) ;
410+ let symbol_def_paths = collect_symbol_def_paths_with_stdlib ( & type_, stdlib. as_ref ( ) ) ;
411+
407412 Some (
408413 HoverValue {
409414 kind,
@@ -413,6 +418,7 @@ pub fn get_hover(
413418 parameter_doc,
414419 display : type_display,
415420 show_go_to_links,
421+ symbol_def_paths,
416422 }
417423 . format ( ) ,
418424 )
0 commit comments