diff options
Diffstat (limited to 'crates/ra_hir/src/source_binder.rs')
-rw-r--r-- | crates/ra_hir/src/source_binder.rs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/crates/ra_hir/src/source_binder.rs b/crates/ra_hir/src/source_binder.rs index 85bd84469..551f44d4e 100644 --- a/crates/ra_hir/src/source_binder.rs +++ b/crates/ra_hir/src/source_binder.rs | |||
@@ -87,6 +87,20 @@ fn module_from_source( | |||
87 | Ok(Some(Module::new(db, source_root_id, module_id)?)) | 87 | Ok(Some(Module::new(db, source_root_id, module_id)?)) |
88 | } | 88 | } |
89 | 89 | ||
90 | pub fn function_from_position( | ||
91 | db: &impl HirDatabase, | ||
92 | position: FilePosition, | ||
93 | ) -> Cancelable<Option<Function>> { | ||
94 | let file = db.source_file(position.file_id); | ||
95 | let fn_def = if let Some(f) = find_node_at_offset::<ast::FnDef>(file.syntax(), position.offset) | ||
96 | { | ||
97 | f | ||
98 | } else { | ||
99 | return Ok(None); | ||
100 | }; | ||
101 | function_from_source(db, position.file_id, fn_def) | ||
102 | } | ||
103 | |||
90 | pub fn function_from_source( | 104 | pub fn function_from_source( |
91 | db: &impl HirDatabase, | 105 | db: &impl HirDatabase, |
92 | file_id: FileId, | 106 | file_id: FileId, |