aboutsummaryrefslogtreecommitdiff
path: root/crates/libsyntax2/src/yellow
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2018-08-12 16:50:16 +0100
committerAleksey Kladov <[email protected]>2018-08-12 16:50:16 +0100
commit66be735aa98c32fb062d1c756fa9303ff2d13002 (patch)
treed679bef9b4005f969cfa5a369c6804195de6c779 /crates/libsyntax2/src/yellow
parent56aa6e20e0279c69e0130905573b1607056cfaf9 (diff)
flip comma
Diffstat (limited to 'crates/libsyntax2/src/yellow')
-rw-r--r--crates/libsyntax2/src/yellow/syntax.rs11
1 files changed, 11 insertions, 0 deletions
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<R: TreeRoot> SyntaxNode<R> {
101 }) 101 })
102 } 102 }
103 103
104 pub fn prev_sibling(&self) -> Option<SyntaxNode<R>> {
105 let red = self.red();
106 let parent = self.parent()?;
107 let prev_sibling_idx = red.index_in_parent()?.checked_sub(1)?;
108 let sibling_red = parent.red().get_child(prev_sibling_idx)?;
109 Some(SyntaxNode {
110 root: self.root.clone(),
111 red: sibling_red,
112 })
113 }
114
104 pub fn is_leaf(&self) -> bool { 115 pub fn is_leaf(&self) -> bool {
105 self.first_child().is_none() 116 self.first_child().is_none()
106 } 117 }