diff options
author | Aleksey Kladov <[email protected]> | 2018-12-22 08:01:03 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2018-12-22 08:01:03 +0000 |
commit | 49e746b010bbba408e9e4b1a40d89642e4cb84c6 (patch) | |
tree | d2d46b55e76a7a9af91c6502d70c5523b0a89b1a /crates/ra_hir/src/source_binder.rs | |
parent | 4e4ca27eabac6a9c97dc07baf9a067efdfc63384 (diff) |
completion uses hir scopes
Diffstat (limited to 'crates/ra_hir/src/source_binder.rs')
-rw-r--r-- | crates/ra_hir/src/source_binder.rs | 12 |
1 files changed, 11 insertions, 1 deletions
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( |