diff options
author | Aleksey Kladov <[email protected]> | 2019-11-14 14:37:22 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-11-14 14:37:22 +0000 |
commit | 1583ab1558022d0fdbbc10d3a440a2d3daa4a840 (patch) | |
tree | ff8a962228a7532a5f468862bc4b0c62535f5069 /crates/ra_hir_def/src/body | |
parent | ef02296b9fe2c2e42b9390a3a14ee860f08fd02c (diff) |
Move body queries to hir_def
Diffstat (limited to 'crates/ra_hir_def/src/body')
-rw-r--r-- | crates/ra_hir_def/src/body/scope.rs | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/crates/ra_hir_def/src/body/scope.rs b/crates/ra_hir_def/src/body/scope.rs index dd8d06d11..09a39e721 100644 --- a/crates/ra_hir_def/src/body/scope.rs +++ b/crates/ra_hir_def/src/body/scope.rs | |||
@@ -1,4 +1,5 @@ | |||
1 | //! FIXME: write short doc here | 1 | //! FIXME: write short doc here |
2 | use std::sync::Arc; | ||
2 | 3 | ||
3 | use hir_expand::name::Name; | 4 | use hir_expand::name::Name; |
4 | use ra_arena::{impl_arena_id, Arena, RawId}; | 5 | use ra_arena::{impl_arena_id, Arena, RawId}; |
@@ -6,7 +7,9 @@ use rustc_hash::FxHashMap; | |||
6 | 7 | ||
7 | use crate::{ | 8 | use crate::{ |
8 | body::Body, | 9 | body::Body, |
10 | db::DefDatabase2, | ||
9 | expr::{Expr, ExprId, Pat, PatId, Statement}, | 11 | expr::{Expr, ExprId, Pat, PatId, Statement}, |
12 | DefWithBodyId, | ||
10 | }; | 13 | }; |
11 | 14 | ||
12 | #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] | 15 | #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] |
@@ -42,7 +45,12 @@ pub struct ScopeData { | |||
42 | } | 45 | } |
43 | 46 | ||
44 | impl ExprScopes { | 47 | impl ExprScopes { |
45 | pub fn new(body: &Body) -> ExprScopes { | 48 | pub(crate) fn expr_scopes_query(db: &impl DefDatabase2, def: DefWithBodyId) -> Arc<ExprScopes> { |
49 | let body = db.body(def); | ||
50 | Arc::new(ExprScopes::new(&*body)) | ||
51 | } | ||
52 | |||
53 | fn new(body: &Body) -> ExprScopes { | ||
46 | let mut scopes = | 54 | let mut scopes = |
47 | ExprScopes { scopes: Arena::default(), scope_by_expr: FxHashMap::default() }; | 55 | ExprScopes { scopes: Arena::default(), scope_by_expr: FxHashMap::default() }; |
48 | let root = scopes.root_scope(); | 56 | let root = scopes.root_scope(); |