diff options
Diffstat (limited to 'crates/ra_syntax/src/ast/edit.rs')
-rw-r--r-- | crates/ra_syntax/src/ast/edit.rs | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/crates/ra_syntax/src/ast/edit.rs b/crates/ra_syntax/src/ast/edit.rs index 069c6ee82..9e5411ee5 100644 --- a/crates/ra_syntax/src/ast/edit.rs +++ b/crates/ra_syntax/src/ast/edit.rs | |||
@@ -6,7 +6,7 @@ use std::{iter, ops::RangeInclusive}; | |||
6 | use arrayvec::ArrayVec; | 6 | use arrayvec::ArrayVec; |
7 | 7 | ||
8 | use crate::{ | 8 | use crate::{ |
9 | algo, | 9 | algo::{self, neighbor, SyntaxRewriter}, |
10 | ast::{ | 10 | ast::{ |
11 | self, | 11 | self, |
12 | make::{self, tokens}, | 12 | make::{self, tokens}, |
@@ -16,7 +16,6 @@ use crate::{ | |||
16 | SyntaxKind::{ATTR, COMMENT, WHITESPACE}, | 16 | SyntaxKind::{ATTR, COMMENT, WHITESPACE}, |
17 | SyntaxNode, SyntaxToken, T, | 17 | SyntaxNode, SyntaxToken, T, |
18 | }; | 18 | }; |
19 | use algo::{neighbor, SyntaxRewriter}; | ||
20 | 19 | ||
21 | impl ast::BinExpr { | 20 | impl ast::BinExpr { |
22 | #[must_use] | 21 | #[must_use] |
@@ -33,9 +32,9 @@ impl ast::FnDef { | |||
33 | let mut to_insert: ArrayVec<[SyntaxElement; 2]> = ArrayVec::new(); | 32 | let mut to_insert: ArrayVec<[SyntaxElement; 2]> = ArrayVec::new(); |
34 | let old_body_or_semi: SyntaxElement = if let Some(old_body) = self.body() { | 33 | let old_body_or_semi: SyntaxElement = if let Some(old_body) = self.body() { |
35 | old_body.syntax().clone().into() | 34 | old_body.syntax().clone().into() |
36 | } else if let Some(semi) = self.semi_token() { | 35 | } else if let Some(semi) = self.semicolon_token() { |
37 | to_insert.push(make::tokens::single_space().into()); | 36 | to_insert.push(make::tokens::single_space().into()); |
38 | semi.syntax.clone().into() | 37 | semi.into() |
39 | } else { | 38 | } else { |
40 | to_insert.push(make::tokens::single_space().into()); | 39 | to_insert.push(make::tokens::single_space().into()); |
41 | to_insert.push(body.syntax().clone().into()); | 40 | to_insert.push(body.syntax().clone().into()); |
@@ -99,7 +98,7 @@ impl ast::ItemList { | |||
99 | None => match self.l_curly_token() { | 98 | None => match self.l_curly_token() { |
100 | Some(it) => ( | 99 | Some(it) => ( |
101 | " ".to_string() + &leading_indent(self.syntax()).unwrap_or_default(), | 100 | " ".to_string() + &leading_indent(self.syntax()).unwrap_or_default(), |
102 | InsertPosition::After(it.syntax().clone().into()), | 101 | InsertPosition::After(it.into()), |
103 | ), | 102 | ), |
104 | None => return self.clone(), | 103 | None => return self.clone(), |
105 | }, | 104 | }, |
@@ -143,7 +142,7 @@ impl ast::RecordFieldList { | |||
143 | macro_rules! after_l_curly { | 142 | macro_rules! after_l_curly { |
144 | () => {{ | 143 | () => {{ |
145 | let anchor = match self.l_curly_token() { | 144 | let anchor = match self.l_curly_token() { |
146 | Some(it) => it.syntax().clone().into(), | 145 | Some(it) => it.into(), |
147 | None => return self.clone(), | 146 | None => return self.clone(), |
148 | }; | 147 | }; |
149 | InsertPosition::After(anchor) | 148 | InsertPosition::After(anchor) |
@@ -190,15 +189,15 @@ impl ast::RecordFieldList { | |||
190 | impl ast::TypeParam { | 189 | impl ast::TypeParam { |
191 | #[must_use] | 190 | #[must_use] |
192 | pub fn remove_bounds(&self) -> ast::TypeParam { | 191 | pub fn remove_bounds(&self) -> ast::TypeParam { |
193 | let colon = match self.colon() { | 192 | let colon = match self.colon_token() { |
194 | Some(it) => it, | 193 | Some(it) => it, |
195 | None => return self.clone(), | 194 | None => return self.clone(), |
196 | }; | 195 | }; |
197 | let end = match self.type_bound_list() { | 196 | let end = match self.type_bound_list() { |
198 | Some(it) => it.syntax().clone().into(), | 197 | Some(it) => it.syntax().clone().into(), |
199 | None => colon.syntax().clone().into(), | 198 | None => colon.clone().into(), |
200 | }; | 199 | }; |
201 | self.replace_children(colon.syntax().clone().into()..=end, iter::empty()) | 200 | self.replace_children(colon.into()..=end, iter::empty()) |
202 | } | 201 | } |
203 | } | 202 | } |
204 | 203 | ||