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 | |
parent | 55e87e0b742b46d40b1a5ef1598804e48e45f0e0 (diff) |
initial mod resolve
Diffstat (limited to 'crates/libsyntax2/src')
-rw-r--r-- | crates/libsyntax2/src/ast/mod.rs | 9 | ||||
-rw-r--r-- | crates/libsyntax2/src/yellow/syntax.rs | 10 |
2 files changed, 18 insertions, 1 deletions
diff --git a/crates/libsyntax2/src/ast/mod.rs b/crates/libsyntax2/src/ast/mod.rs index d53b12ab8..9b9200f99 100644 --- a/crates/libsyntax2/src/ast/mod.rs +++ b/crates/libsyntax2/src/ast/mod.rs | |||
@@ -118,3 +118,12 @@ impl <R: TreeRoot> ImplItem<R> { | |||
118 | (first, second) | 118 | (first, second) |
119 | } | 119 | } |
120 | } | 120 | } |
121 | |||
122 | impl <R: TreeRoot> Module<R> { | ||
123 | pub fn has_semi(&self) -> bool { | ||
124 | match self.syntax_ref().last_child() { | ||
125 | None => false, | ||
126 | Some(node) => node.kind() == SEMI, | ||
127 | } | ||
128 | } | ||
129 | } | ||
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>> { |