diff options
author | Jeremy Kolb <[email protected]> | 2020-01-04 20:54:31 +0000 |
---|---|---|
committer | Jeremy Kolb <[email protected]> | 2020-01-04 20:54:31 +0000 |
commit | 5afb22e2b383a2894297f3508cd3e954da96da1c (patch) | |
tree | 75f478c3e67bcf97b92c4b73cbed1b85e82a2a94 /crates/ra_syntax/src/ast | |
parent | c15293e0193008fb855ed49e8deb533dfaa3e9c7 (diff) |
BinOp helper to detect assignment
Diffstat (limited to 'crates/ra_syntax/src/ast')
-rw-r--r-- | crates/ra_syntax/src/ast/expr_extensions.rs | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/crates/ra_syntax/src/ast/expr_extensions.rs b/crates/ra_syntax/src/ast/expr_extensions.rs index 2fd039837..23b6aa901 100644 --- a/crates/ra_syntax/src/ast/expr_extensions.rs +++ b/crates/ra_syntax/src/ast/expr_extensions.rs | |||
@@ -126,6 +126,24 @@ pub enum BinOp { | |||
126 | BitXorAssign, | 126 | BitXorAssign, |
127 | } | 127 | } |
128 | 128 | ||
129 | impl BinOp { | ||
130 | pub fn is_assignment(&self) -> bool { | ||
131 | match *self { | ||
132 | BinOp::Assignment | ||
133 | | BinOp::AddAssign | ||
134 | | BinOp::DivAssign | ||
135 | | BinOp::MulAssign | ||
136 | | BinOp::RemAssign | ||
137 | | BinOp::ShrAssign | ||
138 | | BinOp::ShlAssign | ||
139 | | BinOp::SubAssign | ||
140 | | BinOp::BitOrAssign | ||
141 | | BinOp::BitAndAssign | ||
142 | | BinOp::BitXorAssign => true, | ||
143 | _ => false, | ||
144 | } | ||
145 | } | ||
146 | } | ||
129 | impl ast::BinExpr { | 147 | impl ast::BinExpr { |
130 | pub fn op_details(&self) -> Option<(SyntaxToken, BinOp)> { | 148 | pub fn op_details(&self) -> Option<(SyntaxToken, BinOp)> { |
131 | self.syntax().children_with_tokens().filter_map(|it| it.into_token()).find_map(|c| { | 149 | self.syntax().children_with_tokens().filter_map(|it| it.into_token()).find_map(|c| { |