aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/source_binder.rs
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2019-01-24 12:28:50 +0000
committerAleksey Kladov <[email protected]>2019-01-24 12:28:50 +0000
commitec7ed054e06cb2e23fd3911932766b32014c8fa1 (patch)
treec06ed85f44afc261c483ff7b87e1a7aa33c198a1 /crates/ra_hir/src/source_binder.rs
parentf1959bbae0cf2f99e63d074278cec165c274b4e5 (diff)
Functions use new id scheme
Diffstat (limited to 'crates/ra_hir/src/source_binder.rs')
-rw-r--r--crates/ra_hir/src/source_binder.rs19
1 files changed, 4 insertions, 15 deletions
diff --git a/crates/ra_hir/src/source_binder.rs b/crates/ra_hir/src/source_binder.rs
index c3bd31d6b..d1bf163d1 100644
--- a/crates/ra_hir/src/source_binder.rs
+++ b/crates/ra_hir/src/source_binder.rs
@@ -14,7 +14,7 @@ use ra_syntax::{
14 14
15use crate::{ 15use crate::{
16 HirDatabase, Function, SourceItemId, ModuleDef, 16 HirDatabase, Function, SourceItemId, ModuleDef,
17 DefKind, DefLoc, AsName, Module, 17 AsName, Module,
18}; 18};
19 19
20/// Locates the module by `FileId`. Picks topmost module in the file. 20/// Locates the module by `FileId`. Picks topmost module in the file.
@@ -105,29 +105,18 @@ pub fn function_from_source(
105 fn_def: &ast::FnDef, 105 fn_def: &ast::FnDef,
106) -> Option<Function> { 106) -> Option<Function> {
107 let module = module_from_child_node(db, file_id, fn_def.syntax())?; 107 let module = module_from_child_node(db, file_id, fn_def.syntax())?;
108 let res = function_from_module(db, &module, fn_def); 108 let res = function_from_module(db, module, fn_def);
109 Some(res) 109 Some(res)
110} 110}
111 111
112pub fn function_from_module( 112pub fn function_from_module(
113 db: &impl HirDatabase, 113 db: &impl HirDatabase,
114 module: &Module, 114 module: Module,
115 fn_def: &ast::FnDef, 115 fn_def: &ast::FnDef,
116) -> Function { 116) -> Function {
117 let (file_id, _) = module.definition_source(db); 117 let (file_id, _) = module.definition_source(db);
118 let file_id = file_id.into(); 118 let file_id = file_id.into();
119 let file_items = db.file_items(file_id); 119 Function::from_ast(db, module, file_id, fn_def)
120 let item_id = file_items.id_of(file_id, fn_def.syntax());
121 let source_item_id = SourceItemId {
122 file_id,
123 item_id: Some(item_id),
124 };
125 let def_loc = DefLoc {
126 module: module.clone(),
127 kind: DefKind::Function,
128 source_item_id,
129 };
130 Function::new(def_loc.id(db))
131} 120}
132 121
133pub fn function_from_child_node( 122pub fn function_from_child_node(