From db34abeb8589518896b82f52062b9fab4c2b1352 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 26 Mar 2020 16:10:01 +0100 Subject: Get rid of ItemOrMacro --- crates/ra_syntax/src/ast/traits.rs | 31 +------------------------------ 1 file changed, 1 insertion(+), 30 deletions(-) (limited to 'crates/ra_syntax/src/ast/traits.rs') diff --git a/crates/ra_syntax/src/ast/traits.rs b/crates/ra_syntax/src/ast/traits.rs index f8cf1e3eb..576378306 100644 --- a/crates/ra_syntax/src/ast/traits.rs +++ b/crates/ra_syntax/src/ast/traits.rs @@ -6,8 +6,7 @@ use itertools::Itertools; use crate::{ ast::{self, child_opt, children, AstChildren, AstNode, AstToken}, - match_ast, - syntax_node::{SyntaxElementChildren, SyntaxNodeChildren}, + syntax_node::SyntaxElementChildren, }; pub trait TypeAscriptionOwner: AstNode { @@ -46,38 +45,10 @@ pub trait FnDefOwner: AstNode { } } -#[derive(Debug, Clone, PartialEq, Eq)] -pub enum ItemOrMacro { - Item(ast::ModuleItem), - Macro(ast::MacroCall), -} - pub trait ModuleItemOwner: AstNode { fn items(&self) -> AstChildren { children(self) } - fn items_with_macros(&self) -> ItemOrMacroIter { - ItemOrMacroIter(self.syntax().children()) - } -} - -#[derive(Debug)] -pub struct ItemOrMacroIter(SyntaxNodeChildren); - -impl Iterator for ItemOrMacroIter { - type Item = ItemOrMacro; - fn next(&mut self) -> Option { - loop { - let n = self.0.next()?; - match_ast! { - match n { - ast::ModuleItem(it) => { return Some(ItemOrMacro::Item(it)) }, - ast::MacroCall(it) => { return Some(ItemOrMacro::Macro(it)) }, - _ => {}, - } - } - } - } } pub trait TypeParamsOwner: AstNode { -- cgit v1.2.3