aboutsummaryrefslogtreecommitdiff
path: root/crates/libsyntax2/src/yellow
diff options
context:
space:
mode:
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 }