diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-03-26 15:13:54 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2020-03-26 15:13:54 +0000 |
commit | ac05571dc9b01dbbb6cf97988190563f1b33ce13 (patch) | |
tree | 3ac357657b2dfa901bc28d35a7934123778dc30a /crates/ra_syntax/src/ast/traits.rs | |
parent | 539e597743229b4497491f325a257bef026602c7 (diff) | |
parent | db34abeb8589518896b82f52062b9fab4c2b1352 (diff) |
Merge #3734
3734: Get rid of ItemOrMacro r=matklad a=matklad
bors r+
🤖
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_syntax/src/ast/traits.rs')
-rw-r--r-- | crates/ra_syntax/src/ast/traits.rs | 31 |
1 files changed, 1 insertions, 30 deletions
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; | |||
6 | 6 | ||
7 | use crate::{ | 7 | use crate::{ |
8 | ast::{self, child_opt, children, AstChildren, AstNode, AstToken}, | 8 | ast::{self, child_opt, children, AstChildren, AstNode, AstToken}, |
9 | match_ast, | 9 | syntax_node::SyntaxElementChildren, |
10 | syntax_node::{SyntaxElementChildren, SyntaxNodeChildren}, | ||
11 | }; | 10 | }; |
12 | 11 | ||
13 | pub trait TypeAscriptionOwner: AstNode { | 12 | pub trait TypeAscriptionOwner: AstNode { |
@@ -46,38 +45,10 @@ pub trait FnDefOwner: AstNode { | |||
46 | } | 45 | } |
47 | } | 46 | } |
48 | 47 | ||
49 | #[derive(Debug, Clone, PartialEq, Eq)] | ||
50 | pub enum ItemOrMacro { | ||
51 | Item(ast::ModuleItem), | ||
52 | Macro(ast::MacroCall), | ||
53 | } | ||
54 | |||
55 | pub trait ModuleItemOwner: AstNode { | 48 | pub trait ModuleItemOwner: AstNode { |
56 | fn items(&self) -> AstChildren<ast::ModuleItem> { | 49 | fn items(&self) -> AstChildren<ast::ModuleItem> { |
57 | children(self) | 50 | children(self) |
58 | } | 51 | } |
59 | fn items_with_macros(&self) -> ItemOrMacroIter { | ||
60 | ItemOrMacroIter(self.syntax().children()) | ||
61 | } | ||
62 | } | ||
63 | |||
64 | #[derive(Debug)] | ||
65 | pub struct ItemOrMacroIter(SyntaxNodeChildren); | ||
66 | |||
67 | impl Iterator for ItemOrMacroIter { | ||
68 | type Item = ItemOrMacro; | ||
69 | fn next(&mut self) -> Option<ItemOrMacro> { | ||
70 | loop { | ||
71 | let n = self.0.next()?; | ||
72 | match_ast! { | ||
73 | match n { | ||
74 | ast::ModuleItem(it) => { return Some(ItemOrMacro::Item(it)) }, | ||
75 | ast::MacroCall(it) => { return Some(ItemOrMacro::Macro(it)) }, | ||
76 | _ => {}, | ||
77 | } | ||
78 | } | ||
79 | } | ||
80 | } | ||
81 | } | 52 | } |
82 | 53 | ||
83 | pub trait TypeParamsOwner: AstNode { | 54 | pub trait TypeParamsOwner: AstNode { |