diff options
Diffstat (limited to 'crates/ra_hir/src/function.rs')
-rw-r--r-- | crates/ra_hir/src/function.rs | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/crates/ra_hir/src/function.rs b/crates/ra_hir/src/function.rs index 75ef308ae..4dbdf81d8 100644 --- a/crates/ra_hir/src/function.rs +++ b/crates/ra_hir/src/function.rs | |||
@@ -11,9 +11,9 @@ use ra_syntax::{ | |||
11 | ast::{self, AstNode, DocCommentsOwner, NameOwner}, | 11 | ast::{self, AstNode, DocCommentsOwner, NameOwner}, |
12 | }; | 12 | }; |
13 | 13 | ||
14 | use crate::{DefId, DefKind, HirDatabase, ty::InferenceResult, Module, Crate, impl_block::ImplBlock}; | 14 | use crate::{DefId, DefKind, HirDatabase, ty::InferenceResult, Module, Crate, impl_block::ImplBlock, expr::{Body, BodySyntaxMapping}}; |
15 | 15 | ||
16 | pub use self::scope::FnScopes; | 16 | pub use self::scope::{FnScopes, ScopesWithSyntaxMapping}; |
17 | 17 | ||
18 | #[derive(Debug, Clone, PartialEq, Eq)] | 18 | #[derive(Debug, Clone, PartialEq, Eq)] |
19 | pub struct Function { | 19 | pub struct Function { |
@@ -36,8 +36,21 @@ impl Function { | |||
36 | ast::FnDef::cast(syntax.borrowed()).unwrap().owned() | 36 | ast::FnDef::cast(syntax.borrowed()).unwrap().owned() |
37 | } | 37 | } |
38 | 38 | ||
39 | pub fn scopes(&self, db: &impl HirDatabase) -> Arc<FnScopes> { | 39 | pub fn body(&self, db: &impl HirDatabase) -> Cancelable<Arc<Body>> { |
40 | db.fn_scopes(self.def_id) | 40 | db.body_hir(self.def_id) |
41 | } | ||
42 | |||
43 | pub fn body_syntax_mapping(&self, db: &impl HirDatabase) -> Cancelable<Arc<BodySyntaxMapping>> { | ||
44 | db.body_syntax_mapping(self.def_id) | ||
45 | } | ||
46 | |||
47 | pub fn scopes(&self, db: &impl HirDatabase) -> Cancelable<ScopesWithSyntaxMapping> { | ||
48 | let scopes = db.fn_scopes(self.def_id)?; | ||
49 | let syntax_mapping = db.body_syntax_mapping(self.def_id)?; | ||
50 | Ok(ScopesWithSyntaxMapping { | ||
51 | scopes, | ||
52 | syntax_mapping, | ||
53 | }) | ||
41 | } | 54 | } |
42 | 55 | ||
43 | pub fn signature_info(&self, db: &impl HirDatabase) -> Option<FnSignatureInfo> { | 56 | pub fn signature_info(&self, db: &impl HirDatabase) -> Option<FnSignatureInfo> { |