flip comma

This commit is contained in:
Aleksey Kladov 2018-08-12 18:50:16 +03:00
parent 56aa6e20e0
commit 66be735aa9
12 changed files with 273 additions and 57 deletions

View file

@ -101,6 +101,17 @@ impl<R: TreeRoot> SyntaxNode<R> {
})
}
pub fn prev_sibling(&self) -> Option<SyntaxNode<R>> {
let red = self.red();
let parent = self.parent()?;
let prev_sibling_idx = red.index_in_parent()?.checked_sub(1)?;
let sibling_red = parent.red().get_child(prev_sibling_idx)?;
Some(SyntaxNode {
root: self.root.clone(),
red: sibling_red,
})
}
pub fn is_leaf(&self) -> bool {
self.first_child().is_none()
}