diff options
Diffstat (limited to 'crates/ra_hir/src/expr/scope.rs')
-rw-r--r-- | crates/ra_hir/src/expr/scope.rs | 15 |
1 files changed, 13 insertions, 2 deletions
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::{ | |||
9 | }; | 9 | }; |
10 | use ra_arena::{Arena, RawId, impl_arena_id}; | 10 | use ra_arena::{Arena, RawId, impl_arena_id}; |
11 | 11 | ||
12 | use crate::{Name, AsName, expr::{PatId, ExprId, Pat, Expr, Body, Statement, BodySyntaxMapping}}; | 12 | use crate::{ |
13 | Name, AsName, Function, | ||
14 | expr::{PatId, ExprId, Pat, Expr, Body, Statement, BodySyntaxMapping}, | ||
15 | db::HirDatabase, | ||
16 | }; | ||
13 | 17 | ||
14 | #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] | 18 | #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] |
15 | pub struct ScopeId(RawId); | 19 | pub struct ScopeId(RawId); |
@@ -35,7 +39,14 @@ pub struct ScopeData { | |||
35 | } | 39 | } |
36 | 40 | ||
37 | impl ExprScopes { | 41 | impl ExprScopes { |
38 | pub(crate) fn new(body: Arc<Body>) -> ExprScopes { | 42 | // TODO: This should take something more general than Function |
43 | pub(crate) fn expr_scopes_query(db: &impl HirDatabase, function: Function) -> Arc<ExprScopes> { | ||
44 | let body = db.body_hir(function); | ||
45 | let res = ExprScopes::new(body); | ||
46 | Arc::new(res) | ||
47 | } | ||
48 | |||
49 | fn new(body: Arc<Body>) -> ExprScopes { | ||
39 | let mut scopes = ExprScopes { | 50 | let mut scopes = ExprScopes { |
40 | body: body.clone(), | 51 | body: body.clone(), |
41 | scopes: Arena::default(), | 52 | scopes: Arena::default(), |