aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax/src
diff options
context:
space:
mode:
authorbors[bot] <bors[bot]@users.noreply.github.com>2019-03-25 08:00:10 +0000
committerbors[bot] <bors[bot]@users.noreply.github.com>2019-03-25 08:00:10 +0000
commitafe96b75eae99fe2dcd7fb7c99e15507290b3d5f (patch)
tree9e73d1fcc53a8287c1d352adce1a24994f9a9203 /crates/ra_syntax/src
parent6f995f47ea6acd69666b0e409b10b3ccd38821ce (diff)
parent6c4b06e2e3db2cf93cfd4930a016ab9ae695d4b9 (diff)
Merge #1045
1045: simplify r=matklad a=matklad Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_syntax/src')
-rw-r--r--crates/ra_syntax/src/ast.rs71
1 files changed, 34 insertions, 37 deletions
diff --git a/crates/ra_syntax/src/ast.rs b/crates/ra_syntax/src/ast.rs
index 226208700..a6fac07c4 100644
--- a/crates/ra_syntax/src/ast.rs
+++ b/crates/ra_syntax/src/ast.rs
@@ -603,43 +603,40 @@ pub enum BinOp {
603 603
604impl BinExpr { 604impl BinExpr {
605 fn op_details(&self) -> Option<(&SyntaxNode, BinOp)> { 605 fn op_details(&self) -> Option<(&SyntaxNode, BinOp)> {
606 self.syntax() 606 self.syntax().children().find_map(|c| match c.kind() {
607 .children() 607 PIPEPIPE => Some((c, BinOp::BooleanOr)),
608 .filter_map(|c| match c.kind() { 608 AMPAMP => Some((c, BinOp::BooleanAnd)),
609 PIPEPIPE => Some((c, BinOp::BooleanOr)), 609 EQEQ => Some((c, BinOp::EqualityTest)),
610 AMPAMP => Some((c, BinOp::BooleanAnd)), 610 NEQ => Some((c, BinOp::NegatedEqualityTest)),
611 EQEQ => Some((c, BinOp::EqualityTest)), 611 LTEQ => Some((c, BinOp::LesserEqualTest)),
612 NEQ => Some((c, BinOp::NegatedEqualityTest)), 612 GTEQ => Some((c, BinOp::GreaterEqualTest)),
613 LTEQ => Some((c, BinOp::LesserEqualTest)), 613 L_ANGLE => Some((c, BinOp::LesserTest)),
614 GTEQ => Some((c, BinOp::GreaterEqualTest)), 614 R_ANGLE => Some((c, BinOp::GreaterTest)),
615 L_ANGLE => Some((c, BinOp::LesserTest)), 615 PLUS => Some((c, BinOp::Addition)),
616 R_ANGLE => Some((c, BinOp::GreaterTest)), 616 STAR => Some((c, BinOp::Multiplication)),
617 PLUS => Some((c, BinOp::Addition)), 617 MINUS => Some((c, BinOp::Subtraction)),
618 STAR => Some((c, BinOp::Multiplication)), 618 SLASH => Some((c, BinOp::Division)),
619 MINUS => Some((c, BinOp::Subtraction)), 619 PERCENT => Some((c, BinOp::Remainder)),
620 SLASH => Some((c, BinOp::Division)), 620 SHL => Some((c, BinOp::LeftShift)),
621 PERCENT => Some((c, BinOp::Remainder)), 621 SHR => Some((c, BinOp::RightShift)),
622 SHL => Some((c, BinOp::LeftShift)), 622 CARET => Some((c, BinOp::BitwiseXor)),
623 SHR => Some((c, BinOp::RightShift)), 623 PIPE => Some((c, BinOp::BitwiseOr)),
624 CARET => Some((c, BinOp::BitwiseXor)), 624 AMP => Some((c, BinOp::BitwiseAnd)),
625 PIPE => Some((c, BinOp::BitwiseOr)), 625 DOTDOT => Some((c, BinOp::RangeRightOpen)),
626 AMP => Some((c, BinOp::BitwiseAnd)), 626 DOTDOTEQ => Some((c, BinOp::RangeRightClosed)),
627 DOTDOT => Some((c, BinOp::RangeRightOpen)), 627 EQ => Some((c, BinOp::Assignment)),
628 DOTDOTEQ => Some((c, BinOp::RangeRightClosed)), 628 PLUSEQ => Some((c, BinOp::AddAssign)),
629 EQ => Some((c, BinOp::Assignment)), 629 SLASHEQ => Some((c, BinOp::DivAssign)),
630 PLUSEQ => Some((c, BinOp::AddAssign)), 630 STAREQ => Some((c, BinOp::MulAssign)),
631 SLASHEQ => Some((c, BinOp::DivAssign)), 631 PERCENTEQ => Some((c, BinOp::RemAssign)),
632 STAREQ => Some((c, BinOp::MulAssign)), 632 SHREQ => Some((c, BinOp::ShrAssign)),
633 PERCENTEQ => Some((c, BinOp::RemAssign)), 633 SHLEQ => Some((c, BinOp::ShlAssign)),
634 SHREQ => Some((c, BinOp::ShrAssign)), 634 MINUSEQ => Some((c, BinOp::SubAssign)),
635 SHLEQ => Some((c, BinOp::ShlAssign)), 635 PIPEEQ => Some((c, BinOp::BitOrAssign)),
636 MINUSEQ => Some((c, BinOp::SubAssign)), 636 AMPEQ => Some((c, BinOp::BitAndAssign)),
637 PIPEEQ => Some((c, BinOp::BitOrAssign)), 637 CARETEQ => Some((c, BinOp::BitXorAssign)),
638 AMPEQ => Some((c, BinOp::BitAndAssign)), 638 _ => None,
639 CARETEQ => Some((c, BinOp::BitXorAssign)), 639 })
640 _ => None,
641 })
642 .next()
643 } 640 }
644 641
645 pub fn op_kind(&self) -> Option<BinOp> { 642 pub fn op_kind(&self) -> Option<BinOp> {