From 05a9d42f542c8eb876d06791579d948b2f571e04 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 31 Aug 2018 14:52:29 +0300 Subject: tweak extend selection --- crates/libeditor/src/scope/fn_scope.rs | 37 ++++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 11 deletions(-) (limited to 'crates/libeditor/src/scope') diff --git a/crates/libeditor/src/scope/fn_scope.rs b/crates/libeditor/src/scope/fn_scope.rs index 4b643237f..5c04e2f9b 100644 --- a/crates/libeditor/src/scope/fn_scope.rs +++ b/crates/libeditor/src/scope/fn_scope.rs @@ -140,6 +140,16 @@ fn compute_expr_scopes(expr: ast::Expr, scopes: &mut FnScopes, scope: ScopeId) { compute_block_scopes(block, scopes, scope); } }, + ast::Expr::BlockExpr(e) => { + if let Some(block) = e.block() { + compute_block_scopes(block, scopes, scope); + } + } + ast::Expr::LoopExpr(e) => { + if let Some(block) = e.loop_body() { + compute_block_scopes(block, scopes, scope); + } + } ast::Expr::WhileExpr(e) => { let cond_scope = e.condition().and_then(|cond| { compute_cond_scopes(cond, scopes, scope) @@ -147,11 +157,6 @@ fn compute_expr_scopes(expr: ast::Expr, scopes: &mut FnScopes, scope: ScopeId) { if let Some(block) = e.loop_body() { compute_block_scopes(block, scopes, cond_scope.unwrap_or(scope)); } - }, - ast::Expr::BlockExpr(e) => { - if let Some(block) = e.block() { - compute_block_scopes(block, scopes, scope); - } } ast::Expr::ForExpr(e) => { if let Some(expr) = e.iterable() { @@ -165,7 +170,7 @@ fn compute_expr_scopes(expr: ast::Expr, scopes: &mut FnScopes, scope: ScopeId) { if let Some(block) = e.loop_body() { compute_block_scopes(block, scopes, scope); } - }, + } ast::Expr::LambdaExpr(e) => { let mut scope = scopes.new_scope(scope); scopes.add_params_bindings(scope, e.param_list()); @@ -180,11 +185,7 @@ fn compute_expr_scopes(expr: ast::Expr, scopes: &mut FnScopes, scope: ScopeId) { .chain(e.expr()) .for_each(|expr| compute_expr_scopes(expr, scopes, scope)); } - ast::Expr::LoopExpr(e) => { - if let Some(block) = e.loop_body() { - compute_block_scopes(block, scopes, scope); - } - } + _ => { expr.syntax().children() .filter_map(ast::Expr::cast) @@ -273,4 +274,18 @@ mod tests { &["x"], ); } + + // #[test] + // fn test_match() { + // do_check(r" + // fn quux() { + // match () { + // Some(x) => { + // <|> + // } + // }; + // }", + // &["x"], + // ); + // } } -- cgit v1.2.3