diff options
Diffstat (limited to 'crates/ra_syntax/src/algo/mod.rs')
-rw-r--r-- | crates/ra_syntax/src/algo/mod.rs | 26 |
1 files changed, 0 insertions, 26 deletions
diff --git a/crates/ra_syntax/src/algo/mod.rs b/crates/ra_syntax/src/algo/mod.rs deleted file mode 100644 index 4b3548ea9..000000000 --- a/crates/ra_syntax/src/algo/mod.rs +++ /dev/null | |||
@@ -1,26 +0,0 @@ | |||
1 | pub mod visit; | ||
2 | |||
3 | use crate::{SyntaxNode, SyntaxNodeRef, TextRange, TextUnit}; | ||
4 | |||
5 | pub use rowan::LeafAtOffset; | ||
6 | |||
7 | pub fn find_leaf_at_offset(node: SyntaxNodeRef, offset: TextUnit) -> LeafAtOffset<SyntaxNodeRef> { | ||
8 | match node.0.leaf_at_offset(offset) { | ||
9 | LeafAtOffset::None => LeafAtOffset::None, | ||
10 | LeafAtOffset::Single(n) => LeafAtOffset::Single(SyntaxNode(n)), | ||
11 | LeafAtOffset::Between(l, r) => LeafAtOffset::Between(SyntaxNode(l), SyntaxNode(r)), | ||
12 | } | ||
13 | } | ||
14 | |||
15 | pub fn find_covering_node(root: SyntaxNodeRef, range: TextRange) -> SyntaxNodeRef { | ||
16 | SyntaxNode(root.0.covering_node(range)) | ||
17 | } | ||
18 | |||
19 | pub fn generate<T>(seed: Option<T>, step: impl Fn(&T) -> Option<T>) -> impl Iterator<Item = T> { | ||
20 | ::itertools::unfold(seed, move |slot| { | ||
21 | slot.take().map(|curr| { | ||
22 | *slot = step(&curr); | ||
23 | curr | ||
24 | }) | ||
25 | }) | ||
26 | } | ||