aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_editor/src/scope/fn_scope.rs
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2018-10-02 16:02:57 +0100
committerAleksey Kladov <[email protected]>2018-10-02 16:02:57 +0100
commitd323c81d5cc6a198239285abcede2166181d8f39 (patch)
tree02c64a01b14d893df439a9e90797db6d58c5a54d /crates/ra_editor/src/scope/fn_scope.rs
parentdccaa5e45e9baaa2d286353a7499a89af1669e42 (diff)
make ancestors and descendants inherent
Diffstat (limited to 'crates/ra_editor/src/scope/fn_scope.rs')
-rw-r--r--crates/ra_editor/src/scope/fn_scope.rs6
1 files changed, 3 insertions, 3 deletions
diff --git a/crates/ra_editor/src/scope/fn_scope.rs b/crates/ra_editor/src/scope/fn_scope.rs
index 3ae5276a2..eddd87495 100644
--- a/crates/ra_editor/src/scope/fn_scope.rs
+++ b/crates/ra_editor/src/scope/fn_scope.rs
@@ -6,7 +6,7 @@ use std::{
6use ra_syntax::{ 6use ra_syntax::{
7 SyntaxNodeRef, SyntaxNode, SmolStr, AstNode, 7 SyntaxNodeRef, SyntaxNode, SmolStr, AstNode,
8 ast::{self, NameOwner, LoopBodyOwner, ArgListOwner}, 8 ast::{self, NameOwner, LoopBodyOwner, ArgListOwner},
9 algo::{ancestors, generate, walk::preorder} 9 algo::{generate}
10}; 10};
11 11
12type ScopeId = usize; 12type ScopeId = usize;
@@ -51,7 +51,7 @@ impl FnScopes {
51 res 51 res
52 } 52 }
53 fn add_bindings(&mut self, scope: ScopeId, pat: ast::Pat) { 53 fn add_bindings(&mut self, scope: ScopeId, pat: ast::Pat) {
54 let entries = preorder(pat.syntax()) 54 let entries = pat.syntax().descendants()
55 .filter_map(ast::BindPat::cast) 55 .filter_map(ast::BindPat::cast)
56 .filter_map(ScopeEntry::new); 56 .filter_map(ScopeEntry::new);
57 self.scopes[scope].entries.extend(entries); 57 self.scopes[scope].entries.extend(entries);
@@ -66,7 +66,7 @@ impl FnScopes {
66 self.scope_for.insert(node.owned(), scope); 66 self.scope_for.insert(node.owned(), scope);
67 } 67 }
68 fn scope_for(&self, node: SyntaxNodeRef) -> Option<ScopeId> { 68 fn scope_for(&self, node: SyntaxNodeRef) -> Option<ScopeId> {
69 ancestors(node) 69 node.ancestors()
70 .filter_map(|it| self.scope_for.get(&it.owned()).map(|&scope| scope)) 70 .filter_map(|it| self.scope_for.get(&it.owned()).map(|&scope| scope))
71 .next() 71 .next()
72 } 72 }