aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
Diffstat (limited to 'crates')
-rw-r--r--crates/ra_hir/src/source_binder.rs16
1 files changed, 3 insertions, 13 deletions
diff --git a/crates/ra_hir/src/source_binder.rs b/crates/ra_hir/src/source_binder.rs
index 5bb6d64ff..67bf2de89 100644
--- a/crates/ra_hir/src/source_binder.rs
+++ b/crates/ra_hir/src/source_binder.rs
@@ -12,6 +12,7 @@ use ra_syntax::{
12 SyntaxNode, AstPtr, TextUnit, 12 SyntaxNode, AstPtr, TextUnit,
13 ast::{self, AstNode, NameOwner}, 13 ast::{self, AstNode, NameOwner},
14 algo::find_node_at_offset, 14 algo::find_node_at_offset,
15 SyntaxKind::*,
15}; 16};
16 17
17use crate::{ 18use crate::{
@@ -90,17 +91,6 @@ fn module_from_source(
90 ) 91 )
91} 92}
92 93
93fn function_from_source(
94 db: &impl HirDatabase,
95 file_id: FileId,
96 fn_def: &ast::FnDef,
97) -> Option<Function> {
98 let module = module_from_child_node(db, file_id, fn_def.syntax())?;
99 let file_id = file_id.into();
100 let ctx = LocationCtx::new(db, module, file_id);
101 Some(Function { id: ctx.to_def(fn_def) })
102}
103
104pub fn struct_from_module( 94pub fn struct_from_module(
105 db: &impl HirDatabase, 95 db: &impl HirDatabase,
106 module: Module, 96 module: Module,
@@ -168,8 +158,8 @@ fn try_get_resolver_for_node(
168 } else if let Some(e) = ast::EnumDef::cast(node) { 158 } else if let Some(e) = ast::EnumDef::cast(node) {
169 let module = module_from_child_node(db, file_id, e.syntax())?; 159 let module = module_from_child_node(db, file_id, e.syntax())?;
170 Some(enum_from_module(db, module, e).resolver(db)) 160 Some(enum_from_module(db, module, e).resolver(db))
171 } else if let Some(f) = ast::FnDef::cast(node) { 161 } else if node.kind() == FN_DEF || node.kind() == CONST_DEF || node.kind() == STATIC_DEF {
172 function_from_source(db, file_id, f).map(|f| f.resolver(db)) 162 Some(def_with_body_from_child_node(db, file_id, node)?.resolver(db))
173 } else { 163 } else {
174 // FIXME add missing cases 164 // FIXME add missing cases
175 None 165 None