mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-25 12:33:33 +00:00
Merge #1045
1045: simplify r=matklad a=matklad Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
This commit is contained in:
commit
afe96b75ea
1 changed files with 34 additions and 37 deletions
|
@ -603,43 +603,40 @@ pub enum BinOp {
|
|||
|
||||
impl BinExpr {
|
||||
fn op_details(&self) -> Option<(&SyntaxNode, BinOp)> {
|
||||
self.syntax()
|
||||
.children()
|
||||
.filter_map(|c| match c.kind() {
|
||||
PIPEPIPE => Some((c, BinOp::BooleanOr)),
|
||||
AMPAMP => Some((c, BinOp::BooleanAnd)),
|
||||
EQEQ => Some((c, BinOp::EqualityTest)),
|
||||
NEQ => Some((c, BinOp::NegatedEqualityTest)),
|
||||
LTEQ => Some((c, BinOp::LesserEqualTest)),
|
||||
GTEQ => Some((c, BinOp::GreaterEqualTest)),
|
||||
L_ANGLE => Some((c, BinOp::LesserTest)),
|
||||
R_ANGLE => Some((c, BinOp::GreaterTest)),
|
||||
PLUS => Some((c, BinOp::Addition)),
|
||||
STAR => Some((c, BinOp::Multiplication)),
|
||||
MINUS => Some((c, BinOp::Subtraction)),
|
||||
SLASH => Some((c, BinOp::Division)),
|
||||
PERCENT => Some((c, BinOp::Remainder)),
|
||||
SHL => Some((c, BinOp::LeftShift)),
|
||||
SHR => Some((c, BinOp::RightShift)),
|
||||
CARET => Some((c, BinOp::BitwiseXor)),
|
||||
PIPE => Some((c, BinOp::BitwiseOr)),
|
||||
AMP => Some((c, BinOp::BitwiseAnd)),
|
||||
DOTDOT => Some((c, BinOp::RangeRightOpen)),
|
||||
DOTDOTEQ => Some((c, BinOp::RangeRightClosed)),
|
||||
EQ => Some((c, BinOp::Assignment)),
|
||||
PLUSEQ => Some((c, BinOp::AddAssign)),
|
||||
SLASHEQ => Some((c, BinOp::DivAssign)),
|
||||
STAREQ => Some((c, BinOp::MulAssign)),
|
||||
PERCENTEQ => Some((c, BinOp::RemAssign)),
|
||||
SHREQ => Some((c, BinOp::ShrAssign)),
|
||||
SHLEQ => Some((c, BinOp::ShlAssign)),
|
||||
MINUSEQ => Some((c, BinOp::SubAssign)),
|
||||
PIPEEQ => Some((c, BinOp::BitOrAssign)),
|
||||
AMPEQ => Some((c, BinOp::BitAndAssign)),
|
||||
CARETEQ => Some((c, BinOp::BitXorAssign)),
|
||||
_ => None,
|
||||
})
|
||||
.next()
|
||||
self.syntax().children().find_map(|c| match c.kind() {
|
||||
PIPEPIPE => Some((c, BinOp::BooleanOr)),
|
||||
AMPAMP => Some((c, BinOp::BooleanAnd)),
|
||||
EQEQ => Some((c, BinOp::EqualityTest)),
|
||||
NEQ => Some((c, BinOp::NegatedEqualityTest)),
|
||||
LTEQ => Some((c, BinOp::LesserEqualTest)),
|
||||
GTEQ => Some((c, BinOp::GreaterEqualTest)),
|
||||
L_ANGLE => Some((c, BinOp::LesserTest)),
|
||||
R_ANGLE => Some((c, BinOp::GreaterTest)),
|
||||
PLUS => Some((c, BinOp::Addition)),
|
||||
STAR => Some((c, BinOp::Multiplication)),
|
||||
MINUS => Some((c, BinOp::Subtraction)),
|
||||
SLASH => Some((c, BinOp::Division)),
|
||||
PERCENT => Some((c, BinOp::Remainder)),
|
||||
SHL => Some((c, BinOp::LeftShift)),
|
||||
SHR => Some((c, BinOp::RightShift)),
|
||||
CARET => Some((c, BinOp::BitwiseXor)),
|
||||
PIPE => Some((c, BinOp::BitwiseOr)),
|
||||
AMP => Some((c, BinOp::BitwiseAnd)),
|
||||
DOTDOT => Some((c, BinOp::RangeRightOpen)),
|
||||
DOTDOTEQ => Some((c, BinOp::RangeRightClosed)),
|
||||
EQ => Some((c, BinOp::Assignment)),
|
||||
PLUSEQ => Some((c, BinOp::AddAssign)),
|
||||
SLASHEQ => Some((c, BinOp::DivAssign)),
|
||||
STAREQ => Some((c, BinOp::MulAssign)),
|
||||
PERCENTEQ => Some((c, BinOp::RemAssign)),
|
||||
SHREQ => Some((c, BinOp::ShrAssign)),
|
||||
SHLEQ => Some((c, BinOp::ShlAssign)),
|
||||
MINUSEQ => Some((c, BinOp::SubAssign)),
|
||||
PIPEEQ => Some((c, BinOp::BitOrAssign)),
|
||||
AMPEQ => Some((c, BinOp::BitAndAssign)),
|
||||
CARETEQ => Some((c, BinOp::BitXorAssign)),
|
||||
_ => None,
|
||||
})
|
||||
}
|
||||
|
||||
pub fn op_kind(&self) -> Option<BinOp> {
|
||||
|
|
Loading…
Reference in a new issue