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/code_actions.rs | |
parent | dccaa5e45e9baaa2d286353a7499a89af1669e42 (diff) |
make ancestors and descendants inherent
Diffstat (limited to 'crates/ra_editor/src/code_actions.rs')
-rw-r--r-- | crates/ra_editor/src/code_actions.rs | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/crates/ra_editor/src/code_actions.rs b/crates/ra_editor/src/code_actions.rs index 83f7956d2..b0f0d8f1d 100644 --- a/crates/ra_editor/src/code_actions.rs +++ b/crates/ra_editor/src/code_actions.rs | |||
@@ -9,7 +9,6 @@ use ra_syntax::{ | |||
9 | Direction, siblings, | 9 | Direction, siblings, |
10 | find_leaf_at_offset, | 10 | find_leaf_at_offset, |
11 | find_covering_node, | 11 | find_covering_node, |
12 | ancestors, | ||
13 | }, | 12 | }, |
14 | }; | 13 | }; |
15 | 14 | ||
@@ -101,8 +100,8 @@ pub fn add_impl<'a>(file: &'a File, offset: TextUnit) -> Option<impl FnOnce() -> | |||
101 | 100 | ||
102 | pub fn introduce_variable<'a>(file: &'a File, range: TextRange) -> Option<impl FnOnce() -> LocalEdit + 'a> { | 101 | pub fn introduce_variable<'a>(file: &'a File, range: TextRange) -> Option<impl FnOnce() -> LocalEdit + 'a> { |
103 | let node = find_covering_node(file.syntax(), range); | 102 | let node = find_covering_node(file.syntax(), range); |
104 | let expr = ancestors(node).filter_map(ast::Expr::cast).next()?; | 103 | let expr = node.ancestors().filter_map(ast::Expr::cast).next()?; |
105 | let anchor_stmt = ancestors(expr.syntax()).filter_map(ast::Stmt::cast).next()?; | 104 | let anchor_stmt = expr.syntax().ancestors().filter_map(ast::Stmt::cast).next()?; |
106 | let indent = anchor_stmt.syntax().prev_sibling()?; | 105 | let indent = anchor_stmt.syntax().prev_sibling()?; |
107 | if indent.kind() != WHITESPACE { | 106 | if indent.kind() != WHITESPACE { |
108 | return None; | 107 | return None; |