diff options
author | Aleksey Kladov <[email protected]> | 2018-10-02 16:02:57 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2018-10-02 16:02:57 +0100 |
commit | d323c81d5cc6a198239285abcede2166181d8f39 (patch) | |
tree | 02c64a01b14d893df439a9e90797db6d58c5a54d /crates/ra_editor/src/scope/fn_scope.rs | |
parent | dccaa5e45e9baaa2d286353a7499a89af1669e42 (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.rs | 6 |
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::{ | |||
6 | use ra_syntax::{ | 6 | use 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 | ||
12 | type ScopeId = usize; | 12 | type 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 | } |