make ancestors and descendants inherent

This commit is contained in:
Aleksey Kladov
2018-10-02 18:02:57 +03:00
parent dccaa5e45e
commit d323c81d5c
14 changed files with 40 additions and 46 deletions

View File

@@ -4,7 +4,6 @@ use std::{
use {
SyntaxNodeRef, TextRange, TextUnit,
algo::walk::preorder,
text_utils::{intersect, contains_offset_nonstrict},
};
@@ -23,7 +22,8 @@ impl<'a> SyntaxText<'a> {
}
pub fn chunks(&self) -> impl Iterator<Item=&'a str> {
let range = self.range;
preorder(self.node)
self.node
.descendants()
.filter_map(move |node| {
let text = node.leaf_text()?;
let range = intersect(range, node.range())?;