diff options
author | Aleksey Kladov <[email protected]> | 2021-05-09 16:20:37 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2021-05-09 16:20:37 +0100 |
commit | 5342800147679a0ded5546322c94aa6339d58fbc (patch) | |
tree | 7a70c7145b5e3a738bf289b7f54941fc645b4fe1 /crates/syntax | |
parent | 984d20aad8445ecbdc05d1dc3ea2de104c685af0 (diff) |
internal: rewrite **Repalce impl Trait** assist to mutable syntax trees
Diffstat (limited to 'crates/syntax')
-rw-r--r-- | crates/syntax/src/ast/edit_in_place.rs | 19 |
1 files changed, 7 insertions, 12 deletions
diff --git a/crates/syntax/src/ast/edit_in_place.rs b/crates/syntax/src/ast/edit_in_place.rs index 04f97f368..168355555 100644 --- a/crates/syntax/src/ast/edit_in_place.rs +++ b/crates/syntax/src/ast/edit_in_place.rs | |||
@@ -195,18 +195,13 @@ impl ast::GenericParamList { | |||
195 | pub fn add_generic_param(&self, generic_param: ast::GenericParam) { | 195 | pub fn add_generic_param(&self, generic_param: ast::GenericParam) { |
196 | match self.generic_params().last() { | 196 | match self.generic_params().last() { |
197 | Some(last_param) => { | 197 | Some(last_param) => { |
198 | let mut elems = Vec::new(); | 198 | let position = Position::after(last_param.syntax()); |
199 | if !last_param | 199 | let elements = vec![ |
200 | .syntax() | 200 | make::token(T![,]).into(), |
201 | .siblings_with_tokens(Direction::Next) | 201 | make::tokens::single_space().into(), |
202 | .any(|it| it.kind() == T![,]) | 202 | generic_param.syntax().clone().into(), |
203 | { | 203 | ]; |
204 | elems.push(make::token(T![,]).into()); | 204 | ted::insert_all(position, elements); |
205 | elems.push(make::tokens::single_space().into()); | ||
206 | }; | ||
207 | elems.push(generic_param.syntax().clone().into()); | ||
208 | let after_last_param = Position::after(last_param.syntax()); | ||
209 | ted::insert_all(after_last_param, elems); | ||
210 | } | 205 | } |
211 | None => { | 206 | None => { |
212 | let after_l_angle = Position::after(self.l_angle_token().unwrap()); | 207 | let after_l_angle = Position::after(self.l_angle_token().unwrap()); |