diff options
-rw-r--r-- | crates/ra_hir/src/db.rs | 2 | ||||
-rw-r--r-- | crates/ra_hir/src/expr/scope.rs | 15 | ||||
-rw-r--r-- | crates/ra_hir/src/query_definitions.rs | 11 |
3 files changed, 17 insertions, 11 deletions
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<HirInterner> { | |||
27 | #[salsa::invoke(crate::macros::expand_macro_invocation)] | 27 | #[salsa::invoke(crate::macros::expand_macro_invocation)] |
28 | fn expand_macro_invocation(&self, invoc: MacroCallId) -> Option<Arc<MacroExpansion>>; | 28 | fn expand_macro_invocation(&self, invoc: MacroCallId) -> Option<Arc<MacroExpansion>>; |
29 | 29 | ||
30 | #[salsa::invoke(query_definitions::expr_scopes)] | 30 | #[salsa::invoke(ExprScopes::expr_scopes_query)] |
31 | fn expr_scopes(&self, func: Function) -> Arc<ExprScopes>; | 31 | fn expr_scopes(&self, func: Function) -> Arc<ExprScopes>; |
32 | 32 | ||
33 | #[salsa::invoke(crate::adt::StructData::struct_data_query)] | 33 | #[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::{ | |||
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(), |
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 @@ | |||
1 | use std::sync::Arc; | 1 | use std::sync::Arc; |
2 | 2 | ||
3 | use ra_syntax::{SyntaxNode, TreeArc}; | 3 | use ra_syntax::{ |
4 | SyntaxNode, TreeArc, | ||
5 | }; | ||
4 | 6 | ||
5 | use crate::{ | 7 | use crate::{ |
6 | SourceFileItems, SourceItemId, HirFileId, | 8 | SourceFileItems, SourceItemId, HirFileId, |
7 | Function, ExprScopes, | ||
8 | db::HirDatabase, | 9 | db::HirDatabase, |
9 | }; | 10 | }; |
10 | 11 | ||
11 | pub(super) fn expr_scopes(db: &impl HirDatabase, func: Function) -> Arc<ExprScopes> { | ||
12 | let body = db.body_hir(func); | ||
13 | let res = ExprScopes::new(body); | ||
14 | Arc::new(res) | ||
15 | } | ||
16 | |||
17 | pub(super) fn file_items(db: &impl HirDatabase, file_id: HirFileId) -> Arc<SourceFileItems> { | 12 | pub(super) fn file_items(db: &impl HirDatabase, file_id: HirFileId) -> Arc<SourceFileItems> { |
18 | let source_file = db.hir_parse(file_id); | 13 | let source_file = db.hir_parse(file_id); |
19 | let res = SourceFileItems::new(file_id, &source_file); | 14 | let res = SourceFileItems::new(file_id, &source_file); |