Skip to content

Commit b9d2c2c

Browse files
committed
made ExprCollector pub(crate) and moved
collect_fn_body_syntax
1 parent 88e22e9 commit b9d2c2c

File tree

2 files changed

+11
-14
lines changed

2 files changed

+11
-14
lines changed

crates/ra_hir/src/expr.rs

+1-10
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,7 @@ impl Pat {
462462

463463
// Queries
464464

465-
struct ExprCollector {
465+
pub(crate) struct ExprCollector {
466466
owner: DefWithBody,
467467
exprs: Arena<ExprId, Expr>,
468468
pats: Arena<PatId, Pat>,
@@ -943,12 +943,3 @@ pub(crate) fn body_with_source_map_query(
943943
pub(crate) fn body_hir_query(db: &impl HirDatabase, def: DefWithBody) -> Arc<Body> {
944944
db.body_with_source_map(def).0
945945
}
946-
947-
#[cfg(test)]
948-
use crate::{Function};
949-
#[cfg(test)]
950-
fn collect_fn_body_syntax(function: Function, node: &ast::FnDef) -> (Body, BodySourceMap) {
951-
let mut collector = ExprCollector::new(DefWithBody::Function(function));
952-
collector.collect_fn_body(node);
953-
collector.finish()
954-
}

crates/ra_hir/src/expr/scope.rs

+10-4
Original file line numberDiff line numberDiff line change
@@ -297,9 +297,9 @@ mod tests {
297297
use ra_syntax::{SourceFile, algo::find_node_at_offset};
298298
use test_utils::{extract_offset, assert_eq_text};
299299
use ra_arena::ArenaId;
300-
use crate::{Function};
300+
use crate::Function;
301301

302-
use crate::expr;
302+
use crate::expr::{ExprCollector};
303303

304304
use super::*;
305305

@@ -317,7 +317,7 @@ mod tests {
317317
let marker: &ast::PathExpr = find_node_at_offset(file.syntax(), off).unwrap();
318318
let fn_def: &ast::FnDef = find_node_at_offset(file.syntax(), off).unwrap();
319319
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);
321321
let scopes = ExprScopes::new(Arc::new(body));
322322
let scopes =
323323
ScopesWithSourceMap { scopes: Arc::new(scopes), source_map: Arc::new(source_map) };
@@ -406,6 +406,12 @@ mod tests {
406406
);
407407
}
408408

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+
409415
fn do_check_local_name(code: &str, expected_offset: u32) {
410416
let (off, code) = extract_offset(code);
411417
let file = SourceFile::parse(&code);
@@ -416,7 +422,7 @@ mod tests {
416422
let name_ref: &ast::NameRef = find_node_at_offset(file.syntax(), off).unwrap();
417423

418424
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);
420426
let scopes = ExprScopes::new(Arc::new(body));
421427
let scopes =
422428
ScopesWithSourceMap { scopes: Arc::new(scopes), source_map: Arc::new(source_map) };

0 commit comments

Comments
 (0)