mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 12:54:58 +00:00
BinOp helper to detect assignment
This commit is contained in:
parent
c15293e019
commit
5afb22e2b3
2 changed files with 19 additions and 11 deletions
|
@ -126,6 +126,24 @@ pub enum BinOp {
|
|||
BitXorAssign,
|
||||
}
|
||||
|
||||
impl BinOp {
|
||||
pub fn is_assignment(&self) -> bool {
|
||||
match *self {
|
||||
BinOp::Assignment
|
||||
| BinOp::AddAssign
|
||||
| BinOp::DivAssign
|
||||
| BinOp::MulAssign
|
||||
| BinOp::RemAssign
|
||||
| BinOp::ShrAssign
|
||||
| BinOp::ShlAssign
|
||||
| BinOp::SubAssign
|
||||
| BinOp::BitOrAssign
|
||||
| BinOp::BitAndAssign
|
||||
| BinOp::BitXorAssign => true,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
}
|
||||
impl ast::BinExpr {
|
||||
pub fn op_details(&self) -> Option<(SyntaxToken, BinOp)> {
|
||||
self.syntax().children_with_tokens().filter_map(|it| it.into_token()).find_map(|c| {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue