aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/expr
diff options
context:
space:
mode:
authorFlorian Diebold <[email protected]>2019-01-19 18:57:43 +0000
committerFlorian Diebold <[email protected]>2019-01-30 20:39:34 +0000
commit1acff307fe2e20f0c2291fd24b08fba6fa39e5ee (patch)
tree18046068a9d7bb72747bbabfc22d1121fea1604a /crates/ra_hir/src/expr
parent65864d85f992300bad3913438a542af1bd736a24 (diff)
Move expr_scopes query to its module
Diffstat (limited to 'crates/ra_hir/src/expr')
-rw-r--r--crates/ra_hir/src/expr/scope.rs15
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};
10use ra_arena::{Arena, RawId, impl_arena_id}; 10use ra_arena::{Arena, RawId, impl_arena_id};
11 11
12use crate::{Name, AsName, expr::{PatId, ExprId, Pat, Expr, Body, Statement, BodySyntaxMapping}}; 12use 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)]
15pub struct ScopeId(RawId); 19pub struct ScopeId(RawId);
@@ -35,7 +39,14 @@ pub struct ScopeData {
35} 39}
36 40
37impl ExprScopes { 41impl 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(),