diff options
author | Aleksey Kladov <[email protected]> | 2019-04-13 07:38:37 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-04-13 07:38:37 +0100 |
commit | d88269bc2d36d163eef5173912c40d5b6eee3847 (patch) | |
tree | 482bdca882f4c61861735a344e4dd2f48887c5cc | |
parent | 17a0e228833de16ed7e8718ba177dceeec4abfb2 (diff) |
generalize
-rw-r--r-- | crates/ra_hir/src/source_binder.rs | 22 |
1 files changed, 7 insertions, 15 deletions
diff --git a/crates/ra_hir/src/source_binder.rs b/crates/ra_hir/src/source_binder.rs index 649c5b684..5bb6d64ff 100644 --- a/crates/ra_hir/src/source_binder.rs +++ b/crates/ra_hir/src/source_binder.rs | |||
@@ -139,21 +139,13 @@ fn resolver_for_node( | |||
139 | node.ancestors() | 139 | node.ancestors() |
140 | .find_map(|node| { | 140 | .find_map(|node| { |
141 | if ast::Expr::cast(node).is_some() || ast::Block::cast(node).is_some() { | 141 | if ast::Expr::cast(node).is_some() || ast::Block::cast(node).is_some() { |
142 | if let Some(func) = node | 142 | let def = def_with_body_from_child_node(db, file_id, node)?; |
143 | .ancestors() | 143 | let scopes = def.scopes(db); |
144 | .find_map(ast::FnDef::cast) | 144 | let scope = match offset { |
145 | .and_then(|it| function_from_source(db, file_id, it)) | 145 | None => scopes.scope_for(&node), |
146 | { | 146 | Some(offset) => scopes.scope_for_offset(offset), |
147 | let scopes = func.scopes(db); | 147 | }; |
148 | let scope = match offset { | 148 | Some(expr::resolver_for_scope(def.body(db), db, scope)) |
149 | None => scopes.scope_for(&node), | ||
150 | Some(offset) => scopes.scope_for_offset(offset), | ||
151 | }; | ||
152 | Some(expr::resolver_for_scope(func.body(db), db, scope)) | ||
153 | } else { | ||
154 | // FIXME const/static/array length | ||
155 | None | ||
156 | } | ||
157 | } else { | 149 | } else { |
158 | try_get_resolver_for_node(db, file_id, node) | 150 | try_get_resolver_for_node(db, file_id, node) |
159 | } | 151 | } |