aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_editor/src/folding_ranges.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/folding_ranges.rs
parentdccaa5e45e9baaa2d286353a7499a89af1669e42 (diff)
make ancestors and descendants inherent
Diffstat (limited to 'crates/ra_editor/src/folding_ranges.rs')
-rw-r--r--crates/ra_editor/src/folding_ranges.rs8
1 files changed, 3 insertions, 5 deletions
diff --git a/crates/ra_editor/src/folding_ranges.rs b/crates/ra_editor/src/folding_ranges.rs
index 817da28d1..892aaf97b 100644
--- a/crates/ra_editor/src/folding_ranges.rs
+++ b/crates/ra_editor/src/folding_ranges.rs
@@ -3,7 +3,7 @@ use std::collections::HashSet;
3use ra_syntax::{ 3use ra_syntax::{
4 File, TextRange, SyntaxNodeRef, 4 File, TextRange, SyntaxNodeRef,
5 SyntaxKind, 5 SyntaxKind,
6 algo::{walk, Direction, siblings}, 6 algo::{Direction, siblings},
7}; 7};
8 8
9#[derive(Debug, PartialEq, Eq)] 9#[derive(Debug, PartialEq, Eq)]
@@ -19,12 +19,10 @@ pub struct Fold {
19} 19}
20 20
21pub fn folding_ranges(file: &File) -> Vec<Fold> { 21pub fn folding_ranges(file: &File) -> Vec<Fold> {
22 let syntax = file.syntax();
23
24 let mut res = vec![]; 22 let mut res = vec![];
25 let mut visited = HashSet::new(); 23 let mut visited = HashSet::new();
26 24
27 for node in walk::preorder(syntax) { 25 for node in file.syntax().descendants() {
28 if visited.contains(&node) { 26 if visited.contains(&node) {
29 continue; 27 continue;
30 } 28 }
@@ -139,4 +137,4 @@ fn main() {
139 } 137 }
140 138
141 139
142} \ No newline at end of file 140}