diff options
author | Aleksey Kladov <[email protected]> | 2018-08-17 13:37:17 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2018-08-17 13:37:17 +0100 |
commit | 081c16c77642a5c86ed72c5fbd11deccc2edd5d5 (patch) | |
tree | 90ddf4f92954fcb00f4c20a46968932c5f0bbdea /crates/libsyntax2/src/yellow | |
parent | 55e87e0b742b46d40b1a5ef1598804e48e45f0e0 (diff) |
initial mod resolve
Diffstat (limited to 'crates/libsyntax2/src/yellow')
-rw-r--r-- | crates/libsyntax2/src/yellow/syntax.rs | 10 |
1 files changed, 9 insertions, 1 deletions
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<R: TreeRoot> SyntaxNode<R> { | |||
89 | } | 89 | } |
90 | 90 | ||
91 | pub fn first_child(&self) -> Option<SyntaxNode<R>> { | 91 | pub fn first_child(&self) -> Option<SyntaxNode<R>> { |
92 | self.children().next() | 92 | let red = self.red().get_child(0)?; |
93 | Some(SyntaxNode { root: self.root.clone(), red }) | ||
94 | } | ||
95 | |||
96 | pub fn last_child(&self) -> Option<SyntaxNode<R>> { | ||
97 | let n = self.red().n_children(); | ||
98 | let n = n.checked_sub(1)?; | ||
99 | let red = self.red().get_child(n)?; | ||
100 | Some(SyntaxNode { root: self.root.clone(), red }) | ||
93 | } | 101 | } |
94 | 102 | ||
95 | pub fn next_sibling(&self) -> Option<SyntaxNode<R>> { | 103 | pub fn next_sibling(&self) -> Option<SyntaxNode<R>> { |