aboutsummaryrefslogtreecommitdiff
path: root/crates/syntax/src/ast/edit.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/syntax/src/ast/edit.rs')
-rw-r--r--crates/syntax/src/ast/edit.rs36
1 files changed, 1 insertions, 35 deletions
diff --git a/crates/syntax/src/ast/edit.rs b/crates/syntax/src/ast/edit.rs
index 7e4b8252e..4b5f5c571 100644
--- a/crates/syntax/src/ast/edit.rs
+++ b/crates/syntax/src/ast/edit.rs
@@ -13,7 +13,7 @@ use crate::{
13 ast::{ 13 ast::{
14 self, 14 self,
15 make::{self, tokens}, 15 make::{self, tokens},
16 AstNode, TypeBoundsOwner, 16 AstNode,
17 }, 17 },
18 ted, AstToken, Direction, InsertPosition, NodeOrToken, SmolStr, SyntaxElement, SyntaxKind, 18 ted, AstToken, Direction, InsertPosition, NodeOrToken, SmolStr, SyntaxElement, SyntaxKind,
19 SyntaxKind::{ATTR, COMMENT, WHITESPACE}, 19 SyntaxKind::{ATTR, COMMENT, WHITESPACE},
@@ -29,25 +29,6 @@ impl ast::BinExpr {
29 } 29 }
30} 30}
31 31
32impl ast::Fn {
33 #[must_use]
34 pub fn with_body(&self, body: ast::BlockExpr) -> ast::Fn {
35 let mut to_insert: ArrayVec<SyntaxElement, 2> = ArrayVec::new();
36 let old_body_or_semi: SyntaxElement = if let Some(old_body) = self.body() {
37 old_body.syntax().clone().into()
38 } else if let Some(semi) = self.semicolon_token() {
39 to_insert.push(make::tokens::single_space().into());
40 semi.into()
41 } else {
42 to_insert.push(make::tokens::single_space().into());
43 to_insert.push(body.syntax().clone().into());
44 return self.insert_children(InsertPosition::Last, to_insert);
45 };
46 to_insert.push(body.syntax().clone().into());
47 self.replace_children(single_node(old_body_or_semi), to_insert)
48 }
49}
50
51fn make_multiline<N>(node: N) -> N 32fn make_multiline<N>(node: N) -> N
52where 33where
53 N: AstNode + Clone, 34 N: AstNode + Clone,
@@ -156,21 +137,6 @@ impl ast::RecordExprFieldList {
156 } 137 }
157} 138}
158 139
159impl ast::TypeAlias {
160 #[must_use]
161 pub fn remove_bounds(&self) -> ast::TypeAlias {
162 let colon = match self.colon_token() {
163 Some(it) => it,
164 None => return self.clone(),
165 };
166 let end = match self.type_bound_list() {
167 Some(it) => it.syntax().clone().into(),
168 None => colon.clone().into(),
169 };
170 self.replace_children(colon.into()..=end, iter::empty())
171 }
172}
173
174impl ast::Path { 140impl ast::Path {
175 #[must_use] 141 #[must_use]
176 pub fn with_segment(&self, segment: ast::PathSegment) -> ast::Path { 142 pub fn with_segment(&self, segment: ast::PathSegment) -> ast::Path {