mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-29 13:25:09 +00:00
made ExprCollector pub(crate) and moved
collect_fn_body_syntax
This commit is contained in:
parent
88e22e9d70
commit
b9d2c2c21f
2 changed files with 11 additions and 14 deletions
|
@ -297,9 +297,9 @@ mod tests {
|
|||
use ra_syntax::{SourceFile, algo::find_node_at_offset};
|
||||
use test_utils::{extract_offset, assert_eq_text};
|
||||
use ra_arena::ArenaId;
|
||||
use crate::{Function};
|
||||
use crate::Function;
|
||||
|
||||
use crate::expr;
|
||||
use crate::expr::{ExprCollector};
|
||||
|
||||
use super::*;
|
||||
|
||||
|
@ -317,7 +317,7 @@ mod tests {
|
|||
let marker: &ast::PathExpr = find_node_at_offset(file.syntax(), off).unwrap();
|
||||
let fn_def: &ast::FnDef = find_node_at_offset(file.syntax(), off).unwrap();
|
||||
let irrelevant_function = Function { id: crate::ids::FunctionId::from_raw(0.into()) };
|
||||
let (body, source_map) = expr::collect_fn_body_syntax(irrelevant_function, fn_def);
|
||||
let (body, source_map) = collect_fn_body_syntax(irrelevant_function, fn_def);
|
||||
let scopes = ExprScopes::new(Arc::new(body));
|
||||
let scopes =
|
||||
ScopesWithSourceMap { scopes: Arc::new(scopes), source_map: Arc::new(source_map) };
|
||||
|
@ -406,6 +406,12 @@ mod tests {
|
|||
);
|
||||
}
|
||||
|
||||
fn collect_fn_body_syntax(function: Function, node: &ast::FnDef) -> (Body, BodySourceMap) {
|
||||
let mut collector = ExprCollector::new(DefWithBody::Function(function));
|
||||
collector.collect_fn_body(node);
|
||||
collector.finish()
|
||||
}
|
||||
|
||||
fn do_check_local_name(code: &str, expected_offset: u32) {
|
||||
let (off, code) = extract_offset(code);
|
||||
let file = SourceFile::parse(&code);
|
||||
|
@ -416,7 +422,7 @@ mod tests {
|
|||
let name_ref: &ast::NameRef = find_node_at_offset(file.syntax(), off).unwrap();
|
||||
|
||||
let irrelevant_function = Function { id: crate::ids::FunctionId::from_raw(0.into()) };
|
||||
let (body, source_map) = expr::collect_fn_body_syntax(irrelevant_function, fn_def);
|
||||
let (body, source_map) = collect_fn_body_syntax(irrelevant_function, fn_def);
|
||||
let scopes = ExprScopes::new(Arc::new(body));
|
||||
let scopes =
|
||||
ScopesWithSourceMap { scopes: Arc::new(scopes), source_map: Arc::new(source_map) };
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue