aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/source_binder.rs
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2019-09-02 19:23:19 +0100
committerAleksey Kladov <[email protected]>2019-09-02 19:23:19 +0100
commit5e3f291195b580580be7ce5622f54ebca75fb9f0 (patch)
tree772693eb44bde1fac1b9292456e1fa6e056bdb1f /crates/ra_hir/src/source_binder.rs
parentdcf8e895038a7677711b8168ee12e1d47f6018bc (diff)
fix hir for new block syntax
Diffstat (limited to 'crates/ra_hir/src/source_binder.rs')
-rw-r--r--crates/ra_hir/src/source_binder.rs14
1 files changed, 10 insertions, 4 deletions
diff --git a/crates/ra_hir/src/source_binder.rs b/crates/ra_hir/src/source_binder.rs
index 43aec201a..e5f4d11a6 100644
--- a/crates/ra_hir/src/source_binder.rs
+++ b/crates/ra_hir/src/source_binder.rs
@@ -462,8 +462,8 @@ fn scope_for(
462 node: &SyntaxNode, 462 node: &SyntaxNode,
463) -> Option<ScopeId> { 463) -> Option<ScopeId> {
464 node.ancestors() 464 node.ancestors()
465 .map(|it| SyntaxNodePtr::new(&it)) 465 .filter_map(ast::Expr::cast)
466 .filter_map(|ptr| source_map.syntax_expr(ptr)) 466 .filter_map(|it| source_map.node_expr(&it))
467 .find_map(|it| scopes.scope_for(it)) 467 .find_map(|it| scopes.scope_for(it))
468} 468}
469 469
@@ -475,7 +475,10 @@ fn scope_for_offset(
475 scopes 475 scopes
476 .scope_by_expr() 476 .scope_by_expr()
477 .iter() 477 .iter()
478 .filter_map(|(id, scope)| Some((source_map.expr_syntax(*id)?, scope))) 478 .filter_map(|(id, scope)| {
479 let ast_ptr = source_map.expr_syntax(*id)?.a()?;
480 Some((ast_ptr.syntax_node_ptr(), scope))
481 })
479 // find containing scope 482 // find containing scope
480 .min_by_key(|(ptr, _scope)| { 483 .min_by_key(|(ptr, _scope)| {
481 (!(ptr.range().start() <= offset && offset <= ptr.range().end()), ptr.range().len()) 484 (!(ptr.range().start() <= offset && offset <= ptr.range().end()), ptr.range().len())
@@ -495,7 +498,10 @@ fn adjust(
495 let child_scopes = scopes 498 let child_scopes = scopes
496 .scope_by_expr() 499 .scope_by_expr()
497 .iter() 500 .iter()
498 .filter_map(|(id, scope)| Some((source_map.expr_syntax(*id)?, scope))) 501 .filter_map(|(id, scope)| {
502 let ast_ptr = source_map.expr_syntax(*id)?.a()?;
503 Some((ast_ptr.syntax_node_ptr(), scope))
504 })
499 .map(|(ptr, scope)| (ptr.range(), scope)) 505 .map(|(ptr, scope)| (ptr.range(), scope))
500 .filter(|(range, _)| range.start() <= offset && range.is_subrange(&r) && *range != r); 506 .filter(|(range, _)| range.start() <= offset && range.is_subrange(&r) && *range != r);
501 507