mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 04:44:57 +00:00
initial mod resolve
This commit is contained in:
parent
55e87e0b74
commit
081c16c776
6 changed files with 111 additions and 23 deletions
|
@ -118,3 +118,12 @@ impl <R: TreeRoot> ImplItem<R> {
|
|||
(first, second)
|
||||
}
|
||||
}
|
||||
|
||||
impl <R: TreeRoot> Module<R> {
|
||||
pub fn has_semi(&self) -> bool {
|
||||
match self.syntax_ref().last_child() {
|
||||
None => false,
|
||||
Some(node) => node.kind() == SEMI,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -89,7 +89,15 @@ impl<R: TreeRoot> SyntaxNode<R> {
|
|||
}
|
||||
|
||||
pub fn first_child(&self) -> Option<SyntaxNode<R>> {
|
||||
self.children().next()
|
||||
let red = self.red().get_child(0)?;
|
||||
Some(SyntaxNode { root: self.root.clone(), red })
|
||||
}
|
||||
|
||||
pub fn last_child(&self) -> Option<SyntaxNode<R>> {
|
||||
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<SyntaxNode<R>> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue