mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-26 04:53:34 +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 {
|
impl BinExpr {
|
||||||
fn op_details(&self) -> Option<(&SyntaxNode, BinOp)> {
|
fn op_details(&self) -> Option<(&SyntaxNode, BinOp)> {
|
||||||
self.syntax()
|
self.syntax().children().find_map(|c| match c.kind() {
|
||||||
.children()
|
PIPEPIPE => Some((c, BinOp::BooleanOr)),
|
||||||
.filter_map(|c| match c.kind() {
|
AMPAMP => Some((c, BinOp::BooleanAnd)),
|
||||||
PIPEPIPE => Some((c, BinOp::BooleanOr)),
|
EQEQ => Some((c, BinOp::EqualityTest)),
|
||||||
AMPAMP => Some((c, BinOp::BooleanAnd)),
|
NEQ => Some((c, BinOp::NegatedEqualityTest)),
|
||||||
EQEQ => Some((c, BinOp::EqualityTest)),
|
LTEQ => Some((c, BinOp::LesserEqualTest)),
|
||||||
NEQ => Some((c, BinOp::NegatedEqualityTest)),
|
GTEQ => Some((c, BinOp::GreaterEqualTest)),
|
||||||
LTEQ => Some((c, BinOp::LesserEqualTest)),
|
L_ANGLE => Some((c, BinOp::LesserTest)),
|
||||||
GTEQ => Some((c, BinOp::GreaterEqualTest)),
|
R_ANGLE => Some((c, BinOp::GreaterTest)),
|
||||||
L_ANGLE => Some((c, BinOp::LesserTest)),
|
PLUS => Some((c, BinOp::Addition)),
|
||||||
R_ANGLE => Some((c, BinOp::GreaterTest)),
|
STAR => Some((c, BinOp::Multiplication)),
|
||||||
PLUS => Some((c, BinOp::Addition)),
|
MINUS => Some((c, BinOp::Subtraction)),
|
||||||
STAR => Some((c, BinOp::Multiplication)),
|
SLASH => Some((c, BinOp::Division)),
|
||||||
MINUS => Some((c, BinOp::Subtraction)),
|
PERCENT => Some((c, BinOp::Remainder)),
|
||||||
SLASH => Some((c, BinOp::Division)),
|
SHL => Some((c, BinOp::LeftShift)),
|
||||||
PERCENT => Some((c, BinOp::Remainder)),
|
SHR => Some((c, BinOp::RightShift)),
|
||||||
SHL => Some((c, BinOp::LeftShift)),
|
CARET => Some((c, BinOp::BitwiseXor)),
|
||||||
SHR => Some((c, BinOp::RightShift)),
|
PIPE => Some((c, BinOp::BitwiseOr)),
|
||||||
CARET => Some((c, BinOp::BitwiseXor)),
|
AMP => Some((c, BinOp::BitwiseAnd)),
|
||||||
PIPE => Some((c, BinOp::BitwiseOr)),
|
DOTDOT => Some((c, BinOp::RangeRightOpen)),
|
||||||
AMP => Some((c, BinOp::BitwiseAnd)),
|
DOTDOTEQ => Some((c, BinOp::RangeRightClosed)),
|
||||||
DOTDOT => Some((c, BinOp::RangeRightOpen)),
|
EQ => Some((c, BinOp::Assignment)),
|
||||||
DOTDOTEQ => Some((c, BinOp::RangeRightClosed)),
|
PLUSEQ => Some((c, BinOp::AddAssign)),
|
||||||
EQ => Some((c, BinOp::Assignment)),
|
SLASHEQ => Some((c, BinOp::DivAssign)),
|
||||||
PLUSEQ => Some((c, BinOp::AddAssign)),
|
STAREQ => Some((c, BinOp::MulAssign)),
|
||||||
SLASHEQ => Some((c, BinOp::DivAssign)),
|
PERCENTEQ => Some((c, BinOp::RemAssign)),
|
||||||
STAREQ => Some((c, BinOp::MulAssign)),
|
SHREQ => Some((c, BinOp::ShrAssign)),
|
||||||
PERCENTEQ => Some((c, BinOp::RemAssign)),
|
SHLEQ => Some((c, BinOp::ShlAssign)),
|
||||||
SHREQ => Some((c, BinOp::ShrAssign)),
|
MINUSEQ => Some((c, BinOp::SubAssign)),
|
||||||
SHLEQ => Some((c, BinOp::ShlAssign)),
|
PIPEEQ => Some((c, BinOp::BitOrAssign)),
|
||||||
MINUSEQ => Some((c, BinOp::SubAssign)),
|
AMPEQ => Some((c, BinOp::BitAndAssign)),
|
||||||
PIPEEQ => Some((c, BinOp::BitOrAssign)),
|
CARETEQ => Some((c, BinOp::BitXorAssign)),
|
||||||
AMPEQ => Some((c, BinOp::BitAndAssign)),
|
_ => None,
|
||||||
CARETEQ => Some((c, BinOp::BitXorAssign)),
|
})
|
||||||
_ => None,
|
|
||||||
})
|
|
||||||
.next()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn op_kind(&self) -> Option<BinOp> {
|
pub fn op_kind(&self) -> Option<BinOp> {
|
||||||
|
|
Loading…
Reference in a new issue