diff options
Diffstat (limited to 'crates/ra_hir')
-rw-r--r-- | crates/ra_hir/src/function.rs | 2 | ||||
-rw-r--r-- | crates/ra_hir/src/function/scope.rs | 2 | ||||
-rw-r--r-- | crates/ra_hir/src/source_binder.rs | 12 |
3 files changed, 13 insertions, 3 deletions
diff --git a/crates/ra_hir/src/function.rs b/crates/ra_hir/src/function.rs index 5187dc051..2925beb16 100644 --- a/crates/ra_hir/src/function.rs +++ b/crates/ra_hir/src/function.rs | |||
@@ -27,7 +27,7 @@ impl Function { | |||
27 | Function { fn_id } | 27 | Function { fn_id } |
28 | } | 28 | } |
29 | 29 | ||
30 | pub fn scope(&self, db: &impl HirDatabase) -> Arc<FnScopes> { | 30 | pub fn scopes(&self, db: &impl HirDatabase) -> Arc<FnScopes> { |
31 | db.fn_scopes(self.fn_id) | 31 | db.fn_scopes(self.fn_id) |
32 | } | 32 | } |
33 | 33 | ||
diff --git a/crates/ra_hir/src/function/scope.rs b/crates/ra_hir/src/function/scope.rs index 77be25f1a..a1a580979 100644 --- a/crates/ra_hir/src/function/scope.rs +++ b/crates/ra_hir/src/function/scope.rs | |||
@@ -33,7 +33,7 @@ pub struct ScopeData { | |||
33 | } | 33 | } |
34 | 34 | ||
35 | impl FnScopes { | 35 | impl FnScopes { |
36 | pub fn new(fn_def: ast::FnDef) -> FnScopes { | 36 | pub(crate) fn new(fn_def: ast::FnDef) -> FnScopes { |
37 | let mut scopes = FnScopes { | 37 | let mut scopes = FnScopes { |
38 | self_param: fn_def | 38 | self_param: fn_def |
39 | .param_list() | 39 | .param_list() |
diff --git a/crates/ra_hir/src/source_binder.rs b/crates/ra_hir/src/source_binder.rs index ce2a0f2e8..a0165aef2 100644 --- a/crates/ra_hir/src/source_binder.rs +++ b/crates/ra_hir/src/source_binder.rs | |||
@@ -74,6 +74,16 @@ pub fn function_from_source( | |||
74 | fn_def: ast::FnDef, | 74 | fn_def: ast::FnDef, |
75 | ) -> Cancelable<Option<Function>> { | 75 | ) -> Cancelable<Option<Function>> { |
76 | let module = ctry!(module_from_child_node(db, file_id, fn_def.syntax())?); | 76 | let module = ctry!(module_from_child_node(db, file_id, fn_def.syntax())?); |
77 | let res = function_from_module(db, &module, fn_def); | ||
78 | Ok(Some(res)) | ||
79 | } | ||
80 | |||
81 | pub fn function_from_module( | ||
82 | db: &impl HirDatabase, | ||
83 | module: &Module, | ||
84 | fn_def: ast::FnDef, | ||
85 | ) -> Function { | ||
86 | let file_id = module.source().file_id(); | ||
77 | let file_items = db.file_items(file_id); | 87 | let file_items = db.file_items(file_id); |
78 | let item_id = file_items.id_of(file_id, fn_def.syntax()); | 88 | let item_id = file_items.id_of(file_id, fn_def.syntax()); |
79 | let source_item_id = SourceItemId { | 89 | let source_item_id = SourceItemId { |
@@ -86,7 +96,7 @@ pub fn function_from_source( | |||
86 | module_id: module.module_id, | 96 | module_id: module.module_id, |
87 | source_item_id, | 97 | source_item_id, |
88 | }; | 98 | }; |
89 | Ok(Some(Function::new(def_loc.id(db)))) | 99 | Function::new(def_loc.id(db)) |
90 | } | 100 | } |
91 | 101 | ||
92 | pub fn function_from_child_node( | 102 | pub fn function_from_child_node( |