mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-22 01:52:56 +00:00
migrate ra_hir to rowan 2.0
This commit is contained in:
parent
d6020f516f
commit
da0b348ae9
20 changed files with 238 additions and 197 deletions
|
@ -53,10 +53,37 @@ pub trait FnDefOwner: AstNode {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum ItemOrMacro<'a> {
|
||||
Item(&'a ModuleItem),
|
||||
Macro(&'a MacroCall),
|
||||
}
|
||||
|
||||
pub trait ModuleItemOwner: AstNode {
|
||||
fn items(&self) -> AstChildren<ModuleItem> {
|
||||
children(self)
|
||||
}
|
||||
fn items_with_macros(&self) -> ItemOrMacroIter {
|
||||
ItemOrMacroIter(self.syntax().children())
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct ItemOrMacroIter<'a>(SyntaxNodeChildren<'a>);
|
||||
|
||||
impl<'a> Iterator for ItemOrMacroIter<'a> {
|
||||
type Item = ItemOrMacro<'a>;
|
||||
fn next(&mut self) -> Option<ItemOrMacro<'a>> {
|
||||
loop {
|
||||
let n = self.0.next()?;
|
||||
if let Some(item) = ModuleItem::cast(n) {
|
||||
return Some(ItemOrMacro::Item(item));
|
||||
}
|
||||
if let Some(call) = MacroCall::cast(n) {
|
||||
return Some(ItemOrMacro::Macro(call));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub trait TypeParamsOwner: AstNode {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue