Runnig tests somehow

This commit is contained in:
Aleksey Kladov 2018-08-24 13:41:25 +03:00
parent 89e56c364f
commit 6cade3f6d8
10 changed files with 149 additions and 32 deletions

View file

@ -1,7 +1,10 @@
pub mod walk;
pub mod visit;
use {SyntaxNodeRef, TextUnit, TextRange};
use {
SyntaxNodeRef, TextUnit, TextRange,
text_utils::{contains_offset_nonstrict, is_subrange},
};
pub fn find_leaf_at_offset(node: SyntaxNodeRef, offset: TextUnit) -> LeafAtOffset {
let range = node.range();
@ -116,14 +119,6 @@ fn common_ancestor<'a>(n1: SyntaxNodeRef<'a>, n2: SyntaxNodeRef<'a>) -> SyntaxNo
panic!("Can't find common ancestor of {:?} and {:?}", n1, n2)
}
fn contains_offset_nonstrict(range: TextRange, offset: TextUnit) -> bool {
range.start() <= offset && offset <= range.end()
}
fn is_subrange(range: TextRange, subrange: TextRange) -> bool {
range.start() <= subrange.start() && subrange.end() <= range.end()
}
fn generate<T>(seed: Option<T>, step: impl Fn(&T) -> Option<T>) -> impl Iterator<Item=T> {
::itertools::unfold(seed, move |slot| {
slot.take().map(|curr| {