From 081c16c77642a5c86ed72c5fbd11deccc2edd5d5 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 17 Aug 2018 15:37:17 +0300 Subject: initial mod resolve --- crates/libsyntax2/src/yellow/syntax.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'crates/libsyntax2/src/yellow') diff --git a/crates/libsyntax2/src/yellow/syntax.rs b/crates/libsyntax2/src/yellow/syntax.rs index b264e008a..bb390751a 100644 --- a/crates/libsyntax2/src/yellow/syntax.rs +++ b/crates/libsyntax2/src/yellow/syntax.rs @@ -89,7 +89,15 @@ impl SyntaxNode { } pub fn first_child(&self) -> Option> { - self.children().next() + let red = self.red().get_child(0)?; + Some(SyntaxNode { root: self.root.clone(), red }) + } + + pub fn last_child(&self) -> Option> { + let n = self.red().n_children(); + let n = n.checked_sub(1)?; + let red = self.red().get_child(n)?; + Some(SyntaxNode { root: self.root.clone(), red }) } pub fn next_sibling(&self) -> Option> { -- cgit v1.2.3