aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_def/src/body/scope.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir_def/src/body/scope.rs')
-rw-r--r--crates/ra_hir_def/src/body/scope.rs10
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
2use std::sync::Arc;
2 3
3use hir_expand::name::Name; 4use hir_expand::name::Name;
4use ra_arena::{impl_arena_id, Arena, RawId}; 5use ra_arena::{impl_arena_id, Arena, RawId};
@@ -6,7 +7,9 @@ use rustc_hash::FxHashMap;
6 7
7use crate::{ 8use 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
44impl ExprScopes { 47impl 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();