Don't insert imports outside of cfg attributed items

This commit is contained in:
Lukas Wirth 2021-06-18 23:53:41 +02:00
parent d9666ce509
commit 344cb5e76a
4 changed files with 118 additions and 32 deletions

View file

@ -8,7 +8,7 @@ use parser::SyntaxKind;
use rowan::{GreenNodeData, GreenTokenData};
use crate::{
ast::{self, support, AstNode, AstToken, AttrsOwner, NameOwner, SyntaxNode},
ast::{self, support, AstChildren, AstNode, AstToken, AttrsOwner, NameOwner, SyntaxNode},
NodeOrToken, SmolStr, SyntaxElement, SyntaxToken, TokenText, T,
};
@ -45,6 +45,12 @@ fn text_of_first_token(node: &SyntaxNode) -> TokenText<'_> {
}
}
impl ast::BlockExpr {
pub fn items(&self) -> AstChildren<ast::Item> {
support::children(self.syntax())
}
}
#[derive(Debug, PartialEq, Eq, Clone)]
pub enum Macro {
MacroRules(ast::MacroRules),