diff options
Diffstat (limited to 'crates/ra_editor/src')
-rw-r--r-- | crates/ra_editor/src/folding_ranges.rs | 12 | ||||
-rw-r--r-- | crates/ra_editor/src/lib.rs | 2 | ||||
-rw-r--r-- | crates/ra_editor/src/symbols.rs | 10 |
3 files changed, 13 insertions, 11 deletions
diff --git a/crates/ra_editor/src/folding_ranges.rs b/crates/ra_editor/src/folding_ranges.rs index 8b79ea874..0803c8891 100644 --- a/crates/ra_editor/src/folding_ranges.rs +++ b/crates/ra_editor/src/folding_ranges.rs | |||
@@ -174,8 +174,16 @@ mod tests { | |||
174 | let file = File::parse(&text); | 174 | let file = File::parse(&text); |
175 | let folds = folding_ranges(&file); | 175 | let folds = folding_ranges(&file); |
176 | 176 | ||
177 | assert_eq!(folds.len(), ranges.len(), "The amount of folds is different than the expected amount"); | 177 | assert_eq!( |
178 | assert_eq!(folds.len(), fold_kinds.len(), "The amount of fold kinds is different than the expected amount"); | 178 | folds.len(), |
179 | ranges.len(), | ||
180 | "The amount of folds is different than the expected amount" | ||
181 | ); | ||
182 | assert_eq!( | ||
183 | folds.len(), | ||
184 | fold_kinds.len(), | ||
185 | "The amount of fold kinds is different than the expected amount" | ||
186 | ); | ||
179 | for ((fold, range), fold_kind) in folds | 187 | for ((fold, range), fold_kind) in folds |
180 | .into_iter() | 188 | .into_iter() |
181 | .zip(ranges.into_iter()) | 189 | .zip(ranges.into_iter()) |
diff --git a/crates/ra_editor/src/lib.rs b/crates/ra_editor/src/lib.rs index 02a1b2d45..481f4c9fc 100644 --- a/crates/ra_editor/src/lib.rs +++ b/crates/ra_editor/src/lib.rs | |||
@@ -148,8 +148,6 @@ pub fn find_node_at_offset<'a, N: AstNode<'a>>( | |||
148 | leaf.ancestors().filter_map(N::cast).next() | 148 | leaf.ancestors().filter_map(N::cast).next() |
149 | } | 149 | } |
150 | 150 | ||
151 | |||
152 | |||
153 | #[cfg(test)] | 151 | #[cfg(test)] |
154 | mod tests { | 152 | mod tests { |
155 | use super::*; | 153 | use super::*; |
diff --git a/crates/ra_editor/src/symbols.rs b/crates/ra_editor/src/symbols.rs index 0bab9dd67..4e602d0e3 100644 --- a/crates/ra_editor/src/symbols.rs +++ b/crates/ra_editor/src/symbols.rs | |||
@@ -1,12 +1,9 @@ | |||
1 | use crate::TextRange; | 1 | use crate::TextRange; |
2 | 2 | ||
3 | use ra_syntax::{ | 3 | use ra_syntax::{ |
4 | algo::{ | 4 | algo::visit::{visitor, Visitor}, |
5 | visit::{visitor, Visitor}, | ||
6 | }, | ||
7 | ast::{self, NameOwner}, | 5 | ast::{self, NameOwner}, |
8 | AstNode, File, SmolStr, SyntaxKind, SyntaxNodeRef, | 6 | AstNode, File, SmolStr, SyntaxKind, SyntaxNodeRef, WalkEvent, |
9 | WalkEvent, | ||
10 | }; | 7 | }; |
11 | 8 | ||
12 | #[derive(Debug, Clone)] | 9 | #[derive(Debug, Clone)] |
@@ -54,7 +51,6 @@ pub fn file_structure(file: &File) -> Vec<StructureNode> { | |||
54 | let mut res = Vec::new(); | 51 | let mut res = Vec::new(); |
55 | let mut stack = Vec::new(); | 52 | let mut stack = Vec::new(); |
56 | 53 | ||
57 | |||
58 | for event in file.syntax().preorder() { | 54 | for event in file.syntax().preorder() { |
59 | match event { | 55 | match event { |
60 | WalkEvent::Enter(node) => { | 56 | WalkEvent::Enter(node) => { |
@@ -63,7 +59,7 @@ pub fn file_structure(file: &File) -> Vec<StructureNode> { | |||
63 | stack.push(res.len()); | 59 | stack.push(res.len()); |
64 | res.push(symbol); | 60 | res.push(symbol); |
65 | } | 61 | } |
66 | }, | 62 | } |
67 | WalkEvent::Leave(node) => { | 63 | WalkEvent::Leave(node) => { |
68 | if structure_node(node).is_some() { | 64 | if structure_node(node).is_some() { |
69 | stack.pop().unwrap(); | 65 | stack.pop().unwrap(); |