From cd4f66b14443dfefaee008936d36fde7e8466281 Mon Sep 17 00:00:00 2001 From: Kevin Amado Date: Wed, 23 Feb 2022 14:47:36 -0500 Subject: [PATCH] refactor: rename functions - So they match the meaning more closely --- src/alejandra_engine/src/children.rs | 43 ++++++++++++------- src/alejandra_engine/src/parsers/pattern.rs | 18 ++++---- src/alejandra_engine/src/rules/apply.rs | 6 +-- .../src/rules/assert_and_with.rs | 12 +++--- src/alejandra_engine/src/rules/attr_set.rs | 14 +++--- .../src/rules/bin_op_and_or_default.rs | 15 +++---- src/alejandra_engine/src/rules/dynamic.rs | 12 +++--- src/alejandra_engine/src/rules/inherit.rs | 6 +-- src/alejandra_engine/src/rules/key_value.rs | 20 ++++----- src/alejandra_engine/src/rules/lambda.rs | 12 +++--- src/alejandra_engine/src/rules/let_in.rs | 14 +++--- src/alejandra_engine/src/rules/list.rs | 8 ++-- src/alejandra_engine/src/rules/paren.rs | 12 +++--- src/alejandra_engine/src/rules/pat_bind.rs | 6 +-- src/alejandra_engine/src/rules/pat_entry.rs | 12 +++--- src/alejandra_engine/src/rules/root.rs | 6 +-- .../src/rules/string_interpol.rs | 12 +++--- 17 files changed, 123 insertions(+), 105 deletions(-) diff --git a/src/alejandra_engine/src/children.rs b/src/alejandra_engine/src/children.rs index 572affc..44f2bc8 100644 --- a/src/alejandra_engine/src/children.rs +++ b/src/alejandra_engine/src/children.rs @@ -9,9 +9,9 @@ pub struct Children { current_index: usize, } -pub enum DrainCommentOrNewline { +pub enum Trivia { Comment(String), - Newline(usize), + Whitespace(String), } impl Children { @@ -129,7 +129,7 @@ impl Children { self.children.iter().any(|child| { child.element.kind() == rnix::SyntaxKind::TOKEN_WHITESPACE && crate::utils::has_newlines( - child.element.clone().into_token().unwrap().text(), + child.element.as_token().as_ref().unwrap().text(), ) }) } @@ -138,7 +138,13 @@ impl Children { if let Some(child) = self.peek_next() { if let rnix::SyntaxKind::TOKEN_COMMENT = child.element.kind() { callback( - child.element.into_token().unwrap().text().to_string(), + child + .element + .as_token() + .as_ref() + .unwrap() + .text() + .to_string(), ); self.move_next(); } @@ -150,7 +156,13 @@ impl Children { match child.element.kind() { rnix::SyntaxKind::TOKEN_COMMENT => { callback( - child.element.into_token().unwrap().text().to_string(), + child + .element + .as_token() + .as_ref() + .unwrap() + .text() + .to_string(), ); self.move_next(); } @@ -161,24 +173,25 @@ impl Children { } } - pub fn drain_comments_and_newlines( - &mut self, - mut callback: F, - ) { + pub fn drain_trivia(&mut self, mut callback: F) { while let Some(child) = self.peek_next() { match child.element.kind() { rnix::SyntaxKind::TOKEN_COMMENT => { - callback(DrainCommentOrNewline::Comment( + callback(Trivia::Comment( child.element.into_token().unwrap().text().to_string(), )); self.move_next(); } rnix::SyntaxKind::TOKEN_WHITESPACE => { - let newlines_count = crate::utils::count_newlines( - child.element.clone().into_token().unwrap().text(), - ); - - callback(DrainCommentOrNewline::Newline(newlines_count)); + callback(Trivia::Whitespace( + child + .element + .as_token() + .as_ref() + .unwrap() + .text() + .to_string(), + )); self.move_next(); } _ => { diff --git a/src/alejandra_engine/src/parsers/pattern.rs b/src/alejandra_engine/src/parsers/pattern.rs index 7736a5a..c72a548 100644 --- a/src/alejandra_engine/src/parsers/pattern.rs +++ b/src/alejandra_engine/src/parsers/pattern.rs @@ -35,11 +35,11 @@ pub fn parse( } // /**/ - children.drain_comments_and_newlines(|element| match element { - crate::children::DrainCommentOrNewline::Comment(text) => { + children.drain_trivia(|element| match element { + crate::children::Trivia::Comment(text) => { pattern.comments_after_initial_at.push_back(text); } - crate::children::DrainCommentOrNewline::Newline(_) => {} + crate::children::Trivia::Whitespace(_) => {} }); // { @@ -133,22 +133,22 @@ pub fn parse( } // /**/ - children.drain_comments_and_newlines(|element| match element { - crate::children::DrainCommentOrNewline::Comment(text) => { + children.drain_trivia(|element| match element { + crate::children::Trivia::Comment(text) => { pattern.comments_before_curly_b_close.push_back(text); } - crate::children::DrainCommentOrNewline::Newline(_) => {} + crate::children::Trivia::Whitespace(_) => {} }); // } children.move_next(); // /**/ - children.drain_comments_and_newlines(|element| match element { - crate::children::DrainCommentOrNewline::Comment(text) => { + children.drain_trivia(|element| match element { + crate::children::Trivia::Comment(text) => { pattern.comments_before_end_at.push_back(text); } - crate::children::DrainCommentOrNewline::Newline(_) => {} + crate::children::Trivia::Whitespace(_) => {} }); // @ x diff --git a/src/alejandra_engine/src/rules/apply.rs b/src/alejandra_engine/src/rules/apply.rs index c8f520a..56f6d0c 100644 --- a/src/alejandra_engine/src/rules/apply.rs +++ b/src/alejandra_engine/src/rules/apply.rs @@ -22,13 +22,13 @@ pub fn rule( } // /**/ - children.drain_comments_and_newlines(|element| match element { - crate::children::DrainCommentOrNewline::Comment(text) => { + children.drain_trivia(|element| match element { + crate::children::Trivia::Comment(text) => { steps.push_back(crate::builder::Step::NewLine); steps.push_back(crate::builder::Step::Pad); steps.push_back(crate::builder::Step::Comment(text)); } - crate::children::DrainCommentOrNewline::Newline(_) => {} + crate::children::Trivia::Whitespace(_) => {} }); let child_prev = children.peek_prev().unwrap(); diff --git a/src/alejandra_engine/src/rules/assert_and_with.rs b/src/alejandra_engine/src/rules/assert_and_with.rs index 55b1588..9e4cdb4 100644 --- a/src/alejandra_engine/src/rules/assert_and_with.rs +++ b/src/alejandra_engine/src/rules/assert_and_with.rs @@ -18,14 +18,14 @@ pub fn rule( // /**/ let mut comment = false; - children.drain_comments_and_newlines(|element| match element { - crate::children::DrainCommentOrNewline::Comment(text) => { + children.drain_trivia(|element| match element { + crate::children::Trivia::Comment(text) => { steps.push_back(crate::builder::Step::NewLine); steps.push_back(crate::builder::Step::Pad); steps.push_back(crate::builder::Step::Comment(text)); comment = true; } - crate::children::DrainCommentOrNewline::Newline(_) => {} + crate::children::Trivia::Whitespace(_) => {} }); if comment { @@ -49,14 +49,14 @@ pub fn rule( // /**/ let mut comment: bool = false; - children.drain_comments_and_newlines(|element| match element { - crate::children::DrainCommentOrNewline::Comment(text) => { + children.drain_trivia(|element| match element { + crate::children::Trivia::Comment(text) => { steps.push_back(crate::builder::Step::NewLine); steps.push_back(crate::builder::Step::Pad); steps.push_back(crate::builder::Step::Comment(text)); comment = true; } - crate::children::DrainCommentOrNewline::Newline(_) => {} + crate::children::Trivia::Whitespace(_) => {} }); // expr diff --git a/src/alejandra_engine/src/rules/attr_set.rs b/src/alejandra_engine/src/rules/attr_set.rs index e4e4197..4313e9e 100644 --- a/src/alejandra_engine/src/rules/attr_set.rs +++ b/src/alejandra_engine/src/rules/attr_set.rs @@ -50,13 +50,13 @@ pub fn rule( } // /**/ - children.drain_comments_and_newlines(|element| match element { - crate::children::DrainCommentOrNewline::Comment(text) => { + children.drain_trivia(|element| match element { + crate::children::Trivia::Comment(text) => { steps.push_back(crate::builder::Step::Comment(text)); steps.push_back(crate::builder::Step::NewLine); steps.push_back(crate::builder::Step::Pad); } - crate::children::DrainCommentOrNewline::Newline(_) => {} + crate::children::Trivia::Whitespace(_) => {} }); // { @@ -71,8 +71,8 @@ pub fn rule( loop { // /**/ - children.drain_comments_and_newlines(|element| match element { - crate::children::DrainCommentOrNewline::Comment(text) => { + children.drain_trivia(|element| match element { + crate::children::Trivia::Comment(text) => { if inline_next_comment && text.starts_with('#') { steps.push_back(crate::builder::Step::Whitespace); } else { @@ -83,7 +83,9 @@ pub fn rule( item_index += 1; inline_next_comment = false; } - crate::children::DrainCommentOrNewline::Newline(newlines) => { + crate::children::Trivia::Whitespace(text) => { + let newlines = crate::utils::count_newlines(&text); + if newlines > 1 && item_index > 0 && item_index < items_count { steps.push_back(crate::builder::Step::NewLine); } diff --git a/src/alejandra_engine/src/rules/bin_op_and_or_default.rs b/src/alejandra_engine/src/rules/bin_op_and_or_default.rs index b8d2615..9c5e8d0 100644 --- a/src/alejandra_engine/src/rules/bin_op_and_or_default.rs +++ b/src/alejandra_engine/src/rules/bin_op_and_or_default.rs @@ -45,33 +45,32 @@ pub fn rule_with_configuration( } // /**/ - children.drain_comments_and_newlines(|element| match element { - crate::children::DrainCommentOrNewline::Comment(text) => { + children.drain_trivia(|element| match element { + crate::children::Trivia::Comment(text) => { steps.push_back(crate::builder::Step::Comment(text)); steps.push_back(crate::builder::Step::NewLine); steps.push_back(crate::builder::Step::Pad); } - crate::children::DrainCommentOrNewline::Newline(_) => {} + crate::children::Trivia::Whitespace(_) => {} }); // operator let child = children.get_next().unwrap(); - if vertical { - } else if parent_kind == "bin_op_and_or_default" { + if !vertical && parent_kind == "bin_op_and_or_default" { steps.push_back(crate::builder::Step::Whitespace); } steps.push_back(crate::builder::Step::Format(child.element)); // /**/ let mut comment = false; - children.drain_comments_and_newlines(|element| match element { - crate::children::DrainCommentOrNewline::Comment(text) => { + children.drain_trivia(|element| match element { + crate::children::Trivia::Comment(text) => { steps.push_back(crate::builder::Step::NewLine); steps.push_back(crate::builder::Step::Pad); steps.push_back(crate::builder::Step::Comment(text)); comment = true; } - crate::children::DrainCommentOrNewline::Newline(_) => {} + crate::children::Trivia::Whitespace(_) => {} }); if comment { diff --git a/src/alejandra_engine/src/rules/dynamic.rs b/src/alejandra_engine/src/rules/dynamic.rs index 9b5bcc8..5ba940c 100644 --- a/src/alejandra_engine/src/rules/dynamic.rs +++ b/src/alejandra_engine/src/rules/dynamic.rs @@ -22,13 +22,13 @@ pub fn rule( } // /**/ - children.drain_comments_and_newlines(|element| match element { - crate::children::DrainCommentOrNewline::Comment(text) => { + children.drain_trivia(|element| match element { + crate::children::Trivia::Comment(text) => { steps.push_back(crate::builder::Step::Comment(text)); steps.push_back(crate::builder::Step::NewLine); steps.push_back(crate::builder::Step::Pad); } - crate::children::DrainCommentOrNewline::Newline(_) => {} + crate::children::Trivia::Whitespace(_) => {} }); // expr @@ -40,13 +40,13 @@ pub fn rule( } // /**/ - children.drain_comments_and_newlines(|element| match element { - crate::children::DrainCommentOrNewline::Comment(text) => { + children.drain_trivia(|element| match element { + crate::children::Trivia::Comment(text) => { steps.push_back(crate::builder::Step::NewLine); steps.push_back(crate::builder::Step::Pad); steps.push_back(crate::builder::Step::Comment(text)); } - crate::children::DrainCommentOrNewline::Newline(_) => {} + crate::children::Trivia::Whitespace(_) => {} }); // } diff --git a/src/alejandra_engine/src/rules/inherit.rs b/src/alejandra_engine/src/rules/inherit.rs index e9a2ec8..4aa865b 100644 --- a/src/alejandra_engine/src/rules/inherit.rs +++ b/src/alejandra_engine/src/rules/inherit.rs @@ -21,13 +21,13 @@ pub fn rule( loop { // /**/ - children.drain_comments_and_newlines(|element| match element { - crate::children::DrainCommentOrNewline::Comment(text) => { + children.drain_trivia(|element| match element { + crate::children::Trivia::Comment(text) => { steps.push_back(crate::builder::Step::NewLine); steps.push_back(crate::builder::Step::Pad); steps.push_back(crate::builder::Step::Comment(text)); } - crate::children::DrainCommentOrNewline::Newline(_) => {} + crate::children::Trivia::Whitespace(_) => {} }); if let Some(child) = children.get_next() { diff --git a/src/alejandra_engine/src/rules/key_value.rs b/src/alejandra_engine/src/rules/key_value.rs index 4f6d093..5842b98 100644 --- a/src/alejandra_engine/src/rules/key_value.rs +++ b/src/alejandra_engine/src/rules/key_value.rs @@ -22,14 +22,14 @@ pub fn rule( // /**/ let mut comment = false; - children.drain_comments_and_newlines(|element| match element { - crate::children::DrainCommentOrNewline::Comment(text) => { + children.drain_trivia(|element| match element { + crate::children::Trivia::Comment(text) => { comment = true; steps.push_back(crate::builder::Step::NewLine); steps.push_back(crate::builder::Step::Pad); steps.push_back(crate::builder::Step::Comment(text)); } - crate::children::DrainCommentOrNewline::Newline(_) => {} + crate::children::Trivia::Whitespace(_) => {} }); if comment { steps.push_back(crate::builder::Step::NewLine); @@ -44,12 +44,12 @@ pub fn rule( // peek: /**/ let mut comments_before = std::collections::LinkedList::new(); let mut newlines = false; - children.drain_comments_and_newlines(|element| match element { - crate::children::DrainCommentOrNewline::Comment(text) => { + children.drain_trivia(|element| match element { + crate::children::Trivia::Comment(text) => { comments_before.push_back(crate::builder::Step::Comment(text)) } - crate::children::DrainCommentOrNewline::Newline(newlines_count) => { - if newlines_count > 0 { + crate::children::Trivia::Whitespace(text) => { + if crate::utils::count_newlines(&text) > 0 { newlines = true; } } @@ -60,11 +60,11 @@ pub fn rule( // peek: /**/ let mut comments_after = std::collections::LinkedList::new(); - children.drain_comments_and_newlines(|element| match element { - crate::children::DrainCommentOrNewline::Comment(text) => { + children.drain_trivia(|element| match element { + crate::children::Trivia::Comment(text) => { comments_after.push_back(crate::builder::Step::Comment(text)) } - crate::children::DrainCommentOrNewline::Newline(_) => {} + crate::children::Trivia::Whitespace(_) => {} }); // = diff --git a/src/alejandra_engine/src/rules/lambda.rs b/src/alejandra_engine/src/rules/lambda.rs index 9791fd1..11d6410 100644 --- a/src/alejandra_engine/src/rules/lambda.rs +++ b/src/alejandra_engine/src/rules/lambda.rs @@ -29,13 +29,13 @@ pub fn rule( } // /**/ - children.drain_comments_and_newlines(|element| match element { - crate::children::DrainCommentOrNewline::Comment(text) => { + children.drain_trivia(|element| match element { + crate::children::Trivia::Comment(text) => { steps.push_back(crate::builder::Step::Comment(text)); steps.push_back(crate::builder::Step::NewLine); steps.push_back(crate::builder::Step::Pad); } - crate::children::DrainCommentOrNewline::Newline(_) => {} + crate::children::Trivia::Whitespace(_) => {} }); // : @@ -44,14 +44,14 @@ pub fn rule( // /**/ let mut comment = false; - children.drain_comments_and_newlines(|element| match element { - crate::children::DrainCommentOrNewline::Comment(text) => { + children.drain_trivia(|element| match element { + crate::children::Trivia::Comment(text) => { comment = true; steps.push_back(crate::builder::Step::NewLine); steps.push_back(crate::builder::Step::Pad); steps.push_back(crate::builder::Step::Comment(text)); } - crate::children::DrainCommentOrNewline::Newline(_) => {} + crate::children::Trivia::Whitespace(_) => {} }); // c diff --git a/src/alejandra_engine/src/rules/let_in.rs b/src/alejandra_engine/src/rules/let_in.rs index 12b5fb0..fdd36e1 100644 --- a/src/alejandra_engine/src/rules/let_in.rs +++ b/src/alejandra_engine/src/rules/let_in.rs @@ -37,8 +37,8 @@ pub fn rule( loop { // /**/ - children.drain_comments_and_newlines(|element| match element { - crate::children::DrainCommentOrNewline::Comment(text) => { + children.drain_trivia(|element| match element { + crate::children::Trivia::Comment(text) => { if inline_next_comment && text.starts_with('#') { steps.push_back(crate::builder::Step::Whitespace); } else { @@ -48,7 +48,9 @@ pub fn rule( steps.push_back(crate::builder::Step::Comment(text)); inline_next_comment = false; } - crate::children::DrainCommentOrNewline::Newline(newlines) => { + crate::children::Trivia::Whitespace(text) => { + let newlines = crate::utils::count_newlines(&text); + if newlines > 1 && item_index > 0 && item_index < items_count { steps.push_back(crate::builder::Step::NewLine); } @@ -93,11 +95,11 @@ pub fn rule( // /**/ let mut child_comments = std::collections::LinkedList::new(); - children.drain_comments_and_newlines(|element| match element { - crate::children::DrainCommentOrNewline::Comment(text) => { + children.drain_trivia(|element| match element { + crate::children::Trivia::Comment(text) => { child_comments.push_back(crate::builder::Step::Comment(text)) } - crate::children::DrainCommentOrNewline::Newline(_) => {} + crate::children::Trivia::Whitespace(_) => {} }); // expr diff --git a/src/alejandra_engine/src/rules/list.rs b/src/alejandra_engine/src/rules/list.rs index 84445bb..efa8573 100644 --- a/src/alejandra_engine/src/rules/list.rs +++ b/src/alejandra_engine/src/rules/list.rs @@ -32,9 +32,9 @@ pub fn rule( loop { // /**/ - children.drain_comments_and_newlines(|element| { + children.drain_trivia(|element| { match element { - crate::children::DrainCommentOrNewline::Comment(text) => { + crate::children::Trivia::Comment(text) => { if inline_next_comment && text.starts_with('#') { steps.push_back(crate::builder::Step::Whitespace); } else { @@ -46,7 +46,9 @@ pub fn rule( item_index += 1; inline_next_comment = false; } - crate::children::DrainCommentOrNewline::Newline(newlines) => { + crate::children::Trivia::Whitespace(text) => { + let newlines = crate::utils::count_newlines(&text); + if newlines > 1 && item_index > 0 && item_index < items_count diff --git a/src/alejandra_engine/src/rules/paren.rs b/src/alejandra_engine/src/rules/paren.rs index 659a41a..d565c7e 100644 --- a/src/alejandra_engine/src/rules/paren.rs +++ b/src/alejandra_engine/src/rules/paren.rs @@ -21,13 +21,13 @@ pub fn rule( } // /**/ - children.drain_comments_and_newlines(|element| match element { - crate::children::DrainCommentOrNewline::Comment(text) => { + children.drain_trivia(|element| match element { + crate::children::Trivia::Comment(text) => { steps.push_back(crate::builder::Step::NewLine); steps.push_back(crate::builder::Step::Pad); steps.push_back(crate::builder::Step::Comment(text)); } - crate::children::DrainCommentOrNewline::Newline(_) => {} + crate::children::Trivia::Whitespace(_) => {} }); // expr @@ -43,13 +43,13 @@ pub fn rule( } // /**/ - children.drain_comments_and_newlines(|element| match element { - crate::children::DrainCommentOrNewline::Comment(text) => { + children.drain_trivia(|element| match element { + crate::children::Trivia::Comment(text) => { steps.push_back(crate::builder::Step::NewLine); steps.push_back(crate::builder::Step::Pad); steps.push_back(crate::builder::Step::Comment(text)); } - crate::children::DrainCommentOrNewline::Newline(_) => {} + crate::children::Trivia::Whitespace(_) => {} }); // ) diff --git a/src/alejandra_engine/src/rules/pat_bind.rs b/src/alejandra_engine/src/rules/pat_bind.rs index 6630d41..757fdb5 100644 --- a/src/alejandra_engine/src/rules/pat_bind.rs +++ b/src/alejandra_engine/src/rules/pat_bind.rs @@ -21,14 +21,14 @@ pub fn rule( // /**/ let mut comment = false; - children.drain_comments_and_newlines(|element| match element { - crate::children::DrainCommentOrNewline::Comment(text) => { + children.drain_trivia(|element| match element { + crate::children::Trivia::Comment(text) => { steps.push_back(crate::builder::Step::NewLine); steps.push_back(crate::builder::Step::Pad); steps.push_back(crate::builder::Step::Comment(text)); comment = true; } - crate::children::DrainCommentOrNewline::Newline(_) => {} + crate::children::Trivia::Whitespace(_) => {} }); if comment { diff --git a/src/alejandra_engine/src/rules/pat_entry.rs b/src/alejandra_engine/src/rules/pat_entry.rs index 5c3df52..bdebc30 100644 --- a/src/alejandra_engine/src/rules/pat_entry.rs +++ b/src/alejandra_engine/src/rules/pat_entry.rs @@ -23,14 +23,14 @@ pub fn rule( if children.has_next() { // /**/ let mut comment = false; - children.drain_comments_and_newlines(|element| match element { - crate::children::DrainCommentOrNewline::Comment(text) => { + children.drain_trivia(|element| match element { + crate::children::Trivia::Comment(text) => { steps.push_back(crate::builder::Step::NewLine); steps.push_back(crate::builder::Step::Pad); steps.push_back(crate::builder::Step::Comment(text)); comment = true; } - crate::children::DrainCommentOrNewline::Newline(_) => {} + crate::children::Trivia::Whitespace(_) => {} }); if comment { @@ -46,14 +46,14 @@ pub fn rule( // /**/ let mut comment = false; - children.drain_comments_and_newlines(|element| match element { - crate::children::DrainCommentOrNewline::Comment(text) => { + children.drain_trivia(|element| match element { + crate::children::Trivia::Comment(text) => { steps.push_back(crate::builder::Step::NewLine); steps.push_back(crate::builder::Step::Pad); steps.push_back(crate::builder::Step::Comment(text)); comment = true; } - crate::children::DrainCommentOrNewline::Newline(_) => {} + crate::children::Trivia::Whitespace(_) => {} }); // expr diff --git a/src/alejandra_engine/src/rules/root.rs b/src/alejandra_engine/src/rules/root.rs index ab85850..6b2b730 100644 --- a/src/alejandra_engine/src/rules/root.rs +++ b/src/alejandra_engine/src/rules/root.rs @@ -13,13 +13,13 @@ pub fn rule( || build_ctx.vertical; while children.has_next() { - children.drain_comments_and_newlines(|element| match element { - crate::children::DrainCommentOrNewline::Comment(text) => { + children.drain_trivia(|element| match element { + crate::children::Trivia::Comment(text) => { steps.push_back(crate::builder::Step::Comment(text)); steps.push_back(crate::builder::Step::NewLine); steps.push_back(crate::builder::Step::Pad); } - crate::children::DrainCommentOrNewline::Newline(_) => {} + crate::children::Trivia::Whitespace(_) => {} }); if let Some(child) = children.get_next() { diff --git a/src/alejandra_engine/src/rules/string_interpol.rs b/src/alejandra_engine/src/rules/string_interpol.rs index 9b5bcc8..5ba940c 100644 --- a/src/alejandra_engine/src/rules/string_interpol.rs +++ b/src/alejandra_engine/src/rules/string_interpol.rs @@ -22,13 +22,13 @@ pub fn rule( } // /**/ - children.drain_comments_and_newlines(|element| match element { - crate::children::DrainCommentOrNewline::Comment(text) => { + children.drain_trivia(|element| match element { + crate::children::Trivia::Comment(text) => { steps.push_back(crate::builder::Step::Comment(text)); steps.push_back(crate::builder::Step::NewLine); steps.push_back(crate::builder::Step::Pad); } - crate::children::DrainCommentOrNewline::Newline(_) => {} + crate::children::Trivia::Whitespace(_) => {} }); // expr @@ -40,13 +40,13 @@ pub fn rule( } // /**/ - children.drain_comments_and_newlines(|element| match element { - crate::children::DrainCommentOrNewline::Comment(text) => { + children.drain_trivia(|element| match element { + crate::children::Trivia::Comment(text) => { steps.push_back(crate::builder::Step::NewLine); steps.push_back(crate::builder::Step::Pad); steps.push_back(crate::builder::Step::Comment(text)); } - crate::children::DrainCommentOrNewline::Newline(_) => {} + crate::children::Trivia::Whitespace(_) => {} }); // }