aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/source_binder.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir/src/source_binder.rs')
-rw-r--r--crates/ra_hir/src/source_binder.rs12
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
81pub 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
92pub fn function_from_child_node( 102pub fn function_from_child_node(