2
2
3
3
mod source_to_def;
4
4
5
- use std:: { cell:: RefCell , fmt} ;
5
+ use std:: { cell:: RefCell , fmt, iter } ;
6
6
7
7
use base_db:: { FileId , FileRange } ;
8
8
use either:: Either ;
@@ -749,8 +749,8 @@ impl<'db> SemanticsImpl<'db> {
749
749
750
750
fn diagnostics_display_range ( & self , src : InFile < SyntaxNodePtr > ) -> FileRange {
751
751
let root = self . parse_or_expand ( src. file_id ) . unwrap ( ) ;
752
- let node = src. value . to_node ( & root) ;
753
- src . with_value ( & node ) . original_file_range ( self . db . upcast ( ) )
752
+ let node = src. map ( |it| it . to_node ( & root) ) ;
753
+ node . as_ref ( ) . original_file_range ( self . db . upcast ( ) )
754
754
}
755
755
756
756
fn token_ancestors_with_macros (
@@ -765,7 +765,17 @@ impl<'db> SemanticsImpl<'db> {
765
765
node : SyntaxNode ,
766
766
) -> impl Iterator < Item = SyntaxNode > + Clone + ' _ {
767
767
let node = self . find_file ( & node) ;
768
- node. ancestors_with_macros ( self . db . upcast ( ) ) . map ( |it| it. value )
768
+ let db = self . db . upcast ( ) ;
769
+ iter:: successors ( Some ( node. cloned ( ) ) , move |& InFile { file_id, ref value } | {
770
+ match value. parent ( ) {
771
+ Some ( parent) => Some ( InFile :: new ( file_id, parent) ) ,
772
+ None => {
773
+ self . cache ( value. clone ( ) , file_id) ;
774
+ file_id. call_node ( db)
775
+ }
776
+ }
777
+ } )
778
+ . map ( |it| it. value )
769
779
}
770
780
771
781
fn ancestors_at_offset_with_macros (
0 commit comments