This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree 7 files changed +158
-161
lines changed 7 files changed +158
-161
lines changed Original file line number Diff line number Diff line change @@ -342,7 +342,7 @@ impl InFile<TextRange> {
342
342
}
343
343
344
344
impl < N : AstNode > InFile < N > {
345
- pub fn original_ast_node ( self , db : & dyn db:: ExpandDatabase ) -> Option < InRealFile < N > > {
345
+ pub fn original_ast_node_rooted ( self , db : & dyn db:: ExpandDatabase ) -> Option < InRealFile < N > > {
346
346
// This kind of upmapping can only be achieved in attribute expanded files,
347
347
// as we don't have node inputs otherwise and therefore can't find an `N` node in the input
348
348
let file_id = match self . file_id . repr ( ) {
Original file line number Diff line number Diff line change @@ -512,8 +512,7 @@ impl<'db> SemanticsImpl<'db> {
512
512
}
513
513
514
514
/// Descend the token into its macro call if it is part of one, returning the tokens in the
515
- /// expansion that it is associated with. If `offset` points into the token's range, it will
516
- /// be considered for the mapping in case of inline format args.
515
+ /// expansion that it is associated with.
517
516
pub fn descend_into_macros (
518
517
& self ,
519
518
mode : DescendPreference ,
@@ -850,7 +849,7 @@ impl<'db> SemanticsImpl<'db> {
850
849
/// Attempts to map the node out of macro expanded files.
851
850
/// This only work for attribute expansions, as other ones do not have nodes as input.
852
851
pub fn original_ast_node < N : AstNode > ( & self , node : N ) -> Option < N > {
853
- self . wrap_node_infile ( node) . original_ast_node ( self . db . upcast ( ) ) . map (
852
+ self . wrap_node_infile ( node) . original_ast_node_rooted ( self . db . upcast ( ) ) . map (
854
853
|InRealFile { file_id, value } | {
855
854
self . cache ( find_root ( value. syntax ( ) ) , file_id. into ( ) ) ;
856
855
value
Original file line number Diff line number Diff line change @@ -114,7 +114,7 @@ fn add_variant_to_accumulator(
114
114
parent : PathParent ,
115
115
) -> Option < ( ) > {
116
116
let db = ctx. db ( ) ;
117
- let InRealFile { file_id, value : enum_node } = adt. source ( db) ?. original_ast_node ( db) ?;
117
+ let InRealFile { file_id, value : enum_node } = adt. source ( db) ?. original_ast_node_rooted ( db) ?;
118
118
119
119
acc. add (
120
120
AssistId ( "generate_enum_variant" , AssistKind :: Generate ) ,
Original file line number Diff line number Diff line change @@ -516,7 +516,7 @@ fn source_edit_from_def(
516
516
if let Definition :: Local ( local) = def {
517
517
let mut file_id = None ;
518
518
for source in local. sources ( sema. db ) {
519
- let source = match source. source . clone ( ) . original_ast_node ( sema. db ) {
519
+ let source = match source. source . clone ( ) . original_ast_node_rooted ( sema. db ) {
520
520
Some ( source) => source,
521
521
None => match source
522
522
. source
@@ -560,7 +560,7 @@ fn source_edit_from_def(
560
560
}
561
561
} else {
562
562
// Foo { ref mut field } -> Foo { field: ref mut new_name }
563
- // ^ insert `field : `
563
+ // original_ast_node_rootedd : `
564
564
// ^^^^^ replace this with `new_name`
565
565
edit. insert (
566
566
pat. syntax ( ) . text_range ( ) . start ( ) ,
You can’t perform that action at this time.
0 commit comments