@@ -297,9 +297,9 @@ mod tests {
297
297
use ra_syntax:: { SourceFile , algo:: find_node_at_offset} ;
298
298
use test_utils:: { extract_offset, assert_eq_text} ;
299
299
use ra_arena:: ArenaId ;
300
- use crate :: { Function } ;
300
+ use crate :: Function ;
301
301
302
- use crate :: expr;
302
+ use crate :: expr:: { ExprCollector } ;
303
303
304
304
use super :: * ;
305
305
@@ -317,7 +317,7 @@ mod tests {
317
317
let marker: & ast:: PathExpr = find_node_at_offset ( file. syntax ( ) , off) . unwrap ( ) ;
318
318
let fn_def: & ast:: FnDef = find_node_at_offset ( file. syntax ( ) , off) . unwrap ( ) ;
319
319
let irrelevant_function = Function { id : crate :: ids:: FunctionId :: from_raw ( 0 . into ( ) ) } ;
320
- let ( body, source_map) = expr :: collect_fn_body_syntax ( irrelevant_function, fn_def) ;
320
+ let ( body, source_map) = collect_fn_body_syntax ( irrelevant_function, fn_def) ;
321
321
let scopes = ExprScopes :: new ( Arc :: new ( body) ) ;
322
322
let scopes =
323
323
ScopesWithSourceMap { scopes : Arc :: new ( scopes) , source_map : Arc :: new ( source_map) } ;
@@ -406,6 +406,12 @@ mod tests {
406
406
) ;
407
407
}
408
408
409
+ fn collect_fn_body_syntax ( function : Function , node : & ast:: FnDef ) -> ( Body , BodySourceMap ) {
410
+ let mut collector = ExprCollector :: new ( DefWithBody :: Function ( function) ) ;
411
+ collector. collect_fn_body ( node) ;
412
+ collector. finish ( )
413
+ }
414
+
409
415
fn do_check_local_name ( code : & str , expected_offset : u32 ) {
410
416
let ( off, code) = extract_offset ( code) ;
411
417
let file = SourceFile :: parse ( & code) ;
@@ -416,7 +422,7 @@ mod tests {
416
422
let name_ref: & ast:: NameRef = find_node_at_offset ( file. syntax ( ) , off) . unwrap ( ) ;
417
423
418
424
let irrelevant_function = Function { id : crate :: ids:: FunctionId :: from_raw ( 0 . into ( ) ) } ;
419
- let ( body, source_map) = expr :: collect_fn_body_syntax ( irrelevant_function, fn_def) ;
425
+ let ( body, source_map) = collect_fn_body_syntax ( irrelevant_function, fn_def) ;
420
426
let scopes = ExprScopes :: new ( Arc :: new ( body) ) ;
421
427
let scopes =
422
428
ScopesWithSourceMap { scopes : Arc :: new ( scopes) , source_map : Arc :: new ( source_map) } ;
0 commit comments