aboutsummaryrefslogtreecommitdiff
path: root/crates/libeditor
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2018-08-27 20:03:19 +0100
committerAleksey Kladov <[email protected]>2018-08-27 20:03:19 +0100
commit57518153147ad53639f16cc940d219dc582c550a (patch)
tree5c1708cf8ea4e2344c8dfc96af82343be0b0271c /crates/libeditor
parentb79c8b6d8a3b38c94de992a54ffb9055c1ad6f31 (diff)
Add runnables
Diffstat (limited to 'crates/libeditor')
-rw-r--r--crates/libeditor/src/scope.rs14
-rw-r--r--crates/libeditor/tests/test.rs8
2 files changed, 21 insertions, 1 deletions
diff --git a/crates/libeditor/src/scope.rs b/crates/libeditor/src/scope.rs
index 76104b2cf..3d398a74c 100644
--- a/crates/libeditor/src/scope.rs
+++ b/crates/libeditor/src/scope.rs
@@ -61,7 +61,19 @@ fn compute_expr_scopes(expr: ast::Expr, scopes: &mut FnScopes, scope: ScopeId) {
61 compute_block_scopes(block, scopes, scope); 61 compute_block_scopes(block, scopes, scope);
62 } 62 }
63 } 63 }
64 // ForExpr(e) => TODO, 64 ast::Expr::ForExpr(e) => {
65 if let Some(expr) = e.iterable() {
66 compute_expr_scopes(expr, scopes, scope);
67 }
68 let mut scope = scope;
69 if let Some(pat) = e.pat() {
70 scope = scopes.new_scope(scope);
71 scopes.add_bindings(scope, pat);
72 }
73 if let Some(block) = e.body() {
74 compute_block_scopes(block, scopes, scope);
75 }
76 },
65 _ => { 77 _ => {
66 expr.syntax().children() 78 expr.syntax().children()
67 .filter_map(ast::Expr::cast) 79 .filter_map(ast::Expr::cast)
diff --git a/crates/libeditor/tests/test.rs b/crates/libeditor/tests/test.rs
index d051980b0..d8c24610d 100644
--- a/crates/libeditor/tests/test.rs
+++ b/crates/libeditor/tests/test.rs
@@ -286,6 +286,14 @@ fn quux() {
286} 286}
287", r#"[CompletionItem { name: "b" }, 287", r#"[CompletionItem { name: "b" },
288 CompletionItem { name: "a" }]"#); 288 CompletionItem { name: "a" }]"#);
289
290 do_check(r"
291fn quux() {
292 for x in &[1, 2, 3] {
293 <|>
294 }
295}
296", r#"[CompletionItem { name: "x" }]"#);
289} 297}
290 298
291fn file(text: &str) -> File { 299fn file(text: &str) -> File {