aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_assists/src/ast_editor.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_assists/src/ast_editor.rs')
-rw-r--r--crates/ra_assists/src/ast_editor.rs26
1 files changed, 11 insertions, 15 deletions
diff --git a/crates/ra_assists/src/ast_editor.rs b/crates/ra_assists/src/ast_editor.rs
index cabb3d862..de0529b32 100644
--- a/crates/ra_assists/src/ast_editor.rs
+++ b/crates/ra_assists/src/ast_editor.rs
@@ -212,21 +212,17 @@ impl AstEditor<ast::FnDef> {
212 } 212 }
213 213
214 pub fn strip_attrs_and_docs(&mut self) { 214 pub fn strip_attrs_and_docs(&mut self) {
215 loop { 215 while let Some(start) = self
216 if let Some(start) = self 216 .ast()
217 .ast() 217 .syntax()
218 .syntax() 218 .children_with_tokens()
219 .children_with_tokens() 219 .find(|it| it.kind() == ATTR || it.kind() == COMMENT)
220 .find(|it| it.kind() == ATTR || it.kind() == COMMENT) 220 {
221 { 221 let end = match start.next_sibling_or_token() {
222 let end = match start.next_sibling_or_token() { 222 Some(el) if el.kind() == WHITESPACE => el,
223 Some(el) if el.kind() == WHITESPACE => el, 223 Some(_) | None => start,
224 Some(_) | None => start, 224 };
225 }; 225 self.ast = self.replace_children(RangeInclusive::new(start, end), iter::empty());
226 self.ast = self.replace_children(RangeInclusive::new(start, end), iter::empty());
227 } else {
228 break;
229 }
230 } 226 }
231 } 227 }
232} 228}