aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax/src/algo
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2018-12-08 16:30:35 +0000
committerAleksey Kladov <[email protected]>2018-12-08 16:30:35 +0000
commit4cbc902fcc9de79893779582dac01351d1137c7f (patch)
tree22b7e547f86270c6f238484fb43dbb523f2e5846 /crates/ra_syntax/src/algo
parent93c0b7d794e55e255b102478e2c482c3037d0acb (diff)
grand module rename
Diffstat (limited to 'crates/ra_syntax/src/algo')
-rw-r--r--crates/ra_syntax/src/algo/mod.rs26
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 @@
1pub mod visit;
2
3use crate::{SyntaxNode, SyntaxNodeRef, TextRange, TextUnit};
4
5pub use rowan::LeafAtOffset;
6
7pub 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
15pub fn find_covering_node(root: SyntaxNodeRef, range: TextRange) -> SyntaxNodeRef {
16 SyntaxNode(root.0.covering_node(range))
17}
18
19pub 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}