@@ -176,14 +176,12 @@ impl NavigationTarget {
176176
177177impl TryToNav for FileSymbol {
178178 fn try_to_nav ( & self , db : & RootDatabase ) -> Option < UpmappingResult < NavigationTarget > > {
179- let root = db. parse_or_expand ( self . loc . hir_file_id ) ;
180- self . loc . ptr . to_node ( & root) ;
181179 Some (
182- orig_range_with_focus (
180+ orig_range_with_focus_r (
183181 db,
184182 self . loc . hir_file_id ,
185- & self . loc . ptr . to_node ( & root ) ,
186- Some ( self . loc . name_ptr . to_node ( & root ) ) ,
183+ self . loc . ptr . text_range ( ) ,
184+ Some ( self . loc . name_ptr . text_range ( ) ) ,
187185 )
188186 . map ( |( FileRange { file_id, range : full_range } , focus_range) | {
189187 NavigationTarget {
@@ -722,7 +720,21 @@ fn orig_range_with_focus(
722720 value : & SyntaxNode ,
723721 name : Option < impl AstNode > ,
724722) -> UpmappingResult < ( FileRange , Option < TextRange > ) > {
725- let Some ( name) = name else { return orig_range ( db, hir_file, value) } ;
723+ orig_range_with_focus_r (
724+ db,
725+ hir_file,
726+ value. text_range ( ) ,
727+ name. map ( |it| it. syntax ( ) . text_range ( ) ) ,
728+ )
729+ }
730+
731+ fn orig_range_with_focus_r (
732+ db : & RootDatabase ,
733+ hir_file : HirFileId ,
734+ value : TextRange ,
735+ name : Option < TextRange > ,
736+ ) -> UpmappingResult < ( FileRange , Option < TextRange > ) > {
737+ let Some ( name) = name else { return orig_range_r ( db, hir_file, value) } ;
726738
727739 let call_kind =
728740 || db. lookup_intern_macro_call ( hir_file. macro_file ( ) . unwrap ( ) . macro_call_id ) . kind ;
@@ -733,9 +745,9 @@ fn orig_range_with_focus(
733745 . definition_range ( db)
734746 } ;
735747
736- let value_range = InFile :: new ( hir_file, value) . original_file_range_opt ( db) ;
748+ let value_range = InFile :: new ( hir_file, value) . original_node_file_range_opt ( db) ;
737749 let ( ( call_site_range, call_site_focus) , def_site) =
738- match InFile :: new ( hir_file, name. syntax ( ) ) . original_file_range_opt ( db) {
750+ match InFile :: new ( hir_file, name) . original_node_file_range_opt ( db) {
739751 // call site name
740752 Some ( ( focus_range, ctxt) ) if ctxt. is_root ( ) => {
741753 // Try to upmap the node as well, if it ends up in the def site, go back to the call site
@@ -802,7 +814,7 @@ fn orig_range_with_focus(
802814 }
803815 }
804816 // lost name? can't happen for single tokens
805- None => return orig_range ( db, hir_file, value) ,
817+ None => return orig_range_r ( db, hir_file, value) ,
806818 } ;
807819
808820 UpmappingResult {
@@ -845,6 +857,17 @@ fn orig_range(
845857 }
846858}
847859
860+ fn orig_range_r (
861+ db : & RootDatabase ,
862+ hir_file : HirFileId ,
863+ value : TextRange ,
864+ ) -> UpmappingResult < ( FileRange , Option < TextRange > ) > {
865+ UpmappingResult {
866+ call_site : ( InFile :: new ( hir_file, value) . original_node_file_range ( db) . 0 , None ) ,
867+ def_site : None ,
868+ }
869+ }
870+
848871#[ cfg( test) ]
849872mod tests {
850873 use expect_test:: expect;
0 commit comments