1
Fork 0
mirror of https://github.com/RGBCube/alejandra synced 2025-07-31 12:37:45 +00:00

refactor: rename functions

- So they match the meaning more closely
This commit is contained in:
Kevin Amado 2022-02-23 14:47:36 -05:00
parent 55cb958dff
commit cd4f66b144
17 changed files with 123 additions and 105 deletions

View file

@ -9,9 +9,9 @@ pub struct Children {
current_index: usize, current_index: usize,
} }
pub enum DrainCommentOrNewline { pub enum Trivia {
Comment(String), Comment(String),
Newline(usize), Whitespace(String),
} }
impl Children { impl Children {
@ -129,7 +129,7 @@ impl Children {
self.children.iter().any(|child| { self.children.iter().any(|child| {
child.element.kind() == rnix::SyntaxKind::TOKEN_WHITESPACE child.element.kind() == rnix::SyntaxKind::TOKEN_WHITESPACE
&& crate::utils::has_newlines( && 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 Some(child) = self.peek_next() {
if let rnix::SyntaxKind::TOKEN_COMMENT = child.element.kind() { if let rnix::SyntaxKind::TOKEN_COMMENT = child.element.kind() {
callback( callback(
child.element.into_token().unwrap().text().to_string(), child
.element
.as_token()
.as_ref()
.unwrap()
.text()
.to_string(),
); );
self.move_next(); self.move_next();
} }
@ -150,7 +156,13 @@ impl Children {
match child.element.kind() { match child.element.kind() {
rnix::SyntaxKind::TOKEN_COMMENT => { rnix::SyntaxKind::TOKEN_COMMENT => {
callback( callback(
child.element.into_token().unwrap().text().to_string(), child
.element
.as_token()
.as_ref()
.unwrap()
.text()
.to_string(),
); );
self.move_next(); self.move_next();
} }
@ -161,24 +173,25 @@ impl Children {
} }
} }
pub fn drain_comments_and_newlines<F: FnMut(DrainCommentOrNewline)>( pub fn drain_trivia<F: FnMut(Trivia)>(&mut self, mut callback: F) {
&mut self,
mut callback: F,
) {
while let Some(child) = self.peek_next() { while let Some(child) = self.peek_next() {
match child.element.kind() { match child.element.kind() {
rnix::SyntaxKind::TOKEN_COMMENT => { rnix::SyntaxKind::TOKEN_COMMENT => {
callback(DrainCommentOrNewline::Comment( callback(Trivia::Comment(
child.element.into_token().unwrap().text().to_string(), child.element.into_token().unwrap().text().to_string(),
)); ));
self.move_next(); self.move_next();
} }
rnix::SyntaxKind::TOKEN_WHITESPACE => { rnix::SyntaxKind::TOKEN_WHITESPACE => {
let newlines_count = crate::utils::count_newlines( callback(Trivia::Whitespace(
child.element.clone().into_token().unwrap().text(), child
); .element
.as_token()
callback(DrainCommentOrNewline::Newline(newlines_count)); .as_ref()
.unwrap()
.text()
.to_string(),
));
self.move_next(); self.move_next();
} }
_ => { _ => {

View file

@ -35,11 +35,11 @@ pub fn parse(
} }
// /**/ // /**/
children.drain_comments_and_newlines(|element| match element { children.drain_trivia(|element| match element {
crate::children::DrainCommentOrNewline::Comment(text) => { crate::children::Trivia::Comment(text) => {
pattern.comments_after_initial_at.push_back(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 { children.drain_trivia(|element| match element {
crate::children::DrainCommentOrNewline::Comment(text) => { crate::children::Trivia::Comment(text) => {
pattern.comments_before_curly_b_close.push_back(text); pattern.comments_before_curly_b_close.push_back(text);
} }
crate::children::DrainCommentOrNewline::Newline(_) => {} crate::children::Trivia::Whitespace(_) => {}
}); });
// } // }
children.move_next(); children.move_next();
// /**/ // /**/
children.drain_comments_and_newlines(|element| match element { children.drain_trivia(|element| match element {
crate::children::DrainCommentOrNewline::Comment(text) => { crate::children::Trivia::Comment(text) => {
pattern.comments_before_end_at.push_back(text); pattern.comments_before_end_at.push_back(text);
} }
crate::children::DrainCommentOrNewline::Newline(_) => {} crate::children::Trivia::Whitespace(_) => {}
}); });
// @ x // @ x

View file

@ -22,13 +22,13 @@ pub fn rule(
} }
// /**/ // /**/
children.drain_comments_and_newlines(|element| match element { children.drain_trivia(|element| match element {
crate::children::DrainCommentOrNewline::Comment(text) => { crate::children::Trivia::Comment(text) => {
steps.push_back(crate::builder::Step::NewLine); steps.push_back(crate::builder::Step::NewLine);
steps.push_back(crate::builder::Step::Pad); steps.push_back(crate::builder::Step::Pad);
steps.push_back(crate::builder::Step::Comment(text)); steps.push_back(crate::builder::Step::Comment(text));
} }
crate::children::DrainCommentOrNewline::Newline(_) => {} crate::children::Trivia::Whitespace(_) => {}
}); });
let child_prev = children.peek_prev().unwrap(); let child_prev = children.peek_prev().unwrap();

View file

@ -18,14 +18,14 @@ pub fn rule(
// /**/ // /**/
let mut comment = false; let mut comment = false;
children.drain_comments_and_newlines(|element| match element { children.drain_trivia(|element| match element {
crate::children::DrainCommentOrNewline::Comment(text) => { crate::children::Trivia::Comment(text) => {
steps.push_back(crate::builder::Step::NewLine); steps.push_back(crate::builder::Step::NewLine);
steps.push_back(crate::builder::Step::Pad); steps.push_back(crate::builder::Step::Pad);
steps.push_back(crate::builder::Step::Comment(text)); steps.push_back(crate::builder::Step::Comment(text));
comment = true; comment = true;
} }
crate::children::DrainCommentOrNewline::Newline(_) => {} crate::children::Trivia::Whitespace(_) => {}
}); });
if comment { if comment {
@ -49,14 +49,14 @@ pub fn rule(
// /**/ // /**/
let mut comment: bool = false; let mut comment: bool = false;
children.drain_comments_and_newlines(|element| match element { children.drain_trivia(|element| match element {
crate::children::DrainCommentOrNewline::Comment(text) => { crate::children::Trivia::Comment(text) => {
steps.push_back(crate::builder::Step::NewLine); steps.push_back(crate::builder::Step::NewLine);
steps.push_back(crate::builder::Step::Pad); steps.push_back(crate::builder::Step::Pad);
steps.push_back(crate::builder::Step::Comment(text)); steps.push_back(crate::builder::Step::Comment(text));
comment = true; comment = true;
} }
crate::children::DrainCommentOrNewline::Newline(_) => {} crate::children::Trivia::Whitespace(_) => {}
}); });
// expr // expr

View file

@ -50,13 +50,13 @@ pub fn rule(
} }
// /**/ // /**/
children.drain_comments_and_newlines(|element| match element { children.drain_trivia(|element| match element {
crate::children::DrainCommentOrNewline::Comment(text) => { crate::children::Trivia::Comment(text) => {
steps.push_back(crate::builder::Step::Comment(text)); steps.push_back(crate::builder::Step::Comment(text));
steps.push_back(crate::builder::Step::NewLine); steps.push_back(crate::builder::Step::NewLine);
steps.push_back(crate::builder::Step::Pad); steps.push_back(crate::builder::Step::Pad);
} }
crate::children::DrainCommentOrNewline::Newline(_) => {} crate::children::Trivia::Whitespace(_) => {}
}); });
// { // {
@ -71,8 +71,8 @@ pub fn rule(
loop { loop {
// /**/ // /**/
children.drain_comments_and_newlines(|element| match element { children.drain_trivia(|element| match element {
crate::children::DrainCommentOrNewline::Comment(text) => { crate::children::Trivia::Comment(text) => {
if inline_next_comment && text.starts_with('#') { if inline_next_comment && text.starts_with('#') {
steps.push_back(crate::builder::Step::Whitespace); steps.push_back(crate::builder::Step::Whitespace);
} else { } else {
@ -83,7 +83,9 @@ pub fn rule(
item_index += 1; item_index += 1;
inline_next_comment = false; 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 { if newlines > 1 && item_index > 0 && item_index < items_count {
steps.push_back(crate::builder::Step::NewLine); steps.push_back(crate::builder::Step::NewLine);
} }

View file

@ -45,33 +45,32 @@ pub fn rule_with_configuration(
} }
// /**/ // /**/
children.drain_comments_and_newlines(|element| match element { children.drain_trivia(|element| match element {
crate::children::DrainCommentOrNewline::Comment(text) => { crate::children::Trivia::Comment(text) => {
steps.push_back(crate::builder::Step::Comment(text)); steps.push_back(crate::builder::Step::Comment(text));
steps.push_back(crate::builder::Step::NewLine); steps.push_back(crate::builder::Step::NewLine);
steps.push_back(crate::builder::Step::Pad); steps.push_back(crate::builder::Step::Pad);
} }
crate::children::DrainCommentOrNewline::Newline(_) => {} crate::children::Trivia::Whitespace(_) => {}
}); });
// operator // operator
let child = children.get_next().unwrap(); let child = children.get_next().unwrap();
if vertical { if !vertical && parent_kind == "bin_op_and_or_default" {
} else if parent_kind == "bin_op_and_or_default" {
steps.push_back(crate::builder::Step::Whitespace); steps.push_back(crate::builder::Step::Whitespace);
} }
steps.push_back(crate::builder::Step::Format(child.element)); steps.push_back(crate::builder::Step::Format(child.element));
// /**/ // /**/
let mut comment = false; let mut comment = false;
children.drain_comments_and_newlines(|element| match element { children.drain_trivia(|element| match element {
crate::children::DrainCommentOrNewline::Comment(text) => { crate::children::Trivia::Comment(text) => {
steps.push_back(crate::builder::Step::NewLine); steps.push_back(crate::builder::Step::NewLine);
steps.push_back(crate::builder::Step::Pad); steps.push_back(crate::builder::Step::Pad);
steps.push_back(crate::builder::Step::Comment(text)); steps.push_back(crate::builder::Step::Comment(text));
comment = true; comment = true;
} }
crate::children::DrainCommentOrNewline::Newline(_) => {} crate::children::Trivia::Whitespace(_) => {}
}); });
if comment { if comment {

View file

@ -22,13 +22,13 @@ pub fn rule(
} }
// /**/ // /**/
children.drain_comments_and_newlines(|element| match element { children.drain_trivia(|element| match element {
crate::children::DrainCommentOrNewline::Comment(text) => { crate::children::Trivia::Comment(text) => {
steps.push_back(crate::builder::Step::Comment(text)); steps.push_back(crate::builder::Step::Comment(text));
steps.push_back(crate::builder::Step::NewLine); steps.push_back(crate::builder::Step::NewLine);
steps.push_back(crate::builder::Step::Pad); steps.push_back(crate::builder::Step::Pad);
} }
crate::children::DrainCommentOrNewline::Newline(_) => {} crate::children::Trivia::Whitespace(_) => {}
}); });
// expr // expr
@ -40,13 +40,13 @@ pub fn rule(
} }
// /**/ // /**/
children.drain_comments_and_newlines(|element| match element { children.drain_trivia(|element| match element {
crate::children::DrainCommentOrNewline::Comment(text) => { crate::children::Trivia::Comment(text) => {
steps.push_back(crate::builder::Step::NewLine); steps.push_back(crate::builder::Step::NewLine);
steps.push_back(crate::builder::Step::Pad); steps.push_back(crate::builder::Step::Pad);
steps.push_back(crate::builder::Step::Comment(text)); steps.push_back(crate::builder::Step::Comment(text));
} }
crate::children::DrainCommentOrNewline::Newline(_) => {} crate::children::Trivia::Whitespace(_) => {}
}); });
// } // }

View file

@ -21,13 +21,13 @@ pub fn rule(
loop { loop {
// /**/ // /**/
children.drain_comments_and_newlines(|element| match element { children.drain_trivia(|element| match element {
crate::children::DrainCommentOrNewline::Comment(text) => { crate::children::Trivia::Comment(text) => {
steps.push_back(crate::builder::Step::NewLine); steps.push_back(crate::builder::Step::NewLine);
steps.push_back(crate::builder::Step::Pad); steps.push_back(crate::builder::Step::Pad);
steps.push_back(crate::builder::Step::Comment(text)); steps.push_back(crate::builder::Step::Comment(text));
} }
crate::children::DrainCommentOrNewline::Newline(_) => {} crate::children::Trivia::Whitespace(_) => {}
}); });
if let Some(child) = children.get_next() { if let Some(child) = children.get_next() {

View file

@ -22,14 +22,14 @@ pub fn rule(
// /**/ // /**/
let mut comment = false; let mut comment = false;
children.drain_comments_and_newlines(|element| match element { children.drain_trivia(|element| match element {
crate::children::DrainCommentOrNewline::Comment(text) => { crate::children::Trivia::Comment(text) => {
comment = true; comment = true;
steps.push_back(crate::builder::Step::NewLine); steps.push_back(crate::builder::Step::NewLine);
steps.push_back(crate::builder::Step::Pad); steps.push_back(crate::builder::Step::Pad);
steps.push_back(crate::builder::Step::Comment(text)); steps.push_back(crate::builder::Step::Comment(text));
} }
crate::children::DrainCommentOrNewline::Newline(_) => {} crate::children::Trivia::Whitespace(_) => {}
}); });
if comment { if comment {
steps.push_back(crate::builder::Step::NewLine); steps.push_back(crate::builder::Step::NewLine);
@ -44,12 +44,12 @@ pub fn rule(
// peek: /**/ // peek: /**/
let mut comments_before = std::collections::LinkedList::new(); let mut comments_before = std::collections::LinkedList::new();
let mut newlines = false; let mut newlines = false;
children.drain_comments_and_newlines(|element| match element { children.drain_trivia(|element| match element {
crate::children::DrainCommentOrNewline::Comment(text) => { crate::children::Trivia::Comment(text) => {
comments_before.push_back(crate::builder::Step::Comment(text)) comments_before.push_back(crate::builder::Step::Comment(text))
} }
crate::children::DrainCommentOrNewline::Newline(newlines_count) => { crate::children::Trivia::Whitespace(text) => {
if newlines_count > 0 { if crate::utils::count_newlines(&text) > 0 {
newlines = true; newlines = true;
} }
} }
@ -60,11 +60,11 @@ pub fn rule(
// peek: /**/ // peek: /**/
let mut comments_after = std::collections::LinkedList::new(); let mut comments_after = std::collections::LinkedList::new();
children.drain_comments_and_newlines(|element| match element { children.drain_trivia(|element| match element {
crate::children::DrainCommentOrNewline::Comment(text) => { crate::children::Trivia::Comment(text) => {
comments_after.push_back(crate::builder::Step::Comment(text)) comments_after.push_back(crate::builder::Step::Comment(text))
} }
crate::children::DrainCommentOrNewline::Newline(_) => {} crate::children::Trivia::Whitespace(_) => {}
}); });
// = // =

View file

@ -29,13 +29,13 @@ pub fn rule(
} }
// /**/ // /**/
children.drain_comments_and_newlines(|element| match element { children.drain_trivia(|element| match element {
crate::children::DrainCommentOrNewline::Comment(text) => { crate::children::Trivia::Comment(text) => {
steps.push_back(crate::builder::Step::Comment(text)); steps.push_back(crate::builder::Step::Comment(text));
steps.push_back(crate::builder::Step::NewLine); steps.push_back(crate::builder::Step::NewLine);
steps.push_back(crate::builder::Step::Pad); 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; let mut comment = false;
children.drain_comments_and_newlines(|element| match element { children.drain_trivia(|element| match element {
crate::children::DrainCommentOrNewline::Comment(text) => { crate::children::Trivia::Comment(text) => {
comment = true; comment = true;
steps.push_back(crate::builder::Step::NewLine); steps.push_back(crate::builder::Step::NewLine);
steps.push_back(crate::builder::Step::Pad); steps.push_back(crate::builder::Step::Pad);
steps.push_back(crate::builder::Step::Comment(text)); steps.push_back(crate::builder::Step::Comment(text));
} }
crate::children::DrainCommentOrNewline::Newline(_) => {} crate::children::Trivia::Whitespace(_) => {}
}); });
// c // c

View file

@ -37,8 +37,8 @@ pub fn rule(
loop { loop {
// /**/ // /**/
children.drain_comments_and_newlines(|element| match element { children.drain_trivia(|element| match element {
crate::children::DrainCommentOrNewline::Comment(text) => { crate::children::Trivia::Comment(text) => {
if inline_next_comment && text.starts_with('#') { if inline_next_comment && text.starts_with('#') {
steps.push_back(crate::builder::Step::Whitespace); steps.push_back(crate::builder::Step::Whitespace);
} else { } else {
@ -48,7 +48,9 @@ pub fn rule(
steps.push_back(crate::builder::Step::Comment(text)); steps.push_back(crate::builder::Step::Comment(text));
inline_next_comment = false; 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 { if newlines > 1 && item_index > 0 && item_index < items_count {
steps.push_back(crate::builder::Step::NewLine); steps.push_back(crate::builder::Step::NewLine);
} }
@ -93,11 +95,11 @@ pub fn rule(
// /**/ // /**/
let mut child_comments = std::collections::LinkedList::new(); let mut child_comments = std::collections::LinkedList::new();
children.drain_comments_and_newlines(|element| match element { children.drain_trivia(|element| match element {
crate::children::DrainCommentOrNewline::Comment(text) => { crate::children::Trivia::Comment(text) => {
child_comments.push_back(crate::builder::Step::Comment(text)) child_comments.push_back(crate::builder::Step::Comment(text))
} }
crate::children::DrainCommentOrNewline::Newline(_) => {} crate::children::Trivia::Whitespace(_) => {}
}); });
// expr // expr

View file

@ -32,9 +32,9 @@ pub fn rule(
loop { loop {
// /**/ // /**/
children.drain_comments_and_newlines(|element| { children.drain_trivia(|element| {
match element { match element {
crate::children::DrainCommentOrNewline::Comment(text) => { crate::children::Trivia::Comment(text) => {
if inline_next_comment && text.starts_with('#') { if inline_next_comment && text.starts_with('#') {
steps.push_back(crate::builder::Step::Whitespace); steps.push_back(crate::builder::Step::Whitespace);
} else { } else {
@ -46,7 +46,9 @@ pub fn rule(
item_index += 1; item_index += 1;
inline_next_comment = false; inline_next_comment = false;
} }
crate::children::DrainCommentOrNewline::Newline(newlines) => { crate::children::Trivia::Whitespace(text) => {
let newlines = crate::utils::count_newlines(&text);
if newlines > 1 if newlines > 1
&& item_index > 0 && item_index > 0
&& item_index < items_count && item_index < items_count

View file

@ -21,13 +21,13 @@ pub fn rule(
} }
// /**/ // /**/
children.drain_comments_and_newlines(|element| match element { children.drain_trivia(|element| match element {
crate::children::DrainCommentOrNewline::Comment(text) => { crate::children::Trivia::Comment(text) => {
steps.push_back(crate::builder::Step::NewLine); steps.push_back(crate::builder::Step::NewLine);
steps.push_back(crate::builder::Step::Pad); steps.push_back(crate::builder::Step::Pad);
steps.push_back(crate::builder::Step::Comment(text)); steps.push_back(crate::builder::Step::Comment(text));
} }
crate::children::DrainCommentOrNewline::Newline(_) => {} crate::children::Trivia::Whitespace(_) => {}
}); });
// expr // expr
@ -43,13 +43,13 @@ pub fn rule(
} }
// /**/ // /**/
children.drain_comments_and_newlines(|element| match element { children.drain_trivia(|element| match element {
crate::children::DrainCommentOrNewline::Comment(text) => { crate::children::Trivia::Comment(text) => {
steps.push_back(crate::builder::Step::NewLine); steps.push_back(crate::builder::Step::NewLine);
steps.push_back(crate::builder::Step::Pad); steps.push_back(crate::builder::Step::Pad);
steps.push_back(crate::builder::Step::Comment(text)); steps.push_back(crate::builder::Step::Comment(text));
} }
crate::children::DrainCommentOrNewline::Newline(_) => {} crate::children::Trivia::Whitespace(_) => {}
}); });
// ) // )

View file

@ -21,14 +21,14 @@ pub fn rule(
// /**/ // /**/
let mut comment = false; let mut comment = false;
children.drain_comments_and_newlines(|element| match element { children.drain_trivia(|element| match element {
crate::children::DrainCommentOrNewline::Comment(text) => { crate::children::Trivia::Comment(text) => {
steps.push_back(crate::builder::Step::NewLine); steps.push_back(crate::builder::Step::NewLine);
steps.push_back(crate::builder::Step::Pad); steps.push_back(crate::builder::Step::Pad);
steps.push_back(crate::builder::Step::Comment(text)); steps.push_back(crate::builder::Step::Comment(text));
comment = true; comment = true;
} }
crate::children::DrainCommentOrNewline::Newline(_) => {} crate::children::Trivia::Whitespace(_) => {}
}); });
if comment { if comment {

View file

@ -23,14 +23,14 @@ pub fn rule(
if children.has_next() { if children.has_next() {
// /**/ // /**/
let mut comment = false; let mut comment = false;
children.drain_comments_and_newlines(|element| match element { children.drain_trivia(|element| match element {
crate::children::DrainCommentOrNewline::Comment(text) => { crate::children::Trivia::Comment(text) => {
steps.push_back(crate::builder::Step::NewLine); steps.push_back(crate::builder::Step::NewLine);
steps.push_back(crate::builder::Step::Pad); steps.push_back(crate::builder::Step::Pad);
steps.push_back(crate::builder::Step::Comment(text)); steps.push_back(crate::builder::Step::Comment(text));
comment = true; comment = true;
} }
crate::children::DrainCommentOrNewline::Newline(_) => {} crate::children::Trivia::Whitespace(_) => {}
}); });
if comment { if comment {
@ -46,14 +46,14 @@ pub fn rule(
// /**/ // /**/
let mut comment = false; let mut comment = false;
children.drain_comments_and_newlines(|element| match element { children.drain_trivia(|element| match element {
crate::children::DrainCommentOrNewline::Comment(text) => { crate::children::Trivia::Comment(text) => {
steps.push_back(crate::builder::Step::NewLine); steps.push_back(crate::builder::Step::NewLine);
steps.push_back(crate::builder::Step::Pad); steps.push_back(crate::builder::Step::Pad);
steps.push_back(crate::builder::Step::Comment(text)); steps.push_back(crate::builder::Step::Comment(text));
comment = true; comment = true;
} }
crate::children::DrainCommentOrNewline::Newline(_) => {} crate::children::Trivia::Whitespace(_) => {}
}); });
// expr // expr

View file

@ -13,13 +13,13 @@ pub fn rule(
|| build_ctx.vertical; || build_ctx.vertical;
while children.has_next() { while children.has_next() {
children.drain_comments_and_newlines(|element| match element { children.drain_trivia(|element| match element {
crate::children::DrainCommentOrNewline::Comment(text) => { crate::children::Trivia::Comment(text) => {
steps.push_back(crate::builder::Step::Comment(text)); steps.push_back(crate::builder::Step::Comment(text));
steps.push_back(crate::builder::Step::NewLine); steps.push_back(crate::builder::Step::NewLine);
steps.push_back(crate::builder::Step::Pad); steps.push_back(crate::builder::Step::Pad);
} }
crate::children::DrainCommentOrNewline::Newline(_) => {} crate::children::Trivia::Whitespace(_) => {}
}); });
if let Some(child) = children.get_next() { if let Some(child) = children.get_next() {

View file

@ -22,13 +22,13 @@ pub fn rule(
} }
// /**/ // /**/
children.drain_comments_and_newlines(|element| match element { children.drain_trivia(|element| match element {
crate::children::DrainCommentOrNewline::Comment(text) => { crate::children::Trivia::Comment(text) => {
steps.push_back(crate::builder::Step::Comment(text)); steps.push_back(crate::builder::Step::Comment(text));
steps.push_back(crate::builder::Step::NewLine); steps.push_back(crate::builder::Step::NewLine);
steps.push_back(crate::builder::Step::Pad); steps.push_back(crate::builder::Step::Pad);
} }
crate::children::DrainCommentOrNewline::Newline(_) => {} crate::children::Trivia::Whitespace(_) => {}
}); });
// expr // expr
@ -40,13 +40,13 @@ pub fn rule(
} }
// /**/ // /**/
children.drain_comments_and_newlines(|element| match element { children.drain_trivia(|element| match element {
crate::children::DrainCommentOrNewline::Comment(text) => { crate::children::Trivia::Comment(text) => {
steps.push_back(crate::builder::Step::NewLine); steps.push_back(crate::builder::Step::NewLine);
steps.push_back(crate::builder::Step::Pad); steps.push_back(crate::builder::Step::Pad);
steps.push_back(crate::builder::Step::Comment(text)); steps.push_back(crate::builder::Step::Comment(text));
} }
crate::children::DrainCommentOrNewline::Newline(_) => {} crate::children::Trivia::Whitespace(_) => {}
}); });
// } // }