From d2e2f6c20bf60d46a04414e7beb37a79279eb99a Mon Sep 17 00:00:00 2001 From: Kevin Amado Date: Wed, 9 Feb 2022 20:14:27 -0500 Subject: [PATCH 01/19] feat: apply without max-width --- src/rules/apply.rs | 21 ++++++++++++------ tests/cases/apply/out | 7 ++++-- tests/cases/key_value/out | 3 ++- tests/cases/paren/out | 45 ++++++++++++++++++++++++++------------- 4 files changed, 51 insertions(+), 25 deletions(-) diff --git a/src/rules/apply.rs b/src/rules/apply.rs index 8f24657..1025c74 100644 --- a/src/rules/apply.rs +++ b/src/rules/apply.rs @@ -4,9 +4,11 @@ pub fn rule( ) -> std::collections::LinkedList { let mut steps = std::collections::LinkedList::new(); - let mut children = crate::children::Children::new(build_ctx, node); + let mut children = crate::children::Children::new_with_configuration( + build_ctx, node, true, + ); - let layout = if children.has_comments() { + let layout = if children.has_comments() || children.has_newlines() { &crate::config::Layout::Tall } else { build_ctx.config.layout() @@ -24,10 +26,13 @@ pub fn rule( } // /**/ - children.drain_comments(|text| { - steps.push_back(crate::builder::Step::NewLine); - steps.push_back(crate::builder::Step::Pad); - steps.push_back(crate::builder::Step::Comment(text)); + children.drain_comments_and_newlines(|element| match element { + crate::children::DrainCommentOrNewline::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(_) => {} }); let child_prev = children.peek_prev().unwrap(); @@ -36,7 +41,9 @@ pub fn rule( let child = children.get_next().unwrap(); match layout { crate::config::Layout::Tall => { - if let rnix::SyntaxKind::TOKEN_COMMENT = child_prev.element.kind() { + if let rnix::SyntaxKind::TOKEN_COMMENT + | rnix::SyntaxKind::TOKEN_WHITESPACE = child_prev.element.kind() + { steps.push_back(crate::builder::Step::NewLine); steps.push_back(crate::builder::Step::Pad); } else if let rnix::SyntaxKind::NODE_ATTR_SET diff --git a/tests/cases/apply/out b/tests/cases/apply/out index e9870bd..9a786b8 100644 --- a/tests/cases/apply/out +++ b/tests/cases/apply/out @@ -1,10 +1,13 @@ -(a b) (a b) ( +(a b) +(a b) +( a /* b */ c -) ( +) +( /* a */ diff --git a/tests/cases/key_value/out b/tests/cases/key_value/out index 509e0fd..e844a22 100644 --- a/tests/cases/key_value/out +++ b/tests/cases/key_value/out @@ -116,5 +116,6 @@ rec ; p = - aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa { } a; + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa { } + a; } diff --git a/tests/cases/paren/out b/tests/cases/paren/out index 87ddbd8..e8be796 100644 --- a/tests/cases/paren/out +++ b/tests/cases/paren/out @@ -1,17 +1,20 @@ ( - ((c)) ( + ((c)) + ( (c) /* e */ - ) ( + ) + ( ( c /* d */ ) - ) ( + ) + ( ( c /* @@ -21,14 +24,16 @@ /* e */ - ) ( + ) + ( ( /* b */ c ) - ) ( + ) + ( ( /* b @@ -38,7 +43,8 @@ /* e */ - ) ( + ) + ( ( /* b @@ -48,7 +54,8 @@ d */ ) - ) ( + ) + ( ( /* b @@ -61,12 +68,14 @@ /* e */ - ) ( + ) + ( /* a */ (c) - ) ( + ) + ( /* a */ @@ -74,7 +83,8 @@ /* e */ - ) ( + ) + ( /* a */ @@ -84,7 +94,8 @@ d */ ) - ) ( + ) + ( /* a */ @@ -97,7 +108,8 @@ /* e */ - ) ( + ) + ( /* a */ @@ -107,7 +119,8 @@ */ c ) - ) ( + ) + ( /* a */ @@ -120,7 +133,8 @@ /* e */ - ) ( + ) + ( /* a */ @@ -133,7 +147,8 @@ d */ ) - ) ( + ) + ( /* a */ From d5fd7704641290d2fe49a9aff116d5484f5790ea Mon Sep 17 00:00:00 2001 From: Kevin Amado Date: Wed, 9 Feb 2022 20:25:26 -0500 Subject: [PATCH 02/19] feat: assert without max-width --- src/rules/assert.rs | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/src/rules/assert.rs b/src/rules/assert.rs index c227c1e..73f13ca 100644 --- a/src/rules/assert.rs +++ b/src/rules/assert.rs @@ -4,9 +4,11 @@ pub fn rule( ) -> std::collections::LinkedList { let mut steps = std::collections::LinkedList::new(); - let mut children = crate::children::Children::new(build_ctx, node); + let mut children = crate::children::Children::new_with_configuration( + build_ctx, node, true, + ); - let layout = if children.has_comments() { + let layout = if children.has_comments() || children.has_newlines() { &crate::config::Layout::Tall } else { build_ctx.config.layout() @@ -17,13 +19,17 @@ pub fn rule( steps.push_back(crate::builder::Step::Format(child.element)); // /**/ - children.drain_comments(|text| { - steps.push_back(crate::builder::Step::NewLine); - steps.push_back(crate::builder::Step::Pad); - steps.push_back(crate::builder::Step::Comment(text)); + children.drain_comments_and_newlines(|element| match element { + crate::children::DrainCommentOrNewline::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(_) => {} }); - if let rnix::SyntaxKind::TOKEN_COMMENT = + if let rnix::SyntaxKind::TOKEN_COMMENT + | rnix::SyntaxKind::TOKEN_WHITESPACE = children.peek_prev().unwrap().element.kind() { steps.push_back(crate::builder::Step::NewLine); @@ -48,10 +54,13 @@ pub fn rule( steps.push_back(crate::builder::Step::Format(child.element)); // /**/ - children.drain_comments(|text| { - steps.push_back(crate::builder::Step::NewLine); - steps.push_back(crate::builder::Step::Pad); - steps.push_back(crate::builder::Step::Comment(text)); + children.drain_comments_and_newlines(|element| match element { + crate::children::DrainCommentOrNewline::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(_) => {} }); // expr From 0695123f7babad63fabfdd11d38c20122feaa1a8 Mon Sep 17 00:00:00 2001 From: Kevin Amado Date: Wed, 9 Feb 2022 20:25:36 -0500 Subject: [PATCH 03/19] feat: bin op without max-width --- src/rules/bin_op.rs | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/src/rules/bin_op.rs b/src/rules/bin_op.rs index ab4eb73..880b2cc 100644 --- a/src/rules/bin_op.rs +++ b/src/rules/bin_op.rs @@ -4,9 +4,11 @@ pub fn rule( ) -> std::collections::LinkedList { let mut steps = std::collections::LinkedList::new(); - let mut children = crate::children::Children::new(build_ctx, node); + let mut children = crate::children::Children::new_with_configuration( + build_ctx, node, true, + ); - let layout = if children.has_comments() { + let layout = if children.has_comments() || children.has_newlines() { &crate::config::Layout::Tall } else { build_ctx.config.layout() @@ -36,10 +38,13 @@ pub fn rule( } // /**/ - children.drain_comments(|text| { - steps.push_back(crate::builder::Step::Comment(text)); - steps.push_back(crate::builder::Step::NewLine); - steps.push_back(crate::builder::Step::Pad); + children.drain_comments_and_newlines(|element| match element { + crate::children::DrainCommentOrNewline::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(_) => {} }); // operator @@ -53,13 +58,17 @@ pub fn rule( steps.push_back(crate::builder::Step::Format(child.element)); // /**/ - children.drain_comments(|text| { - steps.push_back(crate::builder::Step::NewLine); - steps.push_back(crate::builder::Step::Pad); - steps.push_back(crate::builder::Step::Comment(text)); + children.drain_comments_and_newlines(|element| match element { + crate::children::DrainCommentOrNewline::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(_) => {} }); - if let rnix::SyntaxKind::TOKEN_COMMENT = + if let rnix::SyntaxKind::TOKEN_COMMENT + | rnix::SyntaxKind::TOKEN_WHITESPACE = children.peek_prev().unwrap().element.kind() { steps.push_back(crate::builder::Step::NewLine); From ba278a745425dc6efe5836a587e6811717040ca5 Mon Sep 17 00:00:00 2001 From: Kevin Amado Date: Wed, 9 Feb 2022 20:25:43 -0500 Subject: [PATCH 04/19] feat: dynamic without max-width --- src/rules/dynamic.rs | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/src/rules/dynamic.rs b/src/rules/dynamic.rs index e3ab4cc..022125f 100644 --- a/src/rules/dynamic.rs +++ b/src/rules/dynamic.rs @@ -4,9 +4,11 @@ pub fn rule( ) -> std::collections::LinkedList { let mut steps = std::collections::LinkedList::new(); - let mut children = crate::children::Children::new(build_ctx, node); + let mut children = crate::children::Children::new_with_configuration( + build_ctx, node, true, + ); - let layout = if children.has_comments() { + let layout = if children.has_comments() || children.has_newlines() { &crate::config::Layout::Tall } else { build_ctx.config.layout() @@ -25,10 +27,13 @@ pub fn rule( } // /**/ - children.drain_comments(|text| { - steps.push_back(crate::builder::Step::Comment(text)); - steps.push_back(crate::builder::Step::NewLine); - steps.push_back(crate::builder::Step::Pad); + children.drain_comments_and_newlines(|element| match element { + crate::children::DrainCommentOrNewline::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(_) => {} }); // expr @@ -43,10 +48,13 @@ pub fn rule( } // /**/ - children.drain_comments(|text| { - steps.push_back(crate::builder::Step::NewLine); - steps.push_back(crate::builder::Step::Pad); - steps.push_back(crate::builder::Step::Comment(text)); + children.drain_comments_and_newlines(|element| match element { + crate::children::DrainCommentOrNewline::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(_) => {} }); // } From cb0863f4c04c266eef32a5bfce9f705600426737 Mon Sep 17 00:00:00 2001 From: Kevin Amado Date: Wed, 9 Feb 2022 20:28:44 -0500 Subject: [PATCH 05/19] feat: inherit without max-width --- src/rules/inherit.rs | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/rules/inherit.rs b/src/rules/inherit.rs index c094dc0..58e2d86 100644 --- a/src/rules/inherit.rs +++ b/src/rules/inherit.rs @@ -4,9 +4,11 @@ pub fn rule( ) -> std::collections::LinkedList { let mut steps = std::collections::LinkedList::new(); - let mut children = crate::children::Children::new(build_ctx, node); + let mut children = crate::children::Children::new_with_configuration( + build_ctx, node, true, + ); - let layout = if children.has_comments() { + let layout = if children.has_comments() || children.has_newlines() { &crate::config::Layout::Tall } else { build_ctx.config.layout() @@ -24,10 +26,13 @@ pub fn rule( loop { // /**/ - children.drain_comments(|text| { - steps.push_back(crate::builder::Step::NewLine); - steps.push_back(crate::builder::Step::Pad); - steps.push_back(crate::builder::Step::Comment(text)); + children.drain_comments_and_newlines(|element| match element { + crate::children::DrainCommentOrNewline::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(_) => {} }); if let Some(child) = children.get_next() { From 9d95a93051e3cae95ae00e39889616268b71df4a Mon Sep 17 00:00:00 2001 From: Kevin Amado Date: Wed, 9 Feb 2022 20:30:20 -0500 Subject: [PATCH 06/19] feat: lambda without max-width --- src/rules/lambda.rs | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/src/rules/lambda.rs b/src/rules/lambda.rs index b6f4b07..4aed374 100644 --- a/src/rules/lambda.rs +++ b/src/rules/lambda.rs @@ -4,9 +4,11 @@ pub fn rule( ) -> std::collections::LinkedList { let mut steps = std::collections::LinkedList::new(); - let mut children = crate::children::Children::new(build_ctx, node); + let mut children = crate::children::Children::new_with_configuration( + build_ctx, node, true, + ); - let layout = if children.has_comments() { + let layout = if children.has_comments() || children.has_newlines() { &crate::config::Layout::Tall } else { build_ctx.config.layout() @@ -25,7 +27,8 @@ pub fn rule( } } - if let rnix::SyntaxKind::TOKEN_COMMENT = + if let rnix::SyntaxKind::TOKEN_COMMENT + | rnix::SyntaxKind::TOKEN_WHITESPACE = children.peek_next().unwrap().element.kind() { steps.push_back(crate::builder::Step::NewLine); @@ -33,10 +36,13 @@ pub fn rule( } // /**/ - children.drain_comments(|text| { - steps.push_back(crate::builder::Step::Comment(text)); - steps.push_back(crate::builder::Step::NewLine); - steps.push_back(crate::builder::Step::Pad); + children.drain_comments_and_newlines(|element| match element { + crate::children::DrainCommentOrNewline::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(_) => {} }); // : @@ -51,10 +57,13 @@ pub fn rule( } // /**/ - children.drain_comments(|text| { - steps.push_back(crate::builder::Step::NewLine); - steps.push_back(crate::builder::Step::Pad); - steps.push_back(crate::builder::Step::Comment(text)); + children.drain_comments_and_newlines(|element| match element { + crate::children::DrainCommentOrNewline::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(_) => {} }); // c @@ -65,7 +74,8 @@ pub fn rule( if is_pattern_type { steps.push_back(crate::builder::Step::NewLine); steps.push_back(crate::builder::Step::Pad); - } else if let rnix::SyntaxKind::TOKEN_COMMENT = + } else if let rnix::SyntaxKind::TOKEN_COMMENT + | rnix::SyntaxKind::TOKEN_WHITESPACE = child_prev.element.kind() { steps.push_back(crate::builder::Step::NewLine); From 94bc85ced1d763e4b5f349fcff818d1f1c259114 Mon Sep 17 00:00:00 2001 From: Kevin Amado Date: Wed, 9 Feb 2022 20:32:59 -0500 Subject: [PATCH 07/19] feat: or default without max-width --- src/rules/or_default.rs | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/src/rules/or_default.rs b/src/rules/or_default.rs index bda7296..84bf7dc 100644 --- a/src/rules/or_default.rs +++ b/src/rules/or_default.rs @@ -4,9 +4,11 @@ pub fn rule( ) -> std::collections::LinkedList { let mut steps = std::collections::LinkedList::new(); - let mut children = crate::children::Children::new(build_ctx, node); + let mut children = crate::children::Children::new_with_configuration( + build_ctx, node, true, + ); - let layout = if children.has_comments() { + let layout = if children.has_comments() || children.has_newlines() { &crate::config::Layout::Tall } else { build_ctx.config.layout() @@ -35,13 +37,17 @@ pub fn rule( } // /**/ - children.drain_comments(|text| { - steps.push_back(crate::builder::Step::NewLine); - steps.push_back(crate::builder::Step::Pad); - steps.push_back(crate::builder::Step::Comment(text)); + children.drain_comments_and_newlines(|element| match element { + crate::children::DrainCommentOrNewline::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(_) => {} }); - if let rnix::SyntaxKind::TOKEN_COMMENT = + if let rnix::SyntaxKind::TOKEN_COMMENT + | rnix::SyntaxKind::TOKEN_WHITESPACE = children.peek_prev().unwrap().element.kind() { steps.push_back(crate::builder::Step::NewLine); @@ -55,13 +61,17 @@ pub fn rule( steps.push_back(crate::builder::Step::Format(child.element)); // /**/ - children.drain_comments(|text| { - steps.push_back(crate::builder::Step::NewLine); - steps.push_back(crate::builder::Step::Pad); - steps.push_back(crate::builder::Step::Comment(text)); + children.drain_comments_and_newlines(|element| match element { + crate::children::DrainCommentOrNewline::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(_) => {} }); - if let rnix::SyntaxKind::TOKEN_COMMENT = + if let rnix::SyntaxKind::TOKEN_COMMENT + | rnix::SyntaxKind::TOKEN_WHITESPACE = children.peek_prev().unwrap().element.kind() { steps.push_back(crate::builder::Step::NewLine); From 5658798276e36001608b7b5049b771f2a2a0cca5 Mon Sep 17 00:00:00 2001 From: Kevin Amado Date: Wed, 9 Feb 2022 20:35:37 -0500 Subject: [PATCH 08/19] feat: paren without max-width --- src/rules/paren.rs | 28 ++++++++++++++++++---------- tests/cases/lambda/out | 4 +++- 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/src/rules/paren.rs b/src/rules/paren.rs index 7971b24..365e180 100644 --- a/src/rules/paren.rs +++ b/src/rules/paren.rs @@ -4,9 +4,11 @@ pub fn rule( ) -> std::collections::LinkedList { let mut steps = std::collections::LinkedList::new(); - let mut children = crate::children::Children::new(build_ctx, node); + let mut children = crate::children::Children::new_with_configuration( + build_ctx, node, true, + ); - let layout = if children.has_comments() { + let layout = if children.has_comments() || children.has_newlines() { &crate::config::Layout::Tall } else { build_ctx.config.layout() @@ -23,10 +25,13 @@ pub fn rule( } // /**/ - children.drain_comments(|text| { - steps.push_back(crate::builder::Step::NewLine); - steps.push_back(crate::builder::Step::Pad); - steps.push_back(crate::builder::Step::Comment(text)); + children.drain_comments_and_newlines(|element| match element { + crate::children::DrainCommentOrNewline::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(_) => {} }); // expr @@ -43,10 +48,13 @@ pub fn rule( } // /**/ - children.drain_comments(|text| { - steps.push_back(crate::builder::Step::NewLine); - steps.push_back(crate::builder::Step::Pad); - steps.push_back(crate::builder::Step::Comment(text)); + children.drain_comments_and_newlines(|element| match element { + crate::children::DrainCommentOrNewline::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(_) => {} }); // ) diff --git a/tests/cases/lambda/out b/tests/cases/lambda/out index 7958151..a8309a9 100644 --- a/tests/cases/lambda/out +++ b/tests/cases/lambda/out @@ -47,7 +47,9 @@ */ d ) - (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) + ( + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + ) ( aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ) From 4d9d754da5fe3488f9a6fb94ce4632dae7dbfc92 Mon Sep 17 00:00:00 2001 From: Kevin Amado Date: Wed, 9 Feb 2022 20:36:39 -0500 Subject: [PATCH 09/19] feat: pat-bind without max-width --- src/rules/pat_bind.rs | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/rules/pat_bind.rs b/src/rules/pat_bind.rs index 6aa59f8..1ffa43f 100644 --- a/src/rules/pat_bind.rs +++ b/src/rules/pat_bind.rs @@ -4,9 +4,11 @@ pub fn rule( ) -> std::collections::LinkedList { let mut steps = std::collections::LinkedList::new(); - let mut children = crate::children::Children::new(build_ctx, node); + let mut children = crate::children::Children::new_with_configuration( + build_ctx, node, true, + ); - let layout = if children.has_comments() { + let layout = if children.has_comments() || children.has_newlines() { &crate::config::Layout::Tall } else { build_ctx.config.layout() @@ -23,13 +25,17 @@ pub fn rule( } // /**/ - children.drain_comments(|text| { - steps.push_back(crate::builder::Step::NewLine); - steps.push_back(crate::builder::Step::Pad); - steps.push_back(crate::builder::Step::Comment(text)); + children.drain_comments_and_newlines(|element| match element { + crate::children::DrainCommentOrNewline::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(_) => {} }); - if let rnix::SyntaxKind::TOKEN_COMMENT = + if let rnix::SyntaxKind::TOKEN_COMMENT + | rnix::SyntaxKind::TOKEN_WHITESPACE = children.peek_prev().unwrap().element.kind() { steps.push_back(crate::builder::Step::NewLine); From 76d0d5541ef4f1f745c15cf13f8a6487084bf8d4 Mon Sep 17 00:00:00 2001 From: Kevin Amado Date: Wed, 9 Feb 2022 20:38:01 -0500 Subject: [PATCH 10/19] feat: pat-entry without max-width --- src/rules/pat_entry.rs | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/src/rules/pat_entry.rs b/src/rules/pat_entry.rs index ee30f6f..e92a3b7 100644 --- a/src/rules/pat_entry.rs +++ b/src/rules/pat_entry.rs @@ -4,9 +4,11 @@ pub fn rule( ) -> std::collections::LinkedList { let mut steps = std::collections::LinkedList::new(); - let mut children = crate::children::Children::new(build_ctx, node); + let mut children = crate::children::Children::new_with_configuration( + build_ctx, node, true, + ); - let layout = if children.has_comments() { + let layout = if children.has_comments() || children.has_newlines() { &crate::config::Layout::Tall } else { build_ctx.config.layout() @@ -26,13 +28,17 @@ pub fn rule( if children.has_next() { // /**/ - children.drain_comments(|text| { - steps.push_back(crate::builder::Step::NewLine); - steps.push_back(crate::builder::Step::Pad); - steps.push_back(crate::builder::Step::Comment(text)); + children.drain_comments_and_newlines(|element| match element { + crate::children::DrainCommentOrNewline::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(_) => {} }); - if let rnix::SyntaxKind::TOKEN_COMMENT = + if let rnix::SyntaxKind::TOKEN_COMMENT + | rnix::SyntaxKind::TOKEN_WHITESPACE = children.peek_prev().unwrap().element.kind() { steps.push_back(crate::builder::Step::NewLine); @@ -46,10 +52,13 @@ pub fn rule( steps.push_back(crate::builder::Step::Format(child.element)); // /**/ - children.drain_comments(|text| { - steps.push_back(crate::builder::Step::NewLine); - steps.push_back(crate::builder::Step::Pad); - steps.push_back(crate::builder::Step::Comment(text)); + children.drain_comments_and_newlines(|element| match element { + crate::children::DrainCommentOrNewline::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(_) => {} }); if let rnix::SyntaxKind::TOKEN_COMMENT = From 6d47a4b6803a1be94724a27d4b2b9e2753bcc303 Mon Sep 17 00:00:00 2001 From: Kevin Amado Date: Wed, 9 Feb 2022 20:49:56 -0500 Subject: [PATCH 11/19] feat: pattern without max-width --- src/rules/pat_entry.rs | 3 ++- src/rules/pattern.rs | 45 ++++++++++++++++++++++++++++++------------ 2 files changed, 34 insertions(+), 14 deletions(-) diff --git a/src/rules/pat_entry.rs b/src/rules/pat_entry.rs index e92a3b7..046da16 100644 --- a/src/rules/pat_entry.rs +++ b/src/rules/pat_entry.rs @@ -61,7 +61,8 @@ pub fn rule( crate::children::DrainCommentOrNewline::Newline(_) => {} }); - if let rnix::SyntaxKind::TOKEN_COMMENT = + if let rnix::SyntaxKind::TOKEN_COMMENT + | rnix::SyntaxKind::TOKEN_WHITESPACE = children.peek_prev().unwrap().element.kind() { steps.push_back(crate::builder::Step::NewLine); diff --git a/src/rules/pattern.rs b/src/rules/pattern.rs index debf03b..c8c3879 100644 --- a/src/rules/pattern.rs +++ b/src/rules/pattern.rs @@ -4,7 +4,9 @@ pub fn rule( ) -> std::collections::LinkedList { let mut steps = std::collections::LinkedList::new(); - let mut children = crate::children::Children::new(build_ctx, node); + let mut children = crate::children::Children::new_with_configuration( + build_ctx, node, true, + ); let has_comments = children.has_comments(); let has_comments_between_curly_b = node @@ -26,7 +28,7 @@ pub fn rule( }) .count(); - let layout = if has_comments { + let layout = if has_comments || children.has_newlines() { &crate::config::Layout::Tall } else { build_ctx.config.layout() @@ -55,10 +57,13 @@ pub fn rule( } // /**/ - children.drain_comments(|text| { - steps.push_back(crate::builder::Step::Comment(text)); - steps.push_back(crate::builder::Step::NewLine); - steps.push_back(crate::builder::Step::Pad); + children.drain_comments_and_newlines(|element| match element { + crate::children::DrainCommentOrNewline::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(_) => {} }); // { @@ -79,6 +84,7 @@ pub fn rule( if let rnix::SyntaxKind::TOKEN_COMMENT | rnix::SyntaxKind::TOKEN_ELLIPSIS + | rnix::SyntaxKind::TOKEN_WHITESPACE | rnix::SyntaxKind::NODE_PAT_ENTRY = prev_kind { steps.push_back(crate::builder::Step::Indent); @@ -86,14 +92,18 @@ pub fn rule( steps.push_back(crate::builder::Step::Pad); } - children.drain_comment(|text| { - steps.push_back(crate::builder::Step::Comment(text)); + children.drain_comments_and_newlines(|element| match element { + crate::children::DrainCommentOrNewline::Comment(text) => { + steps.push_back(crate::builder::Step::Comment(text)); + } + crate::children::DrainCommentOrNewline::Newline(_) => {} }); if let rnix::SyntaxKind::TOKEN_COMMA | rnix::SyntaxKind::TOKEN_CURLY_B_OPEN | rnix::SyntaxKind::TOKEN_COMMENT | rnix::SyntaxKind::TOKEN_ELLIPSIS + | rnix::SyntaxKind::TOKEN_WHITESPACE | rnix::SyntaxKind::NODE_PAT_ENTRY = prev_kind { steps.push_back(crate::builder::Step::Dedent); @@ -110,7 +120,9 @@ pub fn rule( steps.push_back(crate::builder::Step::Whitespace); } - if let rnix::SyntaxKind::TOKEN_COMMENT = prev_kind { + if let rnix::SyntaxKind::TOKEN_COMMENT + | rnix::SyntaxKind::TOKEN_WHITESPACE = prev_kind + { steps.push_back(crate::builder::Step::NewLine); steps.push_back(crate::builder::Step::Pad); steps.push_back(crate::builder::Step::Whitespace); @@ -143,6 +155,10 @@ pub fn rule( steps.push_back(crate::builder::Step::Format(child.element)); children.move_next(); } + // \n + rnix::SyntaxKind::TOKEN_WHITESPACE => { + children.move_next(); + } _ => { break; } @@ -160,10 +176,13 @@ pub fn rule( steps.push_back(crate::builder::Step::Format(child.element)); // /**/ - children.drain_comments(|text| { - steps.push_back(crate::builder::Step::NewLine); - steps.push_back(crate::builder::Step::Pad); - steps.push_back(crate::builder::Step::Comment(text)); + children.drain_comments_and_newlines(|element| match element { + crate::children::DrainCommentOrNewline::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(_) => {} }); // @ x From 1dd2d0c7cb98c3584d64079459d83e3f4bfea2ba Mon Sep 17 00:00:00 2001 From: Kevin Amado Date: Wed, 9 Feb 2022 20:51:12 -0500 Subject: [PATCH 12/19] feat: root without max-width --- src/rules/root.rs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/rules/root.rs b/src/rules/root.rs index 5473245..16b2336 100644 --- a/src/rules/root.rs +++ b/src/rules/root.rs @@ -4,18 +4,24 @@ pub fn rule( ) -> std::collections::LinkedList { let mut steps = std::collections::LinkedList::new(); - let mut children = crate::children::Children::new(build_ctx, node); + let mut children = crate::children::Children::new_with_configuration( + build_ctx, node, true, + ); - let layout = if children.has_comments() { + let layout = if children.has_comments() || children.has_newlines() { &crate::config::Layout::Tall } else { build_ctx.config.layout() }; while children.has_next() { - children.drain_comments(|text| { - steps.push_back(crate::builder::Step::Comment(text)); - steps.push_back(crate::builder::Step::NewLine); + children.drain_comments_and_newlines(|element| match element { + crate::children::DrainCommentOrNewline::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(_) => {} }); if let Some(child) = children.get_next() { From 0324b927fc5551502efe2c789e60146644eac63f Mon Sep 17 00:00:00 2001 From: Kevin Amado Date: Wed, 9 Feb 2022 20:52:42 -0500 Subject: [PATCH 13/19] feat: select without max-width --- src/rules/select.rs | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/src/rules/select.rs b/src/rules/select.rs index 912837d..b4e925c 100644 --- a/src/rules/select.rs +++ b/src/rules/select.rs @@ -4,9 +4,11 @@ pub fn rule( ) -> std::collections::LinkedList { let mut steps = std::collections::LinkedList::new(); - let mut children = crate::children::Children::new(build_ctx, node); + let mut children = crate::children::Children::new_with_configuration( + build_ctx, node, true, + ); - let layout = if children.has_comments() { + let layout = if children.has_comments() || children.has_newlines() { &crate::config::Layout::Tall } else { build_ctx.config.layout() @@ -35,10 +37,13 @@ pub fn rule( } // /**/ - children.drain_comments(|text| { - steps.push_back(crate::builder::Step::Comment(text)); - steps.push_back(crate::builder::Step::NewLine); - steps.push_back(crate::builder::Step::Pad); + children.drain_comments_and_newlines(|element| match element { + crate::children::DrainCommentOrNewline::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(_) => {} }); // . @@ -46,13 +51,17 @@ pub fn rule( steps.push_back(crate::builder::Step::Format(child.element)); // /**/ - children.drain_comments(|text| { - steps.push_back(crate::builder::Step::NewLine); - steps.push_back(crate::builder::Step::Pad); - steps.push_back(crate::builder::Step::Comment(text)); + children.drain_comments_and_newlines(|element| match element { + crate::children::DrainCommentOrNewline::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(_) => {} }); - if let rnix::SyntaxKind::TOKEN_COMMENT = + if let rnix::SyntaxKind::TOKEN_COMMENT + | rnix::SyntaxKind::TOKEN_WHITESPACE = children.peek_prev().unwrap().element.kind() { steps.push_back(crate::builder::Step::NewLine); From 825b08bcb507c0075a17cef0645e907a8056833c Mon Sep 17 00:00:00 2001 From: Kevin Amado Date: Wed, 9 Feb 2022 20:55:00 -0500 Subject: [PATCH 14/19] feat: string-interpol without max-width --- src/rules/string_interpol.rs | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/src/rules/string_interpol.rs b/src/rules/string_interpol.rs index e3ab4cc..022125f 100644 --- a/src/rules/string_interpol.rs +++ b/src/rules/string_interpol.rs @@ -4,9 +4,11 @@ pub fn rule( ) -> std::collections::LinkedList { let mut steps = std::collections::LinkedList::new(); - let mut children = crate::children::Children::new(build_ctx, node); + let mut children = crate::children::Children::new_with_configuration( + build_ctx, node, true, + ); - let layout = if children.has_comments() { + let layout = if children.has_comments() || children.has_newlines() { &crate::config::Layout::Tall } else { build_ctx.config.layout() @@ -25,10 +27,13 @@ pub fn rule( } // /**/ - children.drain_comments(|text| { - steps.push_back(crate::builder::Step::Comment(text)); - steps.push_back(crate::builder::Step::NewLine); - steps.push_back(crate::builder::Step::Pad); + children.drain_comments_and_newlines(|element| match element { + crate::children::DrainCommentOrNewline::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(_) => {} }); // expr @@ -43,10 +48,13 @@ pub fn rule( } // /**/ - children.drain_comments(|text| { - steps.push_back(crate::builder::Step::NewLine); - steps.push_back(crate::builder::Step::Pad); - steps.push_back(crate::builder::Step::Comment(text)); + children.drain_comments_and_newlines(|element| match element { + crate::children::DrainCommentOrNewline::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(_) => {} }); // } From 4c1f4644eccb8dcc0446d08f6414d72732f8fa6d Mon Sep 17 00:00:00 2001 From: Kevin Amado Date: Wed, 9 Feb 2022 21:04:06 -0500 Subject: [PATCH 15/19] fix: pattern comments --- src/rules/pattern.rs | 7 ++--- tests/cases/pattern/in | 39 +++++++++++++++++++++++++ tests/cases/pattern/out | 64 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 105 insertions(+), 5 deletions(-) diff --git a/src/rules/pattern.rs b/src/rules/pattern.rs index c8c3879..dd17f35 100644 --- a/src/rules/pattern.rs +++ b/src/rules/pattern.rs @@ -92,11 +92,8 @@ pub fn rule( steps.push_back(crate::builder::Step::Pad); } - children.drain_comments_and_newlines(|element| match element { - crate::children::DrainCommentOrNewline::Comment(text) => { - steps.push_back(crate::builder::Step::Comment(text)); - } - crate::children::DrainCommentOrNewline::Newline(_) => {} + children.drain_comment(|text| { + steps.push_back(crate::builder::Step::Comment(text)); }); if let rnix::SyntaxKind::TOKEN_COMMA diff --git a/tests/cases/pattern/in b/tests/cases/pattern/in index 7afd85b..1c6b7a0 100644 --- a/tests/cases/pattern/in +++ b/tests/cases/pattern/in @@ -74,4 +74,43 @@ ({ a ? null }: _) ({ /*a*/ b /*a*/ ? /*a*/ null /*c*/ , /*d*/ e /*a*/ ? /*a*/ null /*f*/ , /*g*/ ... /*h*/ }: _) + + ({ + /*a*/ + # + b + /*a*/ + # + ? + /*a*/ + # + null + /*c*/ + # + , + /*d*/ + # + e + /*a*/ + # + ? + /*a*/ + # + null + /*f*/ + # + , + /*g*/ + # + ... + /*h*/ + # + } + /*i*/ + # + : + /*j*/ + # + _ + ) ] diff --git a/tests/cases/pattern/out b/tests/cases/pattern/out index a09a076..f60344d 100644 --- a/tests/cases/pattern/out +++ b/tests/cases/pattern/out @@ -1094,4 +1094,68 @@ }: _ ) + + ( + { + /* + a + */ + # + b + /* + a + */ + # + ? + /* + a + */ + # + null + /* + c + */ + # + , + /* + d + */ + # + e + /* + a + */ + # + ? + /* + a + */ + # + null + /* + f + */ + # + , + /* + g + */ + # + ... + /* + h + */ + # + } + /* + i + */ + # + : + /* + j + */ + # + _ + ) ] From 7077ad128c9752b19f4e42cf433a6afea0472f0a Mon Sep 17 00:00:00 2001 From: Kevin Amado Date: Wed, 9 Feb 2022 21:07:59 -0500 Subject: [PATCH 16/19] feat: with without max-width --- src/rules/with.rs | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/src/rules/with.rs b/src/rules/with.rs index 60b6bb1..6a13f60 100644 --- a/src/rules/with.rs +++ b/src/rules/with.rs @@ -4,9 +4,11 @@ pub fn rule( ) -> std::collections::LinkedList { let mut steps = std::collections::LinkedList::new(); - let mut children = crate::children::Children::new(build_ctx, node); + let mut children = crate::children::Children::new_with_configuration( + build_ctx, node, true, + ); - let layout = if children.has_comments() { + let layout = if children.has_comments() || children.has_newlines() { &crate::config::Layout::Tall } else { build_ctx.config.layout() @@ -17,13 +19,17 @@ pub fn rule( steps.push_back(crate::builder::Step::Format(child.element)); // /**/ - children.drain_comments(|text| { - steps.push_back(crate::builder::Step::NewLine); - steps.push_back(crate::builder::Step::Pad); - steps.push_back(crate::builder::Step::Comment(text)); + children.drain_comments_and_newlines(|element| match element { + crate::children::DrainCommentOrNewline::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(_) => {} }); - if let rnix::SyntaxKind::TOKEN_COMMENT = + if let rnix::SyntaxKind::TOKEN_COMMENT + | rnix::SyntaxKind::TOKEN_WHITESPACE = children.peek_prev().unwrap().element.kind() { steps.push_back(crate::builder::Step::NewLine); @@ -48,10 +54,13 @@ pub fn rule( steps.push_back(crate::builder::Step::Format(child.element)); // /**/ - children.drain_comments(|text| { - steps.push_back(crate::builder::Step::NewLine); - steps.push_back(crate::builder::Step::Pad); - steps.push_back(crate::builder::Step::Comment(text)); + children.drain_comments_and_newlines(|element| match element { + crate::children::DrainCommentOrNewline::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(_) => {} }); // expr From 7e692f2251961233cb8912ac9e07e2b5f8e20b67 Mon Sep 17 00:00:00 2001 From: Kevin Amado Date: Wed, 9 Feb 2022 21:20:40 -0500 Subject: [PATCH 17/19] feat: remove max-width --- src/builder.rs | 6 ++---- src/cli.rs | 8 -------- src/config.rs | 19 +++++-------------- src/main.rs | 7 +------ tests/cases/assert/in | 3 ++- tests/cases/attr_set/in | 7 ++++++- tests/cases/bin_op/in | 3 ++- tests/cases/inherit/in | 6 ++++-- tests/cases/lambda/in | 3 ++- tests/cases/or_default/in | 3 ++- tests/cases/select/in | 3 ++- tests/cases/string/out | 4 +--- tests/cases/with/in | 3 ++- 13 files changed, 31 insertions(+), 44 deletions(-) diff --git a/src/builder.rs b/src/builder.rs index e129dfb..639a341 100644 --- a/src/builder.rs +++ b/src/builder.rs @@ -296,6 +296,7 @@ pub fn fits_in_single_line( build_ctx: &crate::builder::BuildCtx, node: rnix::SyntaxElement, ) -> bool { + let line = build_ctx.pos_new.line; let maybe_green_node = build( &build_ctx.config.with_layout(crate::config::Layout::Wide), node, @@ -304,10 +305,7 @@ pub fn fits_in_single_line( ); match maybe_green_node { - Some(finished) => { - build_ctx.pos_new.column + finished.to_string().chars().count() - <= build_ctx.config.max_width() - } + Some(_) => build_ctx.pos_new.line == line, None => false, } } diff --git a/src/cli.rs b/src/cli.rs index 2ed264f..aa00452 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -8,14 +8,6 @@ pub fn parse(args: Vec) -> clap::ArgMatches { .short('d') .takes_value(false), ) - .arg( - clap::Arg::new("max-width") - .default_value("80") - .help("How many characters per line to allow.") - .long("max-width") - .takes_value(true) - .value_name("CHARS"), - ) .arg( clap::Arg::new("paths") .help("Files or directories, or none to format stdin.") diff --git a/src/config.rs b/src/config.rs index 326be5a..10205b3 100644 --- a/src/config.rs +++ b/src/config.rs @@ -6,14 +6,13 @@ pub enum Layout { #[derive(Clone)] pub struct Config { - debug: bool, - layout: Layout, - max_width: usize, + debug: bool, + layout: Layout, } impl Config { pub fn new() -> Config { - Config { debug: false, layout: Layout::Tall, max_width: 80 } + Config { debug: false, layout: Layout::Tall } } pub fn debug(&self) -> bool { @@ -24,19 +23,11 @@ impl Config { &self.layout } - pub fn max_width(&self) -> usize { - self.max_width - } - pub fn with_debug(&self, debug: bool) -> Config { - Config { debug, layout: self.layout.clone(), max_width: self.max_width } + Config { debug, layout: self.layout.clone() } } pub fn with_layout(&self, layout: Layout) -> Config { - Config { debug: self.debug, layout, max_width: self.max_width } - } - - pub fn with_max_width(&self, max_width: usize) -> Config { - Config { debug: self.debug, layout: self.layout.clone(), max_width } + Config { debug: self.debug, layout } } } diff --git a/src/main.rs b/src/main.rs index c3bbb1c..f03dfda 100644 --- a/src/main.rs +++ b/src/main.rs @@ -5,12 +5,7 @@ fn main() -> std::io::Result<()> { let matches = alejandra::cli::parse(std::env::args().collect()); let debug: bool = matches.is_present("debug"); - let max_width: usize = - matches.value_of("max-width").unwrap().parse().unwrap(); - - let config = alejandra::config::Config::new() - .with_debug(debug) - .with_max_width(max_width); + let config = alejandra::config::Config::new().with_debug(debug); match matches.values_of("paths") { Some(paths) => { diff --git a/tests/cases/assert/in b/tests/cases/assert/in index eb9708d..1e8d1f3 100644 --- a/tests/cases/assert/in +++ b/tests/cases/assert/in @@ -4,5 +4,6 @@ (assert /*a*/ b; c) (assert /*a*/ b; /*b*/ c) ( assert b; cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc ) - ( assert b; cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc ) + ( assert b; + cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc ) ] diff --git a/tests/cases/attr_set/in b/tests/cases/attr_set/in index 8b55224..2af0248 100644 --- a/tests/cases/attr_set/in +++ b/tests/cases/attr_set/in @@ -19,7 +19,12 @@ rec /*a*/ { /*b*/ c=1; } rec /*a*/ { /*b*/ c=1; /*d*/ } - {a=rec {a={a=rec {a={a=rec {a={a=rec {a={a=rec {a={};};};};};};};};};};} + { + a=rec { + a={ + a=rec { + a={ + a=rec {a={a=rec {a={a=rec {a={};};};};};};};};};};} rec { diff --git a/tests/cases/bin_op/in b/tests/cases/bin_op/in index 61a9cb9..a74a5fe 100644 --- a/tests/cases/bin_op/in +++ b/tests/cases/bin_op/in @@ -5,5 +5,6 @@ (1/**/+/**/1) (1/**/+/**/(1/**/+/**/(1/**/+/**/1))) ( 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 ) - ( 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1) + ( 1 + + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1) ] diff --git a/tests/cases/inherit/in b/tests/cases/inherit/in index b0c31d5..3e924ed 100644 --- a/tests/cases/inherit/in +++ b/tests/cases/inherit/in @@ -1,6 +1,8 @@ [ - { inherit aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa; } - { inherit aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa; } + { + inherit aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa; } + { inherit + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa; } { inherit b d ; } { inherit b d /*e*/ ; } { inherit b /*c*/ d ; } diff --git a/tests/cases/lambda/in b/tests/cases/lambda/in index c467519..bff1206 100644 --- a/tests/cases/lambda/in +++ b/tests/cases/lambda/in @@ -9,6 +9,7 @@ ( aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ) - ( aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ) + ( + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ) ({ pkgs ? import ./.. { }, locationsXml }: null) ] diff --git a/tests/cases/or_default/in b/tests/cases/or_default/in index b75e390..aa4d7f1 100644 --- a/tests/cases/or_default/in +++ b/tests/cases/or_default/in @@ -5,5 +5,6 @@ (a/**/?/**/a) (a/**/?/**/(a/**/?/**/(a/**/?/**/a))) ( a ? a ? a ? a ? a ? a ? a ? a ? a ? a ? a ? a ? a ? a ? a ? a ? a ? a ? a ) - ( a ? a ? a ? a ? a ? a ? a ? a ? a ? a ? a ? a ? a ? a ? a ? a ? a ? a ? a ? a) + ( a ? a + ? a ? a ? a ? a ? a ? a ? a ? a ? a ? a ? a ? a ? a ? a ? a ? a ? a ? a) ] diff --git a/tests/cases/select/in b/tests/cases/select/in index 8ffc381..c66751e 100644 --- a/tests/cases/select/in +++ b/tests/cases/select/in @@ -4,5 +4,6 @@ (a/**/. a) (a/**/./**/a) ( a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a ) - ( a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a ) + ( a.a + .a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a.a ) ] diff --git a/tests/cases/string/out b/tests/cases/string/out index 4c6f927..c858487 100644 --- a/tests/cases/string/out +++ b/tests/cases/string/out @@ -58,9 +58,7 @@ [${mkSectionName sectName}] '' ### - ''-couch_ini ${cfg.package}/etc/default.ini ${configFile} ${ - pkgs.writeText "couchdb-extra.ini" cfg.extraConfig - } ${cfg.configFile}'' + ''-couch_ini ${cfg.package}/etc/default.ini ${configFile} ${pkgs.writeText "couchdb-extra.ini" cfg.extraConfig} ${cfg.configFile}'' ### ''exec i3-input -F "mark %s" -l 1 -P 'Mark: ' '' ### diff --git a/tests/cases/with/in b/tests/cases/with/in index 1a36adf..922aa33 100644 --- a/tests/cases/with/in +++ b/tests/cases/with/in @@ -4,5 +4,6 @@ (with /*a*/ b; c) (with /*a*/ b; /*b*/ c) ( with b; cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc ) - ( with b; cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc ) + ( with b; + cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc ) ] From 23329ebca0b931aeb7757b71bbaeabad289ded1f Mon Sep 17 00:00:00 2001 From: Kevin Amado Date: Wed, 9 Feb 2022 21:38:01 -0500 Subject: [PATCH 18/19] test: increase coverage --- src/children.rs | 25 --------- tests/cases/or_default/in | 18 ++++--- tests/cases/or_default/out | 103 +++++++++++++++++++------------------ 3 files changed, 62 insertions(+), 84 deletions(-) diff --git a/src/children.rs b/src/children.rs index 229ed16..1a68b04 100644 --- a/src/children.rs +++ b/src/children.rs @@ -133,31 +133,6 @@ impl Children { }) } - pub fn drain_newlines(&mut self, mut callback: F) { - let mut newlines = 0; - - while let Some(child) = self.peek_next() { - match child.element.kind() { - rnix::SyntaxKind::TOKEN_WHITESPACE => { - newlines += child - .element - .into_token() - .unwrap() - .text() - .chars() - .filter(|c| *c == '\n') - .count(); - self.move_next(); - } - _ => { - break; - } - } - } - - callback(newlines) - } - pub fn drain_comment(&mut self, mut callback: F) { if let Some(child) = self.peek_next() { match child.element.kind() { diff --git a/tests/cases/or_default/in b/tests/cases/or_default/in index aa4d7f1..2e46e24 100644 --- a/tests/cases/or_default/in +++ b/tests/cases/or_default/in @@ -1,10 +1,12 @@ [ - (a ? a) - (a ?/**/a) - (a/**/? a) - (a/**/?/**/a) - (a/**/?/**/(a/**/?/**/(a/**/?/**/a))) - ( a ? a ? a ? a ? a ? a ? a ? a ? a ? a ? a ? a ? a ? a ? a ? a ? a ? a ? a ) - ( a ? a - ? a ? a ? a ? a ? a ? a ? a ? a ? a ? a ? a ? a ? a ? a ? a ? a ? a ? a) + (a or a) + (a or/**/a) + (a/**/or a) + (a/**/or/**/a) + (a/**/or/**/(a/**/or/**/(a/**/or/**/a))) + (a/**/or/**/(a/**/or/**/(a/**/or/**/a))) + ( a or a or a or a or a or a or a or a or a or a or a or a or a or a or a or a or a or a or a ) + ( a or a + or a + or a or a or a or a or a or a or a or a or a or a or a or a or a or a or a or a or a) ] diff --git a/tests/cases/or_default/out b/tests/cases/or_default/out index c19e5bc..518869f 100644 --- a/tests/cases/or_default/out +++ b/tests/cases/or_default/out @@ -1,63 +1,64 @@ [ - (a ? a) + (a or a) ( - a - ? - /**/ - a - ) - ( - a - /**/ - ? a - ) - ( - a - /**/ - ? - /**/ - a - ) - ( - a - /**/ - ? - /**/ - ( - a + a or /**/ - ? + a + ) + ( + a + /**/ + or a + ) + ( + a + /**/ + or + /**/ + a + ) + ( + a + /**/ + or /**/ ( a - /**/ - ? - /**/ - a + /**/ + or + /**/ + ( + a + /**/ + or + /**/ + a + ) ) - ) ) - (a ? a ? a ? a ? a ? a ? a ? a ? a ? a ? a ? a ? a ? a ? a ? a ? a ? a ? a) ( a - ? a - ? a - ? a - ? a - ? a - ? a - ? a - ? a - ? a - ? a - ? a - ? a - ? a - ? a - ? a - ? a - ? a - ? a - ? a + /**/ + or + /**/ + ( + a + /**/ + or + /**/ + ( + a + /**/ + or + /**/ + a + ) + ) + ) + (a or a or a or a or a or a or a or a or a or a or a or a or a or a or a or a or a or a or a) + ( + a or a + or a + or a or a or a or a or a or a or a or a or a or a or a or a or a or a or a or a or a ) ] From 47936c83fe20182ce65c5ac9c3fd4815b936c0fc Mon Sep 17 00:00:00 2001 From: Kevin Amado Date: Wed, 9 Feb 2022 22:05:23 -0500 Subject: [PATCH 19/19] feat: keep funcs implementations on same line --- flake.nix | 99 ++++++++++++++------------- src/rules/lambda.rs | 60 ++++++++++++---- tests/cases/key_value/out | 12 ++-- tests/cases/lambda/in | 4 ++ tests/cases/lambda/out | 38 +++++++---- tests/cases/pat_bind/out | 12 ++-- tests/cases/pattern/out | 140 +++++++++++++++++++------------------- 7 files changed, 207 insertions(+), 158 deletions(-) diff --git a/flake.nix b/flake.nix index 9bbde25..f987291 100644 --- a/flake.nix +++ b/flake.nix @@ -4,61 +4,68 @@ fenix.url = "github:nix-community/fenix"; fenix.inputs.nixpkgs.follows = "nixpkgs"; fenix.inputs.rust-analyzer-src.follows = "rustAnalyzer"; + flakeCompat.url = github:edolstra/flake-compat; flakeCompat.flake = false; + flakeUtils.url = "github:numtide/flake-utils"; + nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable"; + rustAnalyzer.url = "github:rust-analyzer/rust-analyzer"; rustAnalyzer.flake = false; + treefmt.url = "github:numtide/treefmt"; treefmt.inputs.flake-utils.follows = "flakeUtils"; treefmt.inputs.nixpkgs.follows = "nixpkgs"; }; - outputs = inputs: inputs.flakeUtils.lib.eachSystem [ "x86_64-darwin" "x86_64-linux" ] ( - system: let - nixpkgs = import inputs.nixpkgs { inherit system; }; - cargoToml = builtins.fromTOML (builtins.readFile ./Cargo.toml); - treefmt = inputs.treefmt.defaultPackage.${system}; - fenix = inputs.fenix.packages.${system}; - fenixPlatform = nixpkgs.makeRustPlatform { inherit (fenix.latest) cargo rustc; }; - in - { - checks.defaultPackage = inputs.self.defaultPackage.${system}; - defaultApp = { - type = "app"; - program = "${inputs.self.defaultPackage.${system}}/bin/alejandra"; - }; - defaultPackage = fenixPlatform.buildRustPackage { - pname = cargoToml.package.name; - version = - let - commit = inputs.self.shortRev or "dirty"; - date = inputs.self.lastModifiedDate or inputs.self.lastModified or "19700101"; - in - "${builtins.substring 0 8 date}_${commit}"; - src = inputs.self.sourceInfo; - cargoLock.lockFile = ./Cargo.lock; - meta = { - description = cargoToml.package.description; - homepage = "https://github.com/kamadorueda/alejandra"; - license = nixpkgs.lib.licenses.unlicense; - maintainers = [ nixpkgs.lib.maintainers.kamadorueda ]; + outputs = inputs: + inputs.flakeUtils.lib.eachSystem [ "x86_64-darwin" "x86_64-linux" ] ( + system: let + nixpkgs = import inputs.nixpkgs { inherit system; }; + cargoToml = builtins.fromTOML (builtins.readFile ./Cargo.toml); + treefmt = inputs.treefmt.defaultPackage.${system}; + fenix = inputs.fenix.packages.${system}; + fenixPlatform = nixpkgs.makeRustPlatform { inherit (fenix.latest) cargo rustc; }; + in + { + checks.defaultPackage = inputs.self.defaultPackage.${system}; + defaultApp = { + type = "app"; + program = "${inputs.self.defaultPackage.${system}}/bin/alejandra"; }; - }; - devShell = nixpkgs.mkShell { - name = "Alejandra"; - packages = [ - fenix.rust-analyzer - fenix.latest.toolchain - nixpkgs.cargo-tarpaulin - nixpkgs.jq - nixpkgs.nodejs - nixpkgs.nodePackages.prettier - nixpkgs.nodePackages.prettier-plugin-toml - nixpkgs.shfmt - treefmt - ]; - }; - } - ); + defaultPackage = fenixPlatform.buildRustPackage { + pname = cargoToml.package.name; + version = + let + commit = inputs.self.shortRev or "dirty"; + date = + inputs.self.lastModifiedDate or inputs.self.lastModified or "19700101"; + in + "${builtins.substring 0 8 date}_${commit}"; + src = inputs.self.sourceInfo; + cargoLock.lockFile = ./Cargo.lock; + meta = { + description = cargoToml.package.description; + homepage = "https://github.com/kamadorueda/alejandra"; + license = nixpkgs.lib.licenses.unlicense; + maintainers = [ nixpkgs.lib.maintainers.kamadorueda ]; + }; + }; + devShell = nixpkgs.mkShell { + name = "Alejandra"; + packages = [ + fenix.rust-analyzer + fenix.latest.toolchain + nixpkgs.cargo-tarpaulin + nixpkgs.jq + nixpkgs.nodejs + nixpkgs.nodePackages.prettier + nixpkgs.nodePackages.prettier-plugin-toml + nixpkgs.shfmt + treefmt + ]; + }; + } + ); } diff --git a/src/rules/lambda.rs b/src/rules/lambda.rs index 4aed374..b050cb7 100644 --- a/src/rules/lambda.rs +++ b/src/rules/lambda.rs @@ -47,14 +47,7 @@ pub fn rule( // : let child = children.get_next().unwrap(); - match layout { - crate::config::Layout::Tall => { - steps.push_back(crate::builder::Step::FormatWider(child.element)); - } - crate::config::Layout::Wide => { - steps.push_back(crate::builder::Step::Format(child.element)); - } - } + steps.push_back(crate::builder::Step::Format(child.element)); // /**/ children.drain_comments_and_newlines(|element| match element { @@ -71,19 +64,56 @@ pub fn rule( let child = children.get_next().unwrap(); match layout { crate::config::Layout::Tall => { - if is_pattern_type { - steps.push_back(crate::builder::Step::NewLine); - steps.push_back(crate::builder::Step::Pad); - } else if let rnix::SyntaxKind::TOKEN_COMMENT - | rnix::SyntaxKind::TOKEN_WHITESPACE = - child_prev.element.kind() + if is_pattern_type + || matches!( + child_prev.element.kind(), + rnix::SyntaxKind::TOKEN_COMMENT + | rnix::SyntaxKind::TOKEN_WHITESPACE + ) + || (matches!( + child.element.kind(), + rnix::SyntaxKind::NODE_LAMBDA + ) && matches!( + child + .element + .clone() + .into_node() + .unwrap() + .children() + .next() + .unwrap() + .kind(), + rnix::SyntaxKind::NODE_PATTERN + )) + || !matches!( + child.element.kind(), + rnix::SyntaxKind::NODE_ATTR_SET + | rnix::SyntaxKind::NODE_PAREN + | rnix::SyntaxKind::NODE_LAMBDA + | rnix::SyntaxKind::NODE_LET_IN + | rnix::SyntaxKind::NODE_LIST + | rnix::SyntaxKind::NODE_LITERAL + | rnix::SyntaxKind::NODE_STRING + ) { + if build_ctx.pos_new.column > 1 { + steps.push_back(crate::builder::Step::Indent); + } + steps.push_back(crate::builder::Step::NewLine); steps.push_back(crate::builder::Step::Pad); + steps.push_back(crate::builder::Step::FormatWider( + child.element, + )); + if build_ctx.pos_new.column > 1 { + steps.push_back(crate::builder::Step::Dedent); + } } else { steps.push_back(crate::builder::Step::Whitespace); + steps.push_back(crate::builder::Step::FormatWider( + child.element, + )); } - steps.push_back(crate::builder::Step::FormatWider(child.element)); } crate::config::Layout::Wide => { steps.push_back(crate::builder::Step::Whitespace); diff --git a/tests/cases/key_value/out b/tests/cases/key_value/out index e844a22..868a13c 100644 --- a/tests/cases/key_value/out +++ b/tests/cases/key_value/out @@ -85,21 +85,21 @@ rec /* b */ - { b = 1; }; + { b = 1; }; m = a: /* b */ - { - b = 1; - c = 2; - }; + { + b = 1; + c = 2; + }; n = pkgs: { }; o = { pkgs , ... }: - { }; + { }; a /* diff --git a/tests/cases/lambda/in b/tests/cases/lambda/in index bff1206..79d78f6 100644 --- a/tests/cases/lambda/in +++ b/tests/cases/lambda/in @@ -12,4 +12,8 @@ ( aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ) ({ pkgs ? import ./.. { }, locationsXml }: null) + (a: b: c: + { }: + a: b: c: + a) ] diff --git a/tests/cases/lambda/out b/tests/cases/lambda/out index a8309a9..992b95e 100644 --- a/tests/cases/lambda/out +++ b/tests/cases/lambda/out @@ -4,22 +4,23 @@ /* c */ - d + d ) ( { }: - b: - /* - c - */ - d + b: + /* + c + */ + d ) ( - a: { }: - /* - c - */ - d + a: + { }: + /* + c + */ + d ) (a: d) ( @@ -27,14 +28,15 @@ /* c */ - d + d ) ( a /* b */ - : d + : + d ) ( a @@ -45,7 +47,7 @@ /* c */ - d + d ) ( aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa @@ -57,6 +59,12 @@ { pkgs ? import ./.. { } , locationsXml }: - null + null + ) + ( + a: b: c: + { }: + a: b: c: + a ) ] diff --git a/tests/cases/pat_bind/out b/tests/cases/pat_bind/out index b484bcb..812edb9 100644 --- a/tests/cases/pat_bind/out +++ b/tests/cases/pat_bind/out @@ -4,13 +4,13 @@ { } @ /**/ a: - _ + _ ) ( { } /**/ @ a: - _ + _ ) ( { } @@ -18,7 +18,7 @@ @ /**/ a: - _ + _ ) (a @ { }: _) @@ -26,13 +26,13 @@ a @ /**/ { }: - _ + _ ) ( a /**/ @ { }: - _ + _ ) ( a @@ -40,6 +40,6 @@ @ /**/ { }: - _ + _ ) ] diff --git a/tests/cases/pattern/out b/tests/cases/pattern/out index f60344d..dbfb8a9 100644 --- a/tests/cases/pattern/out +++ b/tests/cases/pattern/out @@ -4,27 +4,27 @@ ( { /**/ }: - _ + _ ) ({ ... }: _) ( { ... /**/ }: - _ + _ ) ( { /**/ ... }: - _ + _ ) ( { /**/ ... /**/ }: - _ + _ ) ( @@ -32,7 +32,7 @@ , e , ... }: - _ + _ ) ( { b @@ -42,7 +42,7 @@ h */ }: - _ + _ ) ( { b @@ -52,7 +52,7 @@ */ ... }: - _ + _ ) ( { b @@ -65,7 +65,7 @@ h */ }: - _ + _ ) ( { b @@ -75,7 +75,7 @@ */ , ... }: - _ + _ ) ( { b @@ -88,7 +88,7 @@ h */ }: - _ + _ ) ( { b @@ -101,7 +101,7 @@ */ ... }: - _ + _ ) ( { b @@ -117,7 +117,7 @@ h */ }: - _ + _ ) ( { b @@ -127,7 +127,7 @@ e , ... }: - _ + _ ) ( { b @@ -140,7 +140,7 @@ h */ }: - _ + _ ) ( { b @@ -153,7 +153,7 @@ */ ... }: - _ + _ ) ( { b @@ -169,7 +169,7 @@ h */ }: - _ + _ ) ( { b @@ -182,7 +182,7 @@ */ , ... }: - _ + _ ) ( { b @@ -198,7 +198,7 @@ h */ }: - _ + _ ) ( { b @@ -214,7 +214,7 @@ */ ... }: - _ + _ ) ( { b @@ -233,7 +233,7 @@ h */ }: - _ + _ ) ( { b @@ -243,7 +243,7 @@ , e , ... }: - _ + _ ) ( { b @@ -256,7 +256,7 @@ h */ }: - _ + _ ) ( { b @@ -269,7 +269,7 @@ */ ... }: - _ + _ ) ( { b @@ -285,7 +285,7 @@ h */ }: - _ + _ ) ( { b @@ -298,7 +298,7 @@ */ , ... }: - _ + _ ) ( { b @@ -314,7 +314,7 @@ h */ }: - _ + _ ) ( { b @@ -330,7 +330,7 @@ */ ... }: - _ + _ ) ( { b @@ -349,7 +349,7 @@ h */ }: - _ + _ ) ( { b @@ -362,7 +362,7 @@ e , ... }: - _ + _ ) ( { b @@ -378,7 +378,7 @@ h */ }: - _ + _ ) ( { b @@ -394,7 +394,7 @@ */ ... }: - _ + _ ) ( { b @@ -413,7 +413,7 @@ h */ }: - _ + _ ) ( { b @@ -429,7 +429,7 @@ */ , ... }: - _ + _ ) ( { b @@ -448,7 +448,7 @@ h */ }: - _ + _ ) ( { b @@ -467,7 +467,7 @@ */ ... }: - _ + _ ) ( { b @@ -489,7 +489,7 @@ h */ }: - _ + _ ) ( { /* @@ -499,7 +499,7 @@ , e , ... }: - _ + _ ) ( { /* @@ -512,7 +512,7 @@ h */ }: - _ + _ ) ( { /* @@ -525,7 +525,7 @@ */ ... }: - _ + _ ) ( { /* @@ -541,7 +541,7 @@ h */ }: - _ + _ ) ( { /* @@ -554,7 +554,7 @@ */ , ... }: - _ + _ ) ( { /* @@ -570,7 +570,7 @@ h */ }: - _ + _ ) ( { /* @@ -586,7 +586,7 @@ */ ... }: - _ + _ ) ( { /* @@ -605,7 +605,7 @@ h */ }: - _ + _ ) ( { /* @@ -618,7 +618,7 @@ e , ... }: - _ + _ ) ( { /* @@ -634,7 +634,7 @@ h */ }: - _ + _ ) ( { /* @@ -650,7 +650,7 @@ */ ... }: - _ + _ ) ( { /* @@ -669,7 +669,7 @@ h */ }: - _ + _ ) ( { /* @@ -685,7 +685,7 @@ */ , ... }: - _ + _ ) ( { /* @@ -704,7 +704,7 @@ h */ }: - _ + _ ) ( { /* @@ -723,7 +723,7 @@ */ ... }: - _ + _ ) ( { /* @@ -745,7 +745,7 @@ h */ }: - _ + _ ) ( { /* @@ -758,7 +758,7 @@ , e , ... }: - _ + _ ) ( { /* @@ -774,7 +774,7 @@ h */ }: - _ + _ ) ( { /* @@ -790,7 +790,7 @@ */ ... }: - _ + _ ) ( { /* @@ -809,7 +809,7 @@ h */ }: - _ + _ ) ( { /* @@ -825,7 +825,7 @@ */ , ... }: - _ + _ ) ( { /* @@ -844,7 +844,7 @@ h */ }: - _ + _ ) ( { /* @@ -863,7 +863,7 @@ */ ... }: - _ + _ ) ( { /* @@ -885,7 +885,7 @@ h */ }: - _ + _ ) ( { /* @@ -901,7 +901,7 @@ e , ... }: - _ + _ ) ( { /* @@ -920,7 +920,7 @@ h */ }: - _ + _ ) ( { /* @@ -939,7 +939,7 @@ */ ... }: - _ + _ ) ( { /* @@ -961,7 +961,7 @@ h */ }: - _ + _ ) ( { /* @@ -980,7 +980,7 @@ */ , ... }: - _ + _ ) ( { /* @@ -1002,7 +1002,7 @@ h */ }: - _ + _ ) ( { /* @@ -1024,7 +1024,7 @@ */ ... }: - _ + _ ) ( { /* @@ -1049,7 +1049,7 @@ h */ }: - _ + _ ) ({ a ? null }: _) @@ -1092,7 +1092,7 @@ h */ }: - _ + _ ) ( @@ -1156,6 +1156,6 @@ j */ # - _ + _ ) ]