From b9d2c2c21fe8880fe1ca29b70b03db1d3faac554 Mon Sep 17 00:00:00 2001 From: Lenard Pratt Date: Tue, 2 Apr 2019 19:21:08 +0100 Subject: made ExprCollector pub(crate) and moved collect_fn_body_syntax --- crates/ra_hir/src/expr.rs | 11 +---------- crates/ra_hir/src/expr/scope.rs | 14 ++++++++++---- 2 files changed, 11 insertions(+), 14 deletions(-) (limited to 'crates') diff --git a/crates/ra_hir/src/expr.rs b/crates/ra_hir/src/expr.rs index bc4c63d3c..51366de0a 100644 --- a/crates/ra_hir/src/expr.rs +++ b/crates/ra_hir/src/expr.rs @@ -462,7 +462,7 @@ impl Pat { // Queries -struct ExprCollector { +pub(crate) struct ExprCollector { owner: DefWithBody, exprs: Arena, pats: Arena, @@ -943,12 +943,3 @@ pub(crate) fn body_with_source_map_query( pub(crate) fn body_hir_query(db: &impl HirDatabase, def: DefWithBody) -> Arc { db.body_with_source_map(def).0 } - -#[cfg(test)] -use crate::{Function}; -#[cfg(test)] -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() -} diff --git a/crates/ra_hir/src/expr/scope.rs b/crates/ra_hir/src/expr/scope.rs index 9d6b1eb2b..48283907b 100644 --- a/crates/ra_hir/src/expr/scope.rs +++ b/crates/ra_hir/src/expr/scope.rs @@ -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) }; -- cgit v1.2.3