From 1acff307fe2e20f0c2291fd24b08fba6fa39e5ee Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Sat, 19 Jan 2019 19:57:43 +0100 Subject: Move expr_scopes query to its module --- crates/ra_hir/src/db.rs | 2 +- crates/ra_hir/src/expr/scope.rs | 15 +++++++++++++-- crates/ra_hir/src/query_definitions.rs | 11 +++-------- 3 files changed, 17 insertions(+), 11 deletions(-) (limited to 'crates') diff --git a/crates/ra_hir/src/db.rs b/crates/ra_hir/src/db.rs index ddd4b2687..189649841 100644 --- a/crates/ra_hir/src/db.rs +++ b/crates/ra_hir/src/db.rs @@ -27,7 +27,7 @@ pub trait HirDatabase: SourceDatabase + AsRef { #[salsa::invoke(crate::macros::expand_macro_invocation)] fn expand_macro_invocation(&self, invoc: MacroCallId) -> Option>; - #[salsa::invoke(query_definitions::expr_scopes)] + #[salsa::invoke(ExprScopes::expr_scopes_query)] fn expr_scopes(&self, func: Function) -> Arc; #[salsa::invoke(crate::adt::StructData::struct_data_query)] diff --git a/crates/ra_hir/src/expr/scope.rs b/crates/ra_hir/src/expr/scope.rs index 17a1efed2..f8b5ba581 100644 --- a/crates/ra_hir/src/expr/scope.rs +++ b/crates/ra_hir/src/expr/scope.rs @@ -9,7 +9,11 @@ use ra_syntax::{ }; use ra_arena::{Arena, RawId, impl_arena_id}; -use crate::{Name, AsName, expr::{PatId, ExprId, Pat, Expr, Body, Statement, BodySyntaxMapping}}; +use crate::{ + Name, AsName, Function, + expr::{PatId, ExprId, Pat, Expr, Body, Statement, BodySyntaxMapping}, + db::HirDatabase, +}; #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct ScopeId(RawId); @@ -35,7 +39,14 @@ pub struct ScopeData { } impl ExprScopes { - pub(crate) fn new(body: Arc) -> ExprScopes { + // TODO: This should take something more general than Function + pub(crate) fn expr_scopes_query(db: &impl HirDatabase, function: Function) -> Arc { + let body = db.body_hir(function); + let res = ExprScopes::new(body); + Arc::new(res) + } + + fn new(body: Arc) -> ExprScopes { let mut scopes = ExprScopes { body: body.clone(), scopes: Arena::default(), diff --git a/crates/ra_hir/src/query_definitions.rs b/crates/ra_hir/src/query_definitions.rs index 1b61d449e..734a98282 100644 --- a/crates/ra_hir/src/query_definitions.rs +++ b/crates/ra_hir/src/query_definitions.rs @@ -1,19 +1,14 @@ use std::sync::Arc; -use ra_syntax::{SyntaxNode, TreeArc}; +use ra_syntax::{ + SyntaxNode, TreeArc, +}; use crate::{ SourceFileItems, SourceItemId, HirFileId, - Function, ExprScopes, db::HirDatabase, }; -pub(super) fn expr_scopes(db: &impl HirDatabase, func: Function) -> Arc { - let body = db.body_hir(func); - let res = ExprScopes::new(body); - Arc::new(res) -} - pub(super) fn file_items(db: &impl HirDatabase, file_id: HirFileId) -> Arc { let source_file = db.hir_parse(file_id); let res = SourceFileItems::new(file_id, &source_file); -- cgit v1.2.3