aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax/src/ast/edit.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_syntax/src/ast/edit.rs')
-rw-r--r--crates/ra_syntax/src/ast/edit.rs12
1 files changed, 11 insertions, 1 deletions
diff --git a/crates/ra_syntax/src/ast/edit.rs b/crates/ra_syntax/src/ast/edit.rs
index 6f005a2d8..95bf9db14 100644
--- a/crates/ra_syntax/src/ast/edit.rs
+++ b/crates/ra_syntax/src/ast/edit.rs
@@ -13,11 +13,21 @@ use crate::{
13 make::{self, tokens}, 13 make::{self, tokens},
14 AstNode, TypeBoundsOwner, 14 AstNode, TypeBoundsOwner,
15 }, 15 },
16 AstToken, Direction, InsertPosition, SmolStr, SyntaxElement, 16 AstToken, Direction, InsertPosition, SmolStr, SyntaxElement, SyntaxKind,
17 SyntaxKind::{ATTR, COMMENT, WHITESPACE}, 17 SyntaxKind::{ATTR, COMMENT, WHITESPACE},
18 SyntaxNode, SyntaxToken, T, 18 SyntaxNode, SyntaxToken, T,
19}; 19};
20 20
21impl ast::BinExpr {
22 #[must_use]
23 pub fn replace_op(&self, op: SyntaxKind) -> Option<ast::BinExpr> {
24 let op_node: SyntaxElement = self.op_details()?.0.into();
25 let to_insert: Option<SyntaxElement> = Some(tokens::op(op).into());
26 let replace_range = RangeInclusive::new(op_node.clone(), op_node);
27 Some(replace_children(self, replace_range, to_insert.into_iter()))
28 }
29}
30
21impl ast::FnDef { 31impl ast::FnDef {
22 #[must_use] 32 #[must_use]
23 pub fn with_body(&self, body: ast::Block) -> ast::FnDef { 33 pub fn with_body(&self, body: ast::Block) -> ast::FnDef {