diff options
Diffstat (limited to 'crates/ra_analysis/src/hir/function/mod.rs')
-rw-r--r-- | crates/ra_analysis/src/hir/function/mod.rs | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/crates/ra_analysis/src/hir/function/mod.rs b/crates/ra_analysis/src/hir/function/mod.rs index 86eee5e93..c8af6bc21 100644 --- a/crates/ra_analysis/src/hir/function/mod.rs +++ b/crates/ra_analysis/src/hir/function/mod.rs | |||
@@ -1,7 +1,10 @@ | |||
1 | pub(super) mod imp; | 1 | pub(super) mod imp; |
2 | mod scope; | 2 | mod scope; |
3 | 3 | ||
4 | use std::cmp::{max, min}; | 4 | use std::{ |
5 | cmp::{max, min}, | ||
6 | sync::Arc, | ||
7 | }; | ||
5 | 8 | ||
6 | use ra_syntax::{ | 9 | use ra_syntax::{ |
7 | ast::{self, AstNode, DocCommentsOwner, NameOwner}, | 10 | ast::{self, AstNode, DocCommentsOwner, NameOwner}, |
@@ -9,6 +12,7 @@ use ra_syntax::{ | |||
9 | }; | 12 | }; |
10 | 13 | ||
11 | use crate::{ | 14 | use crate::{ |
15 | hir::HirDatabase, | ||
12 | syntax_ptr::SyntaxPtr, FileId, | 16 | syntax_ptr::SyntaxPtr, FileId, |
13 | loc2id::IdDatabase, | 17 | loc2id::IdDatabase, |
14 | }; | 18 | }; |
@@ -23,6 +27,25 @@ impl FnId { | |||
23 | } | 27 | } |
24 | } | 28 | } |
25 | 29 | ||
30 | pub(crate) struct FunctionDescriptor { | ||
31 | fn_id: FnId, | ||
32 | } | ||
33 | |||
34 | impl FunctionDescriptor { | ||
35 | pub(crate) fn guess_from_source( | ||
36 | db: &impl HirDatabase, | ||
37 | file_id: FileId, | ||
38 | fn_def: ast::FnDef, | ||
39 | ) -> FunctionDescriptor { | ||
40 | let fn_id = FnId::get(db, file_id, fn_def); | ||
41 | FunctionDescriptor { fn_id } | ||
42 | } | ||
43 | |||
44 | pub(crate) fn scope(&self, db: &impl HirDatabase) -> Arc<FnScopes> { | ||
45 | db.fn_scopes(self.fn_id) | ||
46 | } | ||
47 | } | ||
48 | |||
26 | #[derive(Debug, Clone)] | 49 | #[derive(Debug, Clone)] |
27 | pub struct FnDescriptor { | 50 | pub struct FnDescriptor { |
28 | pub name: String, | 51 | pub name: String, |