From 5e3f291195b580580be7ce5622f54ebca75fb9f0 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Mon, 2 Sep 2019 21:23:19 +0300 Subject: fix hir for new block syntax --- crates/ra_hir/src/source_binder.rs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'crates/ra_hir/src/source_binder.rs') 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( node: &SyntaxNode, ) -> Option { node.ancestors() - .map(|it| SyntaxNodePtr::new(&it)) - .filter_map(|ptr| source_map.syntax_expr(ptr)) + .filter_map(ast::Expr::cast) + .filter_map(|it| source_map.node_expr(&it)) .find_map(|it| scopes.scope_for(it)) } @@ -475,7 +475,10 @@ fn scope_for_offset( scopes .scope_by_expr() .iter() - .filter_map(|(id, scope)| Some((source_map.expr_syntax(*id)?, scope))) + .filter_map(|(id, scope)| { + let ast_ptr = source_map.expr_syntax(*id)?.a()?; + Some((ast_ptr.syntax_node_ptr(), scope)) + }) // find containing scope .min_by_key(|(ptr, _scope)| { (!(ptr.range().start() <= offset && offset <= ptr.range().end()), ptr.range().len()) @@ -495,7 +498,10 @@ fn adjust( let child_scopes = scopes .scope_by_expr() .iter() - .filter_map(|(id, scope)| Some((source_map.expr_syntax(*id)?, scope))) + .filter_map(|(id, scope)| { + let ast_ptr = source_map.expr_syntax(*id)?.a()?; + Some((ast_ptr.syntax_node_ptr(), scope)) + }) .map(|(ptr, scope)| (ptr.range(), scope)) .filter(|(range, _)| range.start() <= offset && range.is_subrange(&r) && *range != r); -- cgit v1.2.3