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.rs11
1 files changed, 7 insertions, 4 deletions
diff --git a/crates/ra_hir/src/source_binder.rs b/crates/ra_hir/src/source_binder.rs
index 0c16ccc24..ce2a0f2e8 100644
--- a/crates/ra_hir/src/source_binder.rs
+++ b/crates/ra_hir/src/source_binder.rs
@@ -20,7 +20,7 @@ use crate::{
20 20
21/// Locates the module by `FileId`. Picks topmost module in the file. 21/// Locates the module by `FileId`. Picks topmost module in the file.
22pub fn module_from_file_id(db: &impl HirDatabase, file_id: FileId) -> Cancelable<Option<Module>> { 22pub fn module_from_file_id(db: &impl HirDatabase, file_id: FileId) -> Cancelable<Option<Module>> {
23 let module_source = ModuleSource::new_file(db, file_id); 23 let module_source = ModuleSource::new_file(file_id);
24 module_from_source(db, module_source) 24 module_from_source(db, module_source)
25} 25}
26 26
@@ -32,7 +32,7 @@ pub fn module_from_position(
32 let file = db.source_file(position.file_id); 32 let file = db.source_file(position.file_id);
33 let module_source = match find_node_at_offset::<ast::Module>(file.syntax(), position.offset) { 33 let module_source = match find_node_at_offset::<ast::Module>(file.syntax(), position.offset) {
34 Some(m) if !m.has_semi() => ModuleSource::new_inline(db, position.file_id, m), 34 Some(m) if !m.has_semi() => ModuleSource::new_inline(db, position.file_id, m),
35 _ => ModuleSource::new_file(db, position.file_id), 35 _ => ModuleSource::new_file(position.file_id),
36 }; 36 };
37 module_from_source(db, module_source) 37 module_from_source(db, module_source)
38} 38}
@@ -50,7 +50,7 @@ pub fn module_from_child_node(
50 { 50 {
51 ModuleSource::new_inline(db, file_id, m) 51 ModuleSource::new_inline(db, file_id, m)
52 } else { 52 } else {
53 ModuleSource::new_file(db, file_id) 53 ModuleSource::new_file(file_id)
54 }; 54 };
55 module_from_source(db, module_source) 55 module_from_source(db, module_source)
56} 56}
@@ -76,7 +76,10 @@ pub fn function_from_source(
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 file_items = db.file_items(file_id); 77 let file_items = db.file_items(file_id);
78 let item_id = file_items.id_of(file_id, fn_def.syntax()); 78 let item_id = file_items.id_of(file_id, fn_def.syntax());
79 let source_item_id = SourceItemId { file_id, item_id }; 79 let source_item_id = SourceItemId {
80 file_id,
81 item_id: Some(item_id),
82 };
80 let def_loc = DefLoc { 83 let def_loc = DefLoc {
81 kind: DefKind::Function, 84 kind: DefKind::Function,
82 source_root_id: module.source_root_id, 85 source_root_id: module.source_root_id,