@@ -176,14 +176,12 @@ impl NavigationTarget {
176
176
177
177
impl TryToNav for FileSymbol {
178
178
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) ;
181
179
Some (
182
- orig_range_with_focus (
180
+ orig_range_with_focus_r (
183
181
db,
184
182
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 ( ) ) ,
187
185
)
188
186
. map ( |( FileRange { file_id, range : full_range } , focus_range) | {
189
187
NavigationTarget {
@@ -722,7 +720,21 @@ fn orig_range_with_focus(
722
720
value : & SyntaxNode ,
723
721
name : Option < impl AstNode > ,
724
722
) -> 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) } ;
726
738
727
739
let call_kind =
728
740
|| db. lookup_intern_macro_call ( hir_file. macro_file ( ) . unwrap ( ) . macro_call_id ) . kind ;
@@ -733,9 +745,9 @@ fn orig_range_with_focus(
733
745
. definition_range ( db)
734
746
} ;
735
747
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) ;
737
749
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) {
739
751
// call site name
740
752
Some ( ( focus_range, ctxt) ) if ctxt. is_root ( ) => {
741
753
// 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(
802
814
}
803
815
}
804
816
// 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) ,
806
818
} ;
807
819
808
820
UpmappingResult {
@@ -845,6 +857,17 @@ fn orig_range(
845
857
}
846
858
}
847
859
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
+
848
871
#[ cfg( test) ]
849
872
mod tests {
850
873
use expect_test:: expect;
0 commit comments