From 66be735aa98c32fb062d1c756fa9303ff2d13002 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sun, 12 Aug 2018 18:50:16 +0300 Subject: flip comma --- crates/libsyntax2/src/yellow/syntax.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'crates/libsyntax2/src/yellow') diff --git a/crates/libsyntax2/src/yellow/syntax.rs b/crates/libsyntax2/src/yellow/syntax.rs index a22275ed9..00f76e51c 100644 --- a/crates/libsyntax2/src/yellow/syntax.rs +++ b/crates/libsyntax2/src/yellow/syntax.rs @@ -101,6 +101,17 @@ impl SyntaxNode { }) } + pub fn prev_sibling(&self) -> Option> { + 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() } -- cgit v1.2.3