aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax/src
diff options
context:
space:
mode:
authorKirill Bulatov <[email protected]>2020-02-12 14:21:55 +0000
committerKirill Bulatov <[email protected]>2020-02-12 14:21:55 +0000
commit1596b31698acd1ca8fe25a1b699bef4a9a6feb1d (patch)
tree4f248f05afd6e1bdbfbc66d6e7d111708cacab45 /crates/ra_syntax/src
parent759100fb0dcb41518f2a593dae5de5bbedd07776 (diff)
Do not add imports before inner attributes
Diffstat (limited to 'crates/ra_syntax/src')
-rw-r--r--crates/ra_syntax/src/ast/extensions.rs9
1 files changed, 9 insertions, 0 deletions
diff --git a/crates/ra_syntax/src/ast/extensions.rs b/crates/ra_syntax/src/ast/extensions.rs
index 7dcf084de..a297ae110 100644
--- a/crates/ra_syntax/src/ast/extensions.rs
+++ b/crates/ra_syntax/src/ast/extensions.rs
@@ -71,6 +71,15 @@ impl ast::Attr {
71 _ => None, 71 _ => None,
72 } 72 }
73 } 73 }
74
75 pub fn is_inner_attribute(&self) -> bool {
76 let first_token = self.syntax().first_token();
77 let first_token_kind = first_token.as_ref().map(SyntaxToken::kind);
78 let second_token_kind =
79 first_token.and_then(|token| token.next_token()).as_ref().map(SyntaxToken::kind);
80 return first_token_kind == Some(SyntaxKind::POUND)
81 && second_token_kind == Some(SyntaxKind::EXCL);
82 }
74} 83}
75 84
76#[derive(Debug, Clone, PartialEq, Eq)] 85#[derive(Debug, Clone, PartialEq, Eq)]