diff options
author | Aleksey Kladov <[email protected]> | 2018-08-31 12:52:29 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2018-08-31 12:52:29 +0100 |
commit | 05a9d42f542c8eb876d06791579d948b2f571e04 (patch) | |
tree | 33b5962641f57d65b8545b477885fcfadbbe801c /crates/libeditor/src/scope | |
parent | 8fc7f438c4347e027deda5cda4bcd5e560610bb7 (diff) |
tweak extend selection
Diffstat (limited to 'crates/libeditor/src/scope')
-rw-r--r-- | crates/libeditor/src/scope/fn_scope.rs | 37 |
1 files changed, 26 insertions, 11 deletions
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) { | |||
140 | compute_block_scopes(block, scopes, scope); | 140 | compute_block_scopes(block, scopes, scope); |
141 | } | 141 | } |
142 | }, | 142 | }, |
143 | ast::Expr::BlockExpr(e) => { | ||
144 | if let Some(block) = e.block() { | ||
145 | compute_block_scopes(block, scopes, scope); | ||
146 | } | ||
147 | } | ||
148 | ast::Expr::LoopExpr(e) => { | ||
149 | if let Some(block) = e.loop_body() { | ||
150 | compute_block_scopes(block, scopes, scope); | ||
151 | } | ||
152 | } | ||
143 | ast::Expr::WhileExpr(e) => { | 153 | ast::Expr::WhileExpr(e) => { |
144 | let cond_scope = e.condition().and_then(|cond| { | 154 | let cond_scope = e.condition().and_then(|cond| { |
145 | compute_cond_scopes(cond, scopes, scope) | 155 | compute_cond_scopes(cond, scopes, scope) |
@@ -147,11 +157,6 @@ fn compute_expr_scopes(expr: ast::Expr, scopes: &mut FnScopes, scope: ScopeId) { | |||
147 | if let Some(block) = e.loop_body() { | 157 | if let Some(block) = e.loop_body() { |
148 | compute_block_scopes(block, scopes, cond_scope.unwrap_or(scope)); | 158 | compute_block_scopes(block, scopes, cond_scope.unwrap_or(scope)); |
149 | } | 159 | } |
150 | }, | ||
151 | ast::Expr::BlockExpr(e) => { | ||
152 | if let Some(block) = e.block() { | ||
153 | compute_block_scopes(block, scopes, scope); | ||
154 | } | ||
155 | } | 160 | } |
156 | ast::Expr::ForExpr(e) => { | 161 | ast::Expr::ForExpr(e) => { |
157 | if let Some(expr) = e.iterable() { | 162 | if let Some(expr) = e.iterable() { |
@@ -165,7 +170,7 @@ fn compute_expr_scopes(expr: ast::Expr, scopes: &mut FnScopes, scope: ScopeId) { | |||
165 | if let Some(block) = e.loop_body() { | 170 | if let Some(block) = e.loop_body() { |
166 | compute_block_scopes(block, scopes, scope); | 171 | compute_block_scopes(block, scopes, scope); |
167 | } | 172 | } |
168 | }, | 173 | } |
169 | ast::Expr::LambdaExpr(e) => { | 174 | ast::Expr::LambdaExpr(e) => { |
170 | let mut scope = scopes.new_scope(scope); | 175 | let mut scope = scopes.new_scope(scope); |
171 | scopes.add_params_bindings(scope, e.param_list()); | 176 | scopes.add_params_bindings(scope, e.param_list()); |
@@ -180,11 +185,7 @@ fn compute_expr_scopes(expr: ast::Expr, scopes: &mut FnScopes, scope: ScopeId) { | |||
180 | .chain(e.expr()) | 185 | .chain(e.expr()) |
181 | .for_each(|expr| compute_expr_scopes(expr, scopes, scope)); | 186 | .for_each(|expr| compute_expr_scopes(expr, scopes, scope)); |
182 | } | 187 | } |
183 | ast::Expr::LoopExpr(e) => { | 188 | |
184 | if let Some(block) = e.loop_body() { | ||
185 | compute_block_scopes(block, scopes, scope); | ||
186 | } | ||
187 | } | ||
188 | _ => { | 189 | _ => { |
189 | expr.syntax().children() | 190 | expr.syntax().children() |
190 | .filter_map(ast::Expr::cast) | 191 | .filter_map(ast::Expr::cast) |
@@ -273,4 +274,18 @@ mod tests { | |||
273 | &["x"], | 274 | &["x"], |
274 | ); | 275 | ); |
275 | } | 276 | } |
277 | |||
278 | // #[test] | ||
279 | // fn test_match() { | ||
280 | // do_check(r" | ||
281 | // fn quux() { | ||
282 | // match () { | ||
283 | // Some(x) => { | ||
284 | // <|> | ||
285 | // } | ||
286 | // }; | ||
287 | // }", | ||
288 | // &["x"], | ||
289 | // ); | ||
290 | // } | ||
276 | } | 291 | } |