mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 22:31:43 +00:00
Do not add imports before inner attributes
This commit is contained in:
parent
759100fb0d
commit
1596b31698
2 changed files with 38 additions and 1 deletions
|
@ -71,6 +71,15 @@ impl ast::Attr {
|
|||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn is_inner_attribute(&self) -> bool {
|
||||
let first_token = self.syntax().first_token();
|
||||
let first_token_kind = first_token.as_ref().map(SyntaxToken::kind);
|
||||
let second_token_kind =
|
||||
first_token.and_then(|token| token.next_token()).as_ref().map(SyntaxToken::kind);
|
||||
return first_token_kind == Some(SyntaxKind::POUND)
|
||||
&& second_token_kind == Some(SyntaxKind::EXCL);
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue