From 105713544d0c79394d54a90e7397fea1233d6492 Mon Sep 17 00:00:00 2001 From: Indrajeet Patil Date: Wed, 1 May 2024 16:37:16 +0200 Subject: [PATCH 01/20] initial work on remove blank lines before and after braces --- R/rules-spaces.R | 22 +++++++++++++++---- R/style-guides.R | 10 +++++++-- .../line_breaks_and_other/assignment-in.R | 3 +-- .../line_breaks_and_other/assignment-out.R | 3 +-- 4 files changed, 28 insertions(+), 10 deletions(-) diff --git a/R/rules-spaces.R b/R/rules-spaces.R index 580a0cdc7..3ec9d717e 100644 --- a/R/rules-spaces.R +++ b/R/rules-spaces.R @@ -140,20 +140,34 @@ remove_space_before_opening_paren <- function(pd_flat) { pd_flat } -remove_space_after_opening_paren <- function(pd_flat) { - paren_after <- pd_flat$token %in% c("'('", "'['", "LBB") +remove_space_after_opening_paren <- function(pd_flat, strict) { + braces <- c("'('", "'['", "LBB") + paren_after <- pd_flat$token %in% braces if (!any(paren_after)) { return(pd_flat) } + # remove blank lines after opening braces + if (strict) { + pd_flat$lag_newlines[ + lag(pd_flat$token %in% braces) & pd_flat$lag_newlines > 1L + ] <- 1L + } pd_flat$spaces[paren_after & (pd_flat$newlines == 0L)] <- 0L pd_flat } -remove_space_before_closing_paren <- function(pd_flat) { - paren_after <- pd_flat$token %in% c("')'", "']'") +remove_space_before_closing_paren <- function(pd_flat, strict) { + braces <- c("')'", "']'") + paren_after <- pd_flat$token %in% braces if (!any(paren_after)) { return(pd_flat) } + # remove blank lines before closing braces + if (strict) { + pd_flat$lag_newlines[ + pd_flat$token %in% braces & pd_flat$lag_newlines > 1L + ] <- 1L + } paren_before <- lead(paren_after, default = FALSE) pd_flat$spaces[paren_before & (pd_flat$newlines == 0L)] <- 0L pd_flat diff --git a/R/style-guides.R b/R/style-guides.R index edff2cba1..4e729c987 100644 --- a/R/style-guides.R +++ b/R/style-guides.R @@ -87,7 +87,10 @@ tidyverse_style <- function(scope = "tokens", } space_manipulators <- if ("spaces" %in% scope) { list( - remove_space_before_closing_paren = remove_space_before_closing_paren, + remove_space_before_closing_paren = purrr::partial( + remove_space_before_closing_paren, + strict = strict + ), remove_space_before_opening_paren = if (strict) { remove_space_before_opening_paren }, @@ -105,7 +108,10 @@ tidyverse_style <- function(scope = "tokens", spacing_around_op = purrr::partial(set_space_around_op, strict = strict ), - remove_space_after_opening_paren = remove_space_after_opening_paren, + remove_space_after_opening_paren = purrr::partial( + remove_space_after_opening_paren, + strict = strict + ), remove_space_after_excl = remove_space_after_excl, set_space_after_bang_bang = set_space_after_bang_bang, remove_space_before_dollar = remove_space_before_dollar, diff --git a/tests/testthat/line_breaks_and_other/assignment-in.R b/tests/testthat/line_breaks_and_other/assignment-in.R index 00180be41..2108b816f 100644 --- a/tests/testthat/line_breaks_and_other/assignment-in.R +++ b/tests/testthat/line_breaks_and_other/assignment-in.R @@ -4,8 +4,7 @@ x <- x <- 3 -# FIXME: edge case not working for R < 3.6: Problem: most likely, comment is -# not moved to the right nest with relocate_eq_assign. + x <- # the culprit diff --git a/tests/testthat/line_breaks_and_other/assignment-out.R b/tests/testthat/line_breaks_and_other/assignment-out.R index 681ded9e5..239bb02aa 100644 --- a/tests/testthat/line_breaks_and_other/assignment-out.R +++ b/tests/testthat/line_breaks_and_other/assignment-out.R @@ -4,8 +4,7 @@ x <- x <- 3 -# FIXME: edge case not working for R < 3.6: Problem: most likely, comment is -# not moved to the right nest with relocate_eq_assign. + x <- # the culprit From 47b7da7c786ca300aa0b6f3bbece0edc1df016c7 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Wed, 1 May 2024 14:38:56 +0000 Subject: [PATCH 02/20] pre-commit --- R/rules-spaces.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/rules-spaces.R b/R/rules-spaces.R index 3ec9d717e..54b76bbd8 100644 --- a/R/rules-spaces.R +++ b/R/rules-spaces.R @@ -142,7 +142,7 @@ remove_space_before_opening_paren <- function(pd_flat) { remove_space_after_opening_paren <- function(pd_flat, strict) { braces <- c("'('", "'['", "LBB") - paren_after <- pd_flat$token %in% braces + paren_after <- pd_flat$token %in% braces if (!any(paren_after)) { return(pd_flat) } From 0fcbc96ca570ca0d11632b0df138266be76006d2 Mon Sep 17 00:00:00 2001 From: Indrajeet Patil Date: Wed, 1 May 2024 18:13:09 +0200 Subject: [PATCH 03/20] add tests for LBB --- .../square_brackets_double_line_break-in.R | 17 ++ .../square_brackets_double_line_break-in_tree | 47 ++++- .../square_brackets_double_line_break-out.R | 13 ++ .../line_breaks_and_other/assignment-in_tree | 194 +++++++++--------- 4 files changed, 164 insertions(+), 107 deletions(-) diff --git a/tests/testthat/indention_square_brackets/square_brackets_double_line_break-in.R b/tests/testthat/indention_square_brackets/square_brackets_double_line_break-in.R index f5a2fc449..6eb852298 100644 --- a/tests/testthat/indention_square_brackets/square_brackets_double_line_break-in.R +++ b/tests/testthat/indention_square_brackets/square_brackets_double_line_break-in.R @@ -20,3 +20,20 @@ a[[ 2 ] # ] + + +a[[ + + 2 + +]] + +a[[ + + 2 +]] + +a[[ + 2 + +]] diff --git a/tests/testthat/indention_square_brackets/square_brackets_double_line_break-in_tree b/tests/testthat/indention_square_brackets/square_brackets_double_line_break-in_tree index f6ae4068d..82ce65dce 100644 --- a/tests/testthat/indention_square_brackets/square_brackets_double_line_break-in_tree +++ b/tests/testthat/indention_square_brackets/square_brackets_double_line_break-in_tree @@ -34,13 +34,42 @@ ROOT (token: short_text [lag_newlines/spaces] {pos_id}) ¦ ¦ °--NUM_CONST: 2 [0/0] {29} ¦ ¦--']': ] [1/0] {31} ¦ °--']': ] [0/0] {32} - °--expr: a[[ + ¦--expr: a[[ [3/0] {33} - ¦--expr: a [0/0] {35} - ¦ °--SYMBOL: a [0/0] {34} - ¦--LBB: [[ [0/2] {36} - ¦--expr: 2 [1/0] {38} - ¦ °--NUM_CONST: 2 [0/0] {37} - ¦--']': ] [1/1] {39} - ¦--COMMENT: # [0/0] {40} - °--']': ] [1/0] {41} + ¦ ¦--expr: a [0/0] {35} + ¦ ¦ °--SYMBOL: a [0/0] {34} + ¦ ¦--LBB: [[ [0/2] {36} + ¦ ¦--expr: 2 [1/0] {38} + ¦ ¦ °--NUM_CONST: 2 [0/0] {37} + ¦ ¦--']': ] [1/1] {39} + ¦ ¦--COMMENT: # [0/0] {40} + ¦ °--']': ] [1/0] {41} + ¦--expr: a[[ + + [3/0] {42} + ¦ ¦--expr: a [0/0] {44} + ¦ ¦ °--SYMBOL: a [0/0] {43} + ¦ ¦--LBB: [[ [0/2] {45} + ¦ ¦--expr: 2 [2/0] {47} + ¦ ¦ °--NUM_CONST: 2 [0/0] {46} + ¦ ¦--']': ] [2/0] {48} + ¦ °--']': ] [0/0] {49} + ¦--expr: a[[ + + [2/0] {50} + ¦ ¦--expr: a [0/0] {52} + ¦ ¦ °--SYMBOL: a [0/0] {51} + ¦ ¦--LBB: [[ [0/2] {53} + ¦ ¦--expr: 2 [2/0] {55} + ¦ ¦ °--NUM_CONST: 2 [0/0] {54} + ¦ ¦--']': ] [1/0] {56} + ¦ °--']': ] [0/0] {57} + °--expr: a[[ + [2/0] {58} + ¦--expr: a [0/0] {60} + ¦ °--SYMBOL: a [0/0] {59} + ¦--LBB: [[ [0/2] {61} + ¦--expr: 2 [1/0] {63} + ¦ °--NUM_CONST: 2 [0/0] {62} + ¦--']': ] [2/0] {64} + °--']': ] [0/0] {65} diff --git a/tests/testthat/indention_square_brackets/square_brackets_double_line_break-out.R b/tests/testthat/indention_square_brackets/square_brackets_double_line_break-out.R index 2b5225958..a6a371f93 100644 --- a/tests/testthat/indention_square_brackets/square_brackets_double_line_break-out.R +++ b/tests/testthat/indention_square_brackets/square_brackets_double_line_break-out.R @@ -20,3 +20,16 @@ a[[ 2 ] # ] + + +a[[ + 2 +]] + +a[[ + 2 +]] + +a[[ + 2 +]] diff --git a/tests/testthat/line_breaks_and_other/assignment-in_tree b/tests/testthat/line_breaks_and_other/assignment-in_tree index 22eaa0017..5c8522dc4 100644 --- a/tests/testthat/line_breaks_and_other/assignment-in_tree +++ b/tests/testthat/line_breaks_and_other/assignment-in_tree @@ -12,104 +12,102 @@ ROOT (token: short_text [lag_newlines/spaces] {pos_id}) ¦ ¦--LEFT_ASSIGN: <- [0/1] {10} ¦ °--expr: 3 [0/0] {12} ¦ °--NUM_CONST: 3 [0/0] {11} - ¦--COMMENT: # FIX [2/0] {13} - ¦--COMMENT: # not [1/0] {14} ¦--expr: x <- - [1/0] {15} - ¦ ¦--expr: x [0/1] {17} - ¦ ¦ °--SYMBOL: x [0/0] {16} - ¦ ¦--LEFT_ASSIGN: <- [0/2] {18} - ¦ ¦--COMMENT: # the [1/2] {19} - ¦ °--expr: 3 [2/0] {21} - ¦ °--NUM_CONST: 3 [0/0] {20} - ¦--expr_or_assign_or_help: x = # [3/0] {22} - ¦ ¦--expr: x [0/1] {24} - ¦ ¦ °--SYMBOL: x [0/0] {23} - ¦ ¦--EQ_ASSIGN: = [0/1] {25} - ¦ ¦--COMMENT: # [0/2] {26} - ¦ °--expr: 2 [1/0] {28} - ¦ °--NUM_CONST: 2 [0/0] {27} - ¦--expr_or_assign_or_help: x = 3 [3/0] {29} - ¦ ¦--expr: x [0/1] {31} - ¦ ¦ °--SYMBOL: x [0/0] {30} - ¦ ¦--EQ_ASSIGN: = [0/1] {32} - ¦ °--expr: 3 [0/0] {34} - ¦ °--NUM_CONST: 3 [0/0] {33} + [3/0] {13} + ¦ ¦--expr: x [0/1] {15} + ¦ ¦ °--SYMBOL: x [0/0] {14} + ¦ ¦--LEFT_ASSIGN: <- [0/2] {16} + ¦ ¦--COMMENT: # the [1/2] {17} + ¦ °--expr: 3 [2/0] {19} + ¦ °--NUM_CONST: 3 [0/0] {18} + ¦--expr_or_assign_or_help: x = # [3/0] {20} + ¦ ¦--expr: x [0/1] {22} + ¦ ¦ °--SYMBOL: x [0/0] {21} + ¦ ¦--EQ_ASSIGN: = [0/1] {23} + ¦ ¦--COMMENT: # [0/2] {24} + ¦ °--expr: 2 [1/0] {26} + ¦ °--NUM_CONST: 2 [0/0] {25} + ¦--expr_or_assign_or_help: x = 3 [3/0] {27} + ¦ ¦--expr: x [0/1] {29} + ¦ ¦ °--SYMBOL: x [0/0] {28} + ¦ ¦--EQ_ASSIGN: = [0/1] {30} + ¦ °--expr: 3 [0/0] {32} + ¦ °--NUM_CONST: 3 [0/0] {31} ¦--expr_or_assign_or_help: x = - [2/0] {35} - ¦ ¦--expr: x [0/1] {37} - ¦ ¦ °--SYMBOL: x [0/0] {36} - ¦ ¦--EQ_ASSIGN: = [0/2] {38} - ¦ ¦--COMMENT: # com [2/2] {39} - ¦ °--expr: 3 [1/0] {41} - ¦ °--NUM_CONST: 3 [0/0] {40} - ¦--expr: Impor [4/0] {42} - ¦ ¦--expr: Impor [0/1] {43} - ¦ ¦ ¦--expr: Impor [0/0] {45} - ¦ ¦ ¦ °--SYMBOL: Impor [0/0] {44} - ¦ ¦ ¦--'$': $ [0/0] {46} - ¦ ¦ °--SYMBOL: Impor [0/0] {47} - ¦ ¦--LEFT_ASSIGN: <- [0/2] {48} - ¦ ¦--expr: Impor [1/1] {50} - ¦ ¦ ¦--expr: Impor [0/0] {52} - ¦ ¦ ¦ °--SYMBOL: Impor [0/0] {51} - ¦ ¦ ¦--'$': $ [0/0] {53} - ¦ ¦ °--SYMBOL: Impor [0/0] {54} - ¦ ¦--LEFT_ASSIGN: <- [0/2] {55} - ¦ °--expr: Compl [1/0] {56} - ¦ ¦--expr: Compl [0/0] {58} - ¦ ¦ °--SYMBOL_FUNCTION_CALL: Compl [0/0] {57} - ¦ ¦--'(': ( [0/0] {59} - ¦ ¦--expr: Impor [0/0] {60} - ¦ ¦ ¦--expr: Impor [0/0] {62} - ¦ ¦ ¦ °--SYMBOL: Impor [0/0] {61} - ¦ ¦ ¦--'$': $ [0/0] {63} - ¦ ¦ °--SYMBOL: Input [0/0] {64} - ¦ °--')': ) [0/0] {65} - ¦--expr: Impor [3/0] {66} - ¦ ¦--expr: Impor [0/1] {67} - ¦ ¦ ¦--expr: Impor [0/0] {69} - ¦ ¦ ¦ °--SYMBOL: Impor [0/0] {68} - ¦ ¦ ¦--'$': $ [0/0] {70} - ¦ ¦ °--SYMBOL: Impor [0/0] {71} - ¦ ¦--LEFT_ASSIGN: <- [0/2] {72} - ¦ ¦--expr: Impor [1/1] {74} - ¦ ¦ ¦--expr: Impor [0/0] {76} - ¦ ¦ ¦ °--SYMBOL: Impor [0/0] {75} - ¦ ¦ ¦--'$': $ [0/0] {77} - ¦ ¦ °--SYMBOL: Impor [0/0] {78} - ¦ ¦--LEFT_ASSIGN: <- [0/1] {79} - ¦ °--expr: Compl [0/0] {80} - ¦ ¦--expr: Compl [0/0] {82} - ¦ ¦ °--SYMBOL_FUNCTION_CALL: Compl [0/0] {81} - ¦ ¦--'(': ( [0/0] {83} - ¦ ¦--expr: Impor [0/0] {84} - ¦ ¦ ¦--expr: Impor [0/0] {86} - ¦ ¦ ¦ °--SYMBOL: Impor [0/0] {85} - ¦ ¦ ¦--'$': $ [0/0] {87} - ¦ ¦ °--SYMBOL: Input [0/0] {88} - ¦ °--')': ) [0/0] {89} - °--expr: Impor [4/0] {90} - ¦--expr: Impor [0/1] {91} - ¦ ¦--expr: Impor [0/0] {93} - ¦ ¦ °--SYMBOL: Impor [0/0] {92} - ¦ ¦--'$': $ [0/0] {94} - ¦ °--SYMBOL: Impor [0/0] {95} - ¦--LEFT_ASSIGN: <- [0/2] {96} - ¦--expr: Impor [2/1] {98} - ¦ ¦--expr: Impor [0/0] {100} - ¦ ¦ °--SYMBOL: Impor [0/0] {99} - ¦ ¦--'$': $ [0/0] {101} - ¦ °--SYMBOL: Impor [0/0] {102} - ¦--LEFT_ASSIGN: <- [0/1] {103} - °--expr: Compl [0/0] {104} - ¦--expr: Compl [0/0] {106} - ¦ °--SYMBOL_FUNCTION_CALL: Compl [0/0] {105} - ¦--'(': ( [0/0] {107} - ¦--expr: Impor [0/0] {108} - ¦ ¦--expr: Impor [0/0] {110} - ¦ ¦ °--SYMBOL: Impor [0/0] {109} - ¦ ¦--'$': $ [0/0] {111} - ¦ °--SYMBOL: Input [0/0] {112} - °--')': ) [0/0] {113} + [2/0] {33} + ¦ ¦--expr: x [0/1] {35} + ¦ ¦ °--SYMBOL: x [0/0] {34} + ¦ ¦--EQ_ASSIGN: = [0/2] {36} + ¦ ¦--COMMENT: # com [2/2] {37} + ¦ °--expr: 3 [1/0] {39} + ¦ °--NUM_CONST: 3 [0/0] {38} + ¦--expr: Impor [4/0] {40} + ¦ ¦--expr: Impor [0/1] {41} + ¦ ¦ ¦--expr: Impor [0/0] {43} + ¦ ¦ ¦ °--SYMBOL: Impor [0/0] {42} + ¦ ¦ ¦--'$': $ [0/0] {44} + ¦ ¦ °--SYMBOL: Impor [0/0] {45} + ¦ ¦--LEFT_ASSIGN: <- [0/2] {46} + ¦ ¦--expr: Impor [1/1] {48} + ¦ ¦ ¦--expr: Impor [0/0] {50} + ¦ ¦ ¦ °--SYMBOL: Impor [0/0] {49} + ¦ ¦ ¦--'$': $ [0/0] {51} + ¦ ¦ °--SYMBOL: Impor [0/0] {52} + ¦ ¦--LEFT_ASSIGN: <- [0/2] {53} + ¦ °--expr: Compl [1/0] {54} + ¦ ¦--expr: Compl [0/0] {56} + ¦ ¦ °--SYMBOL_FUNCTION_CALL: Compl [0/0] {55} + ¦ ¦--'(': ( [0/0] {57} + ¦ ¦--expr: Impor [0/0] {58} + ¦ ¦ ¦--expr: Impor [0/0] {60} + ¦ ¦ ¦ °--SYMBOL: Impor [0/0] {59} + ¦ ¦ ¦--'$': $ [0/0] {61} + ¦ ¦ °--SYMBOL: Input [0/0] {62} + ¦ °--')': ) [0/0] {63} + ¦--expr: Impor [3/0] {64} + ¦ ¦--expr: Impor [0/1] {65} + ¦ ¦ ¦--expr: Impor [0/0] {67} + ¦ ¦ ¦ °--SYMBOL: Impor [0/0] {66} + ¦ ¦ ¦--'$': $ [0/0] {68} + ¦ ¦ °--SYMBOL: Impor [0/0] {69} + ¦ ¦--LEFT_ASSIGN: <- [0/2] {70} + ¦ ¦--expr: Impor [1/1] {72} + ¦ ¦ ¦--expr: Impor [0/0] {74} + ¦ ¦ ¦ °--SYMBOL: Impor [0/0] {73} + ¦ ¦ ¦--'$': $ [0/0] {75} + ¦ ¦ °--SYMBOL: Impor [0/0] {76} + ¦ ¦--LEFT_ASSIGN: <- [0/1] {77} + ¦ °--expr: Compl [0/0] {78} + ¦ ¦--expr: Compl [0/0] {80} + ¦ ¦ °--SYMBOL_FUNCTION_CALL: Compl [0/0] {79} + ¦ ¦--'(': ( [0/0] {81} + ¦ ¦--expr: Impor [0/0] {82} + ¦ ¦ ¦--expr: Impor [0/0] {84} + ¦ ¦ ¦ °--SYMBOL: Impor [0/0] {83} + ¦ ¦ ¦--'$': $ [0/0] {85} + ¦ ¦ °--SYMBOL: Input [0/0] {86} + ¦ °--')': ) [0/0] {87} + °--expr: Impor [4/0] {88} + ¦--expr: Impor [0/1] {89} + ¦ ¦--expr: Impor [0/0] {91} + ¦ ¦ °--SYMBOL: Impor [0/0] {90} + ¦ ¦--'$': $ [0/0] {92} + ¦ °--SYMBOL: Impor [0/0] {93} + ¦--LEFT_ASSIGN: <- [0/2] {94} + ¦--expr: Impor [2/1] {96} + ¦ ¦--expr: Impor [0/0] {98} + ¦ ¦ °--SYMBOL: Impor [0/0] {97} + ¦ ¦--'$': $ [0/0] {99} + ¦ °--SYMBOL: Impor [0/0] {100} + ¦--LEFT_ASSIGN: <- [0/1] {101} + °--expr: Compl [0/0] {102} + ¦--expr: Compl [0/0] {104} + ¦ °--SYMBOL_FUNCTION_CALL: Compl [0/0] {103} + ¦--'(': ( [0/0] {105} + ¦--expr: Impor [0/0] {106} + ¦ ¦--expr: Impor [0/0] {108} + ¦ ¦ °--SYMBOL: Impor [0/0] {107} + ¦ ¦--'$': $ [0/0] {109} + ¦ °--SYMBOL: Input [0/0] {110} + °--')': ) [0/0] {111} From 9464800d8a45801015998f7bcef3eefb3f3073ec Mon Sep 17 00:00:00 2001 From: Indrajeet Patil Date: Wed, 1 May 2024 18:50:02 +0200 Subject: [PATCH 04/20] more tests --- .../multi_line_curly_only-in.R | 8 + .../multi_line_curly_only-in_tree | 80 ++-- .../multi_line_curly_only-out.R | 9 + .../multi_line_curly_while_for_if_fun-in.R | 15 + .../multi_line_curly_while_for_if_fun-in_tree | 196 +++++---- .../multi_line_curly_while_for_if_fun-out.R | 8 + .../arithmetic_start-in.R | 10 + .../arithmetic_start-in_tree | 63 ++- .../arithmetic_start-out.R | 7 + .../multi_line-random-in.R | 13 + .../multi_line-random-in_tree | 114 +++-- .../multi_line-random-out.R | 10 + .../square_brackets_line_break-in.R | 36 ++ .../square_brackets_line_break-in_tree | 394 +++++++++++------- .../square_brackets_line_break-out.R | 24 ++ 15 files changed, 659 insertions(+), 328 deletions(-) diff --git a/tests/testthat/indention_curly_brackets/multi_line_curly_only-in.R b/tests/testthat/indention_curly_brackets/multi_line_curly_only-in.R index f06c54945..e8bca1432 100644 --- a/tests/testthat/indention_curly_brackets/multi_line_curly_only-in.R +++ b/tests/testthat/indention_curly_brackets/multi_line_curly_only-in.R @@ -2,3 +2,11 @@ {1 + 3} {2 + sin(pi)} } + + { + + {1 + 3} + {2 + sin(pi)} + + + } diff --git a/tests/testthat/indention_curly_brackets/multi_line_curly_only-in_tree b/tests/testthat/indention_curly_brackets/multi_line_curly_only-in_tree index 1205a1a3f..4e4ee22af 100644 --- a/tests/testthat/indention_curly_brackets/multi_line_curly_only-in_tree +++ b/tests/testthat/indention_curly_brackets/multi_line_curly_only-in_tree @@ -1,28 +1,56 @@ ROOT (token: short_text [lag_newlines/spaces] {pos_id}) + ¦--expr: { + [0/6] {1} + ¦ ¦--'{': { [0/9] {2} + ¦ ¦--expr: {1 + [1/0] {3} + ¦ ¦ ¦--'{': { [0/0] {4} + ¦ ¦ ¦--expr: 1 + 3 [0/0] {5} + ¦ ¦ ¦ ¦--expr: 1 [0/1] {7} + ¦ ¦ ¦ ¦ °--NUM_CONST: 1 [0/0] {6} + ¦ ¦ ¦ ¦--'+': + [0/1] {8} + ¦ ¦ ¦ °--expr: 3 [0/0] {10} + ¦ ¦ ¦ °--NUM_CONST: 3 [0/0] {9} + ¦ ¦ °--'}': } [0/0] {11} + ¦ ¦--expr: {2 + [1/6] {12} + ¦ ¦ ¦--'{': { [0/0] {13} + ¦ ¦ ¦--expr: 2 + s [0/0] {14} + ¦ ¦ ¦ ¦--expr: 2 [0/1] {16} + ¦ ¦ ¦ ¦ °--NUM_CONST: 2 [0/0] {15} + ¦ ¦ ¦ ¦--'+': + [0/1] {17} + ¦ ¦ ¦ °--expr: sin(p [0/0] {18} + ¦ ¦ ¦ ¦--expr: sin [0/0] {20} + ¦ ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: sin [0/0] {19} + ¦ ¦ ¦ ¦--'(': ( [0/0] {21} + ¦ ¦ ¦ ¦--expr: pi [0/0] {23} + ¦ ¦ ¦ ¦ °--SYMBOL: pi [0/0] {22} + ¦ ¦ ¦ °--')': ) [0/0] {24} + ¦ ¦ °--'}': } [0/0] {25} + ¦ °--'}': } [1/0] {26} °--expr: { - [0/0] {1} - ¦--'{': { [0/9] {2} - ¦--expr: {1 + [1/0] {3} - ¦ ¦--'{': { [0/0] {4} - ¦ ¦--expr: 1 + 3 [0/0] {5} - ¦ ¦ ¦--expr: 1 [0/1] {7} - ¦ ¦ ¦ °--NUM_CONST: 1 [0/0] {6} - ¦ ¦ ¦--'+': + [0/1] {8} - ¦ ¦ °--expr: 3 [0/0] {10} - ¦ ¦ °--NUM_CONST: 3 [0/0] {9} - ¦ °--'}': } [0/0] {11} - ¦--expr: {2 + [1/6] {12} - ¦ ¦--'{': { [0/0] {13} - ¦ ¦--expr: 2 + s [0/0] {14} - ¦ ¦ ¦--expr: 2 [0/1] {16} - ¦ ¦ ¦ °--NUM_CONST: 2 [0/0] {15} - ¦ ¦ ¦--'+': + [0/1] {17} - ¦ ¦ °--expr: sin(p [0/0] {18} - ¦ ¦ ¦--expr: sin [0/0] {20} - ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: sin [0/0] {19} - ¦ ¦ ¦--'(': ( [0/0] {21} - ¦ ¦ ¦--expr: pi [0/0] {23} - ¦ ¦ ¦ °--SYMBOL: pi [0/0] {22} - ¦ ¦ °--')': ) [0/0] {24} - ¦ °--'}': } [0/0] {25} - °--'}': } [1/0] {26} + + [2/0] {27} + ¦--'{': { [0/8] {28} + ¦--expr: {1 + [2/8] {29} + ¦ ¦--'{': { [0/0] {30} + ¦ ¦--expr: 1 + 3 [0/0] {31} + ¦ ¦ ¦--expr: 1 [0/1] {33} + ¦ ¦ ¦ °--NUM_CONST: 1 [0/0] {32} + ¦ ¦ ¦--'+': + [0/1] {34} + ¦ ¦ °--expr: 3 [0/0] {36} + ¦ ¦ °--NUM_CONST: 3 [0/0] {35} + ¦ °--'}': } [0/0] {37} + ¦--expr: {2 + [1/6] {38} + ¦ ¦--'{': { [0/0] {39} + ¦ ¦--expr: 2 + s [0/0] {40} + ¦ ¦ ¦--expr: 2 [0/1] {42} + ¦ ¦ ¦ °--NUM_CONST: 2 [0/0] {41} + ¦ ¦ ¦--'+': + [0/1] {43} + ¦ ¦ °--expr: sin(p [0/0] {44} + ¦ ¦ ¦--expr: sin [0/0] {46} + ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: sin [0/0] {45} + ¦ ¦ ¦--'(': ( [0/0] {47} + ¦ ¦ ¦--expr: pi [0/0] {49} + ¦ ¦ ¦ °--SYMBOL: pi [0/0] {48} + ¦ ¦ °--')': ) [0/0] {50} + ¦ °--'}': } [0/0] {51} + °--'}': } [3/0] {52} diff --git a/tests/testthat/indention_curly_brackets/multi_line_curly_only-out.R b/tests/testthat/indention_curly_brackets/multi_line_curly_only-out.R index b2db83528..e4c5631c4 100644 --- a/tests/testthat/indention_curly_brackets/multi_line_curly_only-out.R +++ b/tests/testthat/indention_curly_brackets/multi_line_curly_only-out.R @@ -6,3 +6,12 @@ 2 + sin(pi) } } + +{ + { + 1 + 3 + } + { + 2 + sin(pi) + } +} diff --git a/tests/testthat/indention_curly_brackets/multi_line_curly_while_for_if_fun-in.R b/tests/testthat/indention_curly_brackets/multi_line_curly_while_for_if_fun-in.R index 6c37fe95f..09e5bc827 100644 --- a/tests/testthat/indention_curly_brackets/multi_line_curly_while_for_if_fun-in.R +++ b/tests/testthat/indention_curly_brackets/multi_line_curly_while_for_if_fun-in.R @@ -8,3 +8,18 @@ a <- function(x, y, z) { x[i] +1 } } + + +if ( + + require("logspline") && + require("rstanarm") + + + +) { + + NULL + + + } diff --git a/tests/testthat/indention_curly_brackets/multi_line_curly_while_for_if_fun-in_tree b/tests/testthat/indention_curly_brackets/multi_line_curly_while_for_if_fun-in_tree index 99ff47e9c..850631be3 100644 --- a/tests/testthat/indention_curly_brackets/multi_line_curly_while_for_if_fun-in_tree +++ b/tests/testthat/indention_curly_brackets/multi_line_curly_while_for_if_fun-in_tree @@ -1,89 +1,117 @@ ROOT (token: short_text [lag_newlines/spaces] {pos_id}) - °--expr: a <- [0/0] {1} - ¦--expr: a [0/1] {3} - ¦ °--SYMBOL: a [0/0] {2} - ¦--LEFT_ASSIGN: <- [0/1] {4} - °--expr: funct [0/0] {5} - ¦--FUNCTION: funct [0/0] {6} - ¦--'(': ( [0/0] {7} - ¦--SYMBOL_FORMALS: x [0/0] {8} - ¦--',': , [0/1] {9} - ¦--SYMBOL_FORMALS: y [0/0] {10} - ¦--',': , [0/1] {11} - ¦--SYMBOL_FORMALS: z [0/0] {12} - ¦--')': ) [0/12] {13} - °--expr: { + ¦--expr: a <- [0/0] {1} + ¦ ¦--expr: a [0/1] {3} + ¦ ¦ °--SYMBOL: a [0/0] {2} + ¦ ¦--LEFT_ASSIGN: <- [0/1] {4} + ¦ °--expr: funct [0/0] {5} + ¦ ¦--FUNCTION: funct [0/0] {6} + ¦ ¦--'(': ( [0/0] {7} + ¦ ¦--SYMBOL_FORMALS: x [0/0] {8} + ¦ ¦--',': , [0/1] {9} + ¦ ¦--SYMBOL_FORMALS: y [0/0] {10} + ¦ ¦--',': , [0/1] {11} + ¦ ¦--SYMBOL_FORMALS: z [0/0] {12} + ¦ ¦--')': ) [0/12] {13} + ¦ °--expr: { w [0/0] {14} - ¦--'{': { [0/2] {15} - ¦--expr: while [1/6] {16} - ¦ ¦--WHILE: while [0/0] {17} - ¦ ¦--'(': ( [0/0] {18} - ¦ ¦--expr: 2+2> [0/0] {19} - ¦ ¦ ¦--expr: 2+2 [0/0] {20} - ¦ ¦ ¦ ¦--expr: 2 [0/0] {22} - ¦ ¦ ¦ ¦ °--NUM_CONST: 2 [0/0] {21} - ¦ ¦ ¦ ¦--'+': + [0/0] {23} - ¦ ¦ ¦ °--expr: 2 [0/0] {25} - ¦ ¦ ¦ °--NUM_CONST: 2 [0/0] {24} - ¦ ¦ ¦--GT: > [0/1] {26} - ¦ ¦ °--expr: call( [0/0] {27} - ¦ ¦ ¦--expr: call [0/0] {29} - ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: call [0/0] {28} - ¦ ¦ ¦--'(': ( [0/0] {30} - ¦ ¦ ¦--expr: 3 [0/0] {32} - ¦ ¦ ¦ °--NUM_CONST: 3 [0/0] {31} - ¦ ¦ ¦--',': , [0/0] {33} - ¦ ¦ ¦--expr: 1 [0/0] {35} - ¦ ¦ ¦ °--NUM_CONST: 1 [0/0] {34} - ¦ ¦ °--')': ) [0/0] {36} - ¦ ¦--')': ) [0/1] {37} - ¦ °--expr: { + ¦ ¦--'{': { [0/2] {15} + ¦ ¦--expr: while [1/6] {16} + ¦ ¦ ¦--WHILE: while [0/0] {17} + ¦ ¦ ¦--'(': ( [0/0] {18} + ¦ ¦ ¦--expr: 2+2> [0/0] {19} + ¦ ¦ ¦ ¦--expr: 2+2 [0/0] {20} + ¦ ¦ ¦ ¦ ¦--expr: 2 [0/0] {22} + ¦ ¦ ¦ ¦ ¦ °--NUM_CONST: 2 [0/0] {21} + ¦ ¦ ¦ ¦ ¦--'+': + [0/0] {23} + ¦ ¦ ¦ ¦ °--expr: 2 [0/0] {25} + ¦ ¦ ¦ ¦ °--NUM_CONST: 2 [0/0] {24} + ¦ ¦ ¦ ¦--GT: > [0/1] {26} + ¦ ¦ ¦ °--expr: call( [0/0] {27} + ¦ ¦ ¦ ¦--expr: call [0/0] {29} + ¦ ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: call [0/0] {28} + ¦ ¦ ¦ ¦--'(': ( [0/0] {30} + ¦ ¦ ¦ ¦--expr: 3 [0/0] {32} + ¦ ¦ ¦ ¦ °--NUM_CONST: 3 [0/0] {31} + ¦ ¦ ¦ ¦--',': , [0/0] {33} + ¦ ¦ ¦ ¦--expr: 1 [0/0] {35} + ¦ ¦ ¦ ¦ °--NUM_CONST: 1 [0/0] {34} + ¦ ¦ ¦ °--')': ) [0/0] {36} + ¦ ¦ ¦--')': ) [0/1] {37} + ¦ ¦ °--expr: { [0/0] {38} - ¦ ¦--'{': { [0/4] {39} - ¦ ¦--expr: if (i [1/4] {40} - ¦ ¦ ¦--IF: if [0/1] {41} - ¦ ¦ ¦--'(': ( [0/0] {42} - ¦ ¦ ¦--expr: isTRU [0/0] {43} - ¦ ¦ ¦ ¦--expr: isTRU [0/0] {45} - ¦ ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: isTRU [0/0] {44} - ¦ ¦ ¦ ¦--'(': ( [0/0] {46} - ¦ ¦ ¦ ¦--expr: x [0/0] {48} - ¦ ¦ ¦ ¦ °--SYMBOL: x [0/0] {47} - ¦ ¦ ¦ °--')': ) [0/0] {49} - ¦ ¦ ¦--')': ) [0/1] {50} - ¦ ¦ °--expr: { + ¦ ¦ ¦--'{': { [0/4] {39} + ¦ ¦ ¦--expr: if (i [1/4] {40} + ¦ ¦ ¦ ¦--IF: if [0/1] {41} + ¦ ¦ ¦ ¦--'(': ( [0/0] {42} + ¦ ¦ ¦ ¦--expr: isTRU [0/0] {43} + ¦ ¦ ¦ ¦ ¦--expr: isTRU [0/0] {45} + ¦ ¦ ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: isTRU [0/0] {44} + ¦ ¦ ¦ ¦ ¦--'(': ( [0/0] {46} + ¦ ¦ ¦ ¦ ¦--expr: x [0/0] {48} + ¦ ¦ ¦ ¦ ¦ °--SYMBOL: x [0/0] {47} + ¦ ¦ ¦ ¦ °--')': ) [0/0] {49} + ¦ ¦ ¦ ¦--')': ) [0/1] {50} + ¦ ¦ ¦ °--expr: { [0/0] {51} - ¦ ¦ ¦--'{': { [0/6] {52} - ¦ ¦ ¦--expr: b [1/0] {54} - ¦ ¦ ¦ °--SYMBOL: b [0/0] {53} - ¦ ¦ °--'}': } [1/0] {55} - ¦ °--'}': } [1/0] {56} - ¦--expr: for(a [1/0] {57} - ¦ ¦--FOR: for [0/0] {58} - ¦ ¦--forcond: (a in [0/0] {59} - ¦ ¦ ¦--'(': ( [0/0] {60} - ¦ ¦ ¦--SYMBOL: a [0/1] {61} - ¦ ¦ ¦--IN: in [0/1] {62} - ¦ ¦ ¦--expr: 1:19 [0/0] {63} - ¦ ¦ ¦ ¦--expr: 1 [0/0] {65} - ¦ ¦ ¦ ¦ °--NUM_CONST: 1 [0/0] {64} - ¦ ¦ ¦ ¦--':': : [0/0] {66} - ¦ ¦ ¦ °--expr: 19 [0/0] {68} - ¦ ¦ ¦ °--NUM_CONST: 19 [0/0] {67} - ¦ ¦ °--')': ) [0/0] {69} - ¦ °--expr: { + ¦ ¦ ¦ ¦--'{': { [0/6] {52} + ¦ ¦ ¦ ¦--expr: b [1/0] {54} + ¦ ¦ ¦ ¦ °--SYMBOL: b [0/0] {53} + ¦ ¦ ¦ °--'}': } [1/0] {55} + ¦ ¦ °--'}': } [1/0] {56} + ¦ ¦--expr: for(a [1/0] {57} + ¦ ¦ ¦--FOR: for [0/0] {58} + ¦ ¦ ¦--forcond: (a in [0/0] {59} + ¦ ¦ ¦ ¦--'(': ( [0/0] {60} + ¦ ¦ ¦ ¦--SYMBOL: a [0/1] {61} + ¦ ¦ ¦ ¦--IN: in [0/1] {62} + ¦ ¦ ¦ ¦--expr: 1:19 [0/0] {63} + ¦ ¦ ¦ ¦ ¦--expr: 1 [0/0] {65} + ¦ ¦ ¦ ¦ ¦ °--NUM_CONST: 1 [0/0] {64} + ¦ ¦ ¦ ¦ ¦--':': : [0/0] {66} + ¦ ¦ ¦ ¦ °--expr: 19 [0/0] {68} + ¦ ¦ ¦ ¦ °--NUM_CONST: 19 [0/0] {67} + ¦ ¦ ¦ °--')': ) [0/0] {69} + ¦ ¦ °--expr: { [0/0] {70} - ¦ ¦--'{': { [0/4] {71} - ¦ ¦--expr: x[i] [1/2] {72} - ¦ ¦ ¦--expr: x[i] [0/1] {73} - ¦ ¦ ¦ ¦--expr: x [0/0] {75} - ¦ ¦ ¦ ¦ °--SYMBOL: x [0/0] {74} - ¦ ¦ ¦ ¦--'[': [ [0/0] {76} - ¦ ¦ ¦ ¦--expr: i [0/0] {78} - ¦ ¦ ¦ ¦ °--SYMBOL: i [0/0] {77} - ¦ ¦ ¦ °--']': ] [0/0] {79} - ¦ ¦ ¦--'+': + [0/0] {80} - ¦ ¦ °--expr: 1 [0/0] {82} - ¦ ¦ °--NUM_CONST: 1 [0/0] {81} - ¦ °--'}': } [1/0] {83} - °--'}': } [1/0] {84} + ¦ ¦ ¦--'{': { [0/4] {71} + ¦ ¦ ¦--expr: x[i] [1/2] {72} + ¦ ¦ ¦ ¦--expr: x[i] [0/1] {73} + ¦ ¦ ¦ ¦ ¦--expr: x [0/0] {75} + ¦ ¦ ¦ ¦ ¦ °--SYMBOL: x [0/0] {74} + ¦ ¦ ¦ ¦ ¦--'[': [ [0/0] {76} + ¦ ¦ ¦ ¦ ¦--expr: i [0/0] {78} + ¦ ¦ ¦ ¦ ¦ °--SYMBOL: i [0/0] {77} + ¦ ¦ ¦ ¦ °--']': ] [0/0] {79} + ¦ ¦ ¦ ¦--'+': + [0/0] {80} + ¦ ¦ ¦ °--expr: 1 [0/0] {82} + ¦ ¦ ¦ °--NUM_CONST: 1 [0/0] {81} + ¦ ¦ °--'}': } [1/0] {83} + ¦ °--'}': } [1/0] {84} + °--expr: if ( + [3/0] {85} + ¦--IF: if [0/1] {86} + ¦--'(': ( [0/2] {87} + ¦--expr: requi [2/0] {88} + ¦ ¦--expr: requi [0/1] {89} + ¦ ¦ ¦--expr: requi [0/0] {91} + ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: requi [0/0] {90} + ¦ ¦ ¦--'(': ( [0/0] {92} + ¦ ¦ ¦--expr: "logs [0/0] {94} + ¦ ¦ ¦ °--STR_CONST: "logs [0/0] {93} + ¦ ¦ °--')': ) [0/0] {95} + ¦ ¦--AND2: && [0/4] {96} + ¦ °--expr: requi [1/0] {97} + ¦ ¦--expr: requi [0/0] {99} + ¦ ¦ °--SYMBOL_FUNCTION_CALL: requi [0/0] {98} + ¦ ¦--'(': ( [0/0] {100} + ¦ ¦--expr: "rsta [0/0] {102} + ¦ ¦ °--STR_CONST: "rsta [0/0] {101} + ¦ °--')': ) [0/0] {103} + ¦--')': ) [4/1] {104} + °--expr: { + + [0/0] {105} + ¦--'{': { [0/2] {106} + ¦--expr: NULL [2/2] {108} + ¦ °--NULL_CONST: NULL [0/0] {107} + °--'}': } [3/0] {109} diff --git a/tests/testthat/indention_curly_brackets/multi_line_curly_while_for_if_fun-out.R b/tests/testthat/indention_curly_brackets/multi_line_curly_while_for_if_fun-out.R index babdc4a26..f80ed3c8b 100644 --- a/tests/testthat/indention_curly_brackets/multi_line_curly_while_for_if_fun-out.R +++ b/tests/testthat/indention_curly_brackets/multi_line_curly_while_for_if_fun-out.R @@ -8,3 +8,11 @@ a <- function(x, y, z) { x[i] + 1 } } + + +if ( + require("logspline") && + require("rstanarm") +) { + NULL +} diff --git a/tests/testthat/indention_round_brackets/arithmetic_start-in.R b/tests/testthat/indention_round_brackets/arithmetic_start-in.R index d8ef4066c..5d7b411f1 100644 --- a/tests/testthat/indention_round_brackets/arithmetic_start-in.R +++ b/tests/testthat/indention_round_brackets/arithmetic_start-in.R @@ -3,3 +3,13 @@ 3 + 4 ) ) + + ( + + 1 + + 2 + ( + 3 + 4 + + + ) + ) diff --git a/tests/testthat/indention_round_brackets/arithmetic_start-in_tree b/tests/testthat/indention_round_brackets/arithmetic_start-in_tree index b4c868352..90e895710 100644 --- a/tests/testthat/indention_round_brackets/arithmetic_start-in_tree +++ b/tests/testthat/indention_round_brackets/arithmetic_start-in_tree @@ -1,23 +1,46 @@ ROOT (token: short_text [lag_newlines/spaces] {pos_id}) - °--expr: (1 + - [0/0] {1} - ¦--'(': ( [0/0] {2} - ¦--expr: 1 + + ¦--expr: (1 + + [0/10] {1} + ¦ ¦--'(': ( [0/0] {2} + ¦ ¦--expr: 1 + 2 [0/0] {3} - ¦ ¦--expr: 1 [0/1] {6} - ¦ ¦ °--NUM_CONST: 1 [0/0] {5} - ¦ ¦--'+': + [0/0] {7} - ¦ ¦--expr: 2 [1/1] {9} - ¦ ¦ °--NUM_CONST: 2 [0/0] {8} - ¦ ¦--'+': + [0/1] {10} - ¦ °--expr: ( + ¦ ¦ ¦--expr: 1 [0/1] {6} + ¦ ¦ ¦ °--NUM_CONST: 1 [0/0] {5} + ¦ ¦ ¦--'+': + [0/0] {7} + ¦ ¦ ¦--expr: 2 [1/1] {9} + ¦ ¦ ¦ °--NUM_CONST: 2 [0/0] {8} + ¦ ¦ ¦--'+': + [0/1] {10} + ¦ ¦ °--expr: ( 3 + [0/0] {11} - ¦ ¦--'(': ( [0/0] {12} - ¦ ¦--expr: 3 + 4 [1/2] {13} - ¦ ¦ ¦--expr: 3 [0/1] {15} - ¦ ¦ ¦ °--NUM_CONST: 3 [0/0] {14} - ¦ ¦ ¦--'+': + [0/1] {16} - ¦ ¦ °--expr: 4 [0/0] {18} - ¦ ¦ °--NUM_CONST: 4 [0/0] {17} - ¦ °--')': ) [1/0] {19} - °--')': ) [1/0] {20} + ¦ ¦ ¦--'(': ( [0/0] {12} + ¦ ¦ ¦--expr: 3 + 4 [1/2] {13} + ¦ ¦ ¦ ¦--expr: 3 [0/1] {15} + ¦ ¦ ¦ ¦ °--NUM_CONST: 3 [0/0] {14} + ¦ ¦ ¦ ¦--'+': + [0/1] {16} + ¦ ¦ ¦ °--expr: 4 [0/0] {18} + ¦ ¦ ¦ °--NUM_CONST: 4 [0/0] {17} + ¦ ¦ °--')': ) [1/0] {19} + ¦ °--')': ) [1/0] {20} + °--expr: ( + + [2/0] {21} + ¦--'(': ( [0/12] {22} + ¦--expr: 1 + + [2/10] {23} + ¦ ¦--expr: 1 [0/1] {26} + ¦ ¦ °--NUM_CONST: 1 [0/0] {25} + ¦ ¦--'+': + [0/14] {27} + ¦ ¦--expr: 2 [1/1] {29} + ¦ ¦ °--NUM_CONST: 2 [0/0] {28} + ¦ ¦--'+': + [0/1] {30} + ¦ °--expr: ( + [0/0] {31} + ¦ ¦--'(': ( [0/16] {32} + ¦ ¦--expr: 3 + 4 [1/14] {33} + ¦ ¦ ¦--expr: 3 [0/1] {35} + ¦ ¦ ¦ °--NUM_CONST: 3 [0/0] {34} + ¦ ¦ ¦--'+': + [0/1] {36} + ¦ ¦ °--expr: 4 [0/0] {38} + ¦ ¦ °--NUM_CONST: 4 [0/0] {37} + ¦ °--')': ) [3/0] {39} + °--')': ) [1/0] {40} diff --git a/tests/testthat/indention_round_brackets/arithmetic_start-out.R b/tests/testthat/indention_round_brackets/arithmetic_start-out.R index ec2ff7135..337db97f2 100644 --- a/tests/testthat/indention_round_brackets/arithmetic_start-out.R +++ b/tests/testthat/indention_round_brackets/arithmetic_start-out.R @@ -3,3 +3,10 @@ 3 + 4 ) ) + +( + 1 + + 2 + ( + 3 + 4 + ) +) diff --git a/tests/testthat/indention_round_brackets/multi_line-random-in.R b/tests/testthat/indention_round_brackets/multi_line-random-in.R index 15c35f66c..43d3ef0e3 100644 --- a/tests/testthat/indention_round_brackets/multi_line-random-in.R +++ b/tests/testthat/indention_round_brackets/multi_line-random-in.R @@ -7,3 +7,16 @@ call3(1, 2, 22), ), 144 ) + +call( + + 1, + call2( + 2, 3, + call3(1, 2, 22), + 5 + + ), + 144 + +) diff --git a/tests/testthat/indention_round_brackets/multi_line-random-in_tree b/tests/testthat/indention_round_brackets/multi_line-random-in_tree index def8bc3ab..8dc8b53a4 100644 --- a/tests/testthat/indention_round_brackets/multi_line-random-in_tree +++ b/tests/testthat/indention_round_brackets/multi_line-random-in_tree @@ -1,39 +1,77 @@ ROOT (token: short_text [lag_newlines/spaces] {pos_id}) - °--expr: call( [0/0] {1} - ¦--expr: call [0/0] {3} - ¦ °--SYMBOL_FUNCTION_CALL: call [0/0] {2} - ¦--'(': ( [0/0] {4} - ¦--expr: 1 [1/0] {6} - ¦ °--NUM_CONST: 1 [0/0] {5} - ¦--',': , [0/2] {7} - ¦--expr: call2 [1/0] {8} - ¦ ¦--expr: call2 [0/0] {10} - ¦ ¦ °--SYMBOL_FUNCTION_CALL: call2 [0/0] {9} - ¦ ¦--'(': ( [0/4] {11} - ¦ ¦--expr: 2 [1/0] {13} - ¦ ¦ °--NUM_CONST: 2 [0/0] {12} - ¦ ¦--',': , [0/1] {14} - ¦ ¦--expr: 3 [0/0] {16} - ¦ ¦ °--NUM_CONST: 3 [0/0] {15} - ¦ ¦--',': , [0/0] {17} - ¦ ¦--expr: call3 [1/0] {18} - ¦ ¦ ¦--expr: call3 [0/0] {20} - ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: call3 [0/0] {19} - ¦ ¦ ¦--'(': ( [0/0] {21} - ¦ ¦ ¦--expr: 1 [0/0] {23} - ¦ ¦ ¦ °--NUM_CONST: 1 [0/0] {22} - ¦ ¦ ¦--',': , [0/1] {24} - ¦ ¦ ¦--expr: 2 [0/0] {26} - ¦ ¦ ¦ °--NUM_CONST: 2 [0/0] {25} - ¦ ¦ ¦--',': , [0/1] {27} - ¦ ¦ ¦--expr: 22 [0/0] {29} - ¦ ¦ ¦ °--NUM_CONST: 22 [0/0] {28} - ¦ ¦ °--')': ) [0/0] {30} - ¦ ¦--',': , [0/13] {31} - ¦ ¦--expr: 5 [1/2] {33} - ¦ ¦ °--NUM_CONST: 5 [0/0] {32} - ¦ °--')': ) [1/0] {34} - ¦--',': , [0/2] {35} - ¦--expr: 144 [1/12] {37} - ¦ °--NUM_CONST: 144 [0/0] {36} - °--')': ) [1/0] {38} + ¦--expr: call( [0/0] {1} + ¦ ¦--expr: call [0/0] {3} + ¦ ¦ °--SYMBOL_FUNCTION_CALL: call [0/0] {2} + ¦ ¦--'(': ( [0/0] {4} + ¦ ¦--expr: 1 [1/0] {6} + ¦ ¦ °--NUM_CONST: 1 [0/0] {5} + ¦ ¦--',': , [0/2] {7} + ¦ ¦--expr: call2 [1/0] {8} + ¦ ¦ ¦--expr: call2 [0/0] {10} + ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: call2 [0/0] {9} + ¦ ¦ ¦--'(': ( [0/4] {11} + ¦ ¦ ¦--expr: 2 [1/0] {13} + ¦ ¦ ¦ °--NUM_CONST: 2 [0/0] {12} + ¦ ¦ ¦--',': , [0/1] {14} + ¦ ¦ ¦--expr: 3 [0/0] {16} + ¦ ¦ ¦ °--NUM_CONST: 3 [0/0] {15} + ¦ ¦ ¦--',': , [0/0] {17} + ¦ ¦ ¦--expr: call3 [1/0] {18} + ¦ ¦ ¦ ¦--expr: call3 [0/0] {20} + ¦ ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: call3 [0/0] {19} + ¦ ¦ ¦ ¦--'(': ( [0/0] {21} + ¦ ¦ ¦ ¦--expr: 1 [0/0] {23} + ¦ ¦ ¦ ¦ °--NUM_CONST: 1 [0/0] {22} + ¦ ¦ ¦ ¦--',': , [0/1] {24} + ¦ ¦ ¦ ¦--expr: 2 [0/0] {26} + ¦ ¦ ¦ ¦ °--NUM_CONST: 2 [0/0] {25} + ¦ ¦ ¦ ¦--',': , [0/1] {27} + ¦ ¦ ¦ ¦--expr: 22 [0/0] {29} + ¦ ¦ ¦ ¦ °--NUM_CONST: 22 [0/0] {28} + ¦ ¦ ¦ °--')': ) [0/0] {30} + ¦ ¦ ¦--',': , [0/13] {31} + ¦ ¦ ¦--expr: 5 [1/2] {33} + ¦ ¦ ¦ °--NUM_CONST: 5 [0/0] {32} + ¦ ¦ °--')': ) [1/0] {34} + ¦ ¦--',': , [0/2] {35} + ¦ ¦--expr: 144 [1/12] {37} + ¦ ¦ °--NUM_CONST: 144 [0/0] {36} + ¦ °--')': ) [1/0] {38} + °--expr: call( [2/0] {39} + ¦--expr: call [0/0] {41} + ¦ °--SYMBOL_FUNCTION_CALL: call [0/0] {40} + ¦--'(': ( [0/2] {42} + ¦--expr: 1 [2/0] {44} + ¦ °--NUM_CONST: 1 [0/0] {43} + ¦--',': , [0/2] {45} + ¦--expr: call2 [1/0] {46} + ¦ ¦--expr: call2 [0/0] {48} + ¦ ¦ °--SYMBOL_FUNCTION_CALL: call2 [0/0] {47} + ¦ ¦--'(': ( [0/4] {49} + ¦ ¦--expr: 2 [1/0] {51} + ¦ ¦ °--NUM_CONST: 2 [0/0] {50} + ¦ ¦--',': , [0/1] {52} + ¦ ¦--expr: 3 [0/0] {54} + ¦ ¦ °--NUM_CONST: 3 [0/0] {53} + ¦ ¦--',': , [0/4] {55} + ¦ ¦--expr: call3 [1/0] {56} + ¦ ¦ ¦--expr: call3 [0/0] {58} + ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: call3 [0/0] {57} + ¦ ¦ ¦--'(': ( [0/0] {59} + ¦ ¦ ¦--expr: 1 [0/0] {61} + ¦ ¦ ¦ °--NUM_CONST: 1 [0/0] {60} + ¦ ¦ ¦--',': , [0/1] {62} + ¦ ¦ ¦--expr: 2 [0/0] {64} + ¦ ¦ ¦ °--NUM_CONST: 2 [0/0] {63} + ¦ ¦ ¦--',': , [0/1] {65} + ¦ ¦ ¦--expr: 22 [0/0] {67} + ¦ ¦ ¦ °--NUM_CONST: 22 [0/0] {66} + ¦ ¦ °--')': ) [0/0] {68} + ¦ ¦--',': , [0/4] {69} + ¦ ¦--expr: 5 [1/2] {71} + ¦ ¦ °--NUM_CONST: 5 [0/0] {70} + ¦ °--')': ) [2/0] {72} + ¦--',': , [0/2] {73} + ¦--expr: 144 [1/0] {75} + ¦ °--NUM_CONST: 144 [0/0] {74} + °--')': ) [2/0] {76} diff --git a/tests/testthat/indention_round_brackets/multi_line-random-out.R b/tests/testthat/indention_round_brackets/multi_line-random-out.R index e960a3d0d..98b2950bd 100644 --- a/tests/testthat/indention_round_brackets/multi_line-random-out.R +++ b/tests/testthat/indention_round_brackets/multi_line-random-out.R @@ -7,3 +7,13 @@ call( ), 144 ) + +call( + 1, + call2( + 2, 3, + call3(1, 2, 22), + 5 + ), + 144 +) diff --git a/tests/testthat/indention_square_brackets/square_brackets_line_break-in.R b/tests/testthat/indention_square_brackets/square_brackets_line_break-in.R index 6dd33a894..645dcaaee 100644 --- a/tests/testthat/indention_square_brackets/square_brackets_line_break-in.R +++ b/tests/testthat/indention_square_brackets/square_brackets_line_break-in.R @@ -19,6 +19,14 @@ fac[ ] fac[, `:`(a = c) +] + +fac[ + + , `:`(a = c) + + + ] x[a ==3 | @@ -44,3 +52,31 @@ x[a ==3 && x[a ==3 & b == v,] + +x[ + + + a ==3 & + b == v, + + + ] + +x[ + + a, + b +] + +x[ + a, + b + +] + +x[ + + a, + b + +] diff --git a/tests/testthat/indention_square_brackets/square_brackets_line_break-in_tree b/tests/testthat/indention_square_brackets/square_brackets_line_break-in_tree index 834f2095e..5f73336d2 100644 --- a/tests/testthat/indention_square_brackets/square_brackets_line_break-in_tree +++ b/tests/testthat/indention_square_brackets/square_brackets_line_break-in_tree @@ -118,163 +118,237 @@ ROOT (token: short_text [lag_newlines/spaces] {pos_id}) ¦ ¦ ¦ °--SYMBOL: c [0/0] {113} ¦ ¦ °--')': ) [0/0] {115} ¦ °--']': ] [1/0] {116} - ¦--expr: x[a = [2/0] {117} - ¦ ¦--expr: x [0/0] {119} - ¦ ¦ °--SYMBOL: x [0/0] {118} - ¦ ¦--'[': [ [0/0] {120} - ¦ ¦--expr: a ==3 [0/0] {121} - ¦ ¦ ¦--expr: a ==3 [0/1] {122} - ¦ ¦ ¦ ¦--expr: a [0/1] {124} - ¦ ¦ ¦ ¦ °--SYMBOL: a [0/0] {123} - ¦ ¦ ¦ ¦--EQ: == [0/0] {125} - ¦ ¦ ¦ °--expr: 3 [0/0] {127} - ¦ ¦ ¦ °--NUM_CONST: 3 [0/0] {126} - ¦ ¦ ¦--OR: | [0/2] {128} - ¦ ¦ °--expr: b == [1/0] {129} - ¦ ¦ ¦--expr: b [0/1] {131} - ¦ ¦ ¦ °--SYMBOL: b [0/0] {130} - ¦ ¦ ¦--EQ: == [0/1] {132} - ¦ ¦ °--expr: v [0/0] {134} - ¦ ¦ °--SYMBOL: v [0/0] {133} - ¦ ¦--',': , [0/0] {135} - ¦ °--']': ] [0/0] {136} - ¦--expr: x[a = [2/0] {137} - ¦ ¦--expr: x [0/0] {139} - ¦ ¦ °--SYMBOL: x [0/0] {138} - ¦ ¦--'[': [ [0/0] {140} - ¦ ¦--expr: a ==3 [0/0] {141} - ¦ ¦ ¦--expr: a ==3 [0/2] {142} - ¦ ¦ ¦ ¦--expr: a [0/1] {144} - ¦ ¦ ¦ ¦ °--SYMBOL: a [0/0] {143} - ¦ ¦ ¦ ¦--EQ: == [0/0] {145} - ¦ ¦ ¦ °--expr: 3 [0/0] {147} - ¦ ¦ ¦ °--NUM_CONST: 3 [0/0] {146} - ¦ ¦ ¦--OR: | [1/2] {148} - ¦ ¦ °--expr: b == [0/0] {149} - ¦ ¦ ¦--expr: b [0/1] {151} - ¦ ¦ ¦ °--SYMBOL: b [0/0] {150} - ¦ ¦ ¦--EQ: == [0/1] {152} - ¦ ¦ °--expr: v [0/0] {154} - ¦ ¦ °--SYMBOL: v [0/0] {153} - ¦ ¦--',': , [0/0] {155} - ¦ °--']': ] [0/0] {156} - ¦--expr: x[a = [2/0] {157} - ¦ ¦--expr: x [0/0] {159} - ¦ ¦ °--SYMBOL: x [0/0] {158} - ¦ ¦--'[': [ [0/0] {160} - ¦ ¦--expr: a ==3 [0/0] {161} - ¦ ¦ ¦--expr: a ==3 [0/1] {162} - ¦ ¦ ¦ ¦--expr: a [0/1] {164} - ¦ ¦ ¦ ¦ °--SYMBOL: a [0/0] {163} - ¦ ¦ ¦ ¦--EQ: == [0/0] {165} - ¦ ¦ ¦ °--expr: 3 [0/0] {167} - ¦ ¦ ¦ °--NUM_CONST: 3 [0/0] {166} - ¦ ¦ ¦--OR2: || [0/4] {168} - ¦ ¦ °--expr: b == [1/0] {169} - ¦ ¦ ¦--expr: b [0/1] {171} - ¦ ¦ ¦ °--SYMBOL: b [0/0] {170} - ¦ ¦ ¦--EQ: == [0/1] {172} - ¦ ¦ °--expr: v [0/0] {174} - ¦ ¦ °--SYMBOL: v [0/0] {173} - ¦ ¦--',': , [0/0] {175} - ¦ °--']': ] [0/0] {176} - ¦--expr: x[a = [2/0] {177} - ¦ ¦--expr: x [0/0] {179} - ¦ ¦ °--SYMBOL: x [0/0] {178} - ¦ ¦--'[': [ [0/0] {180} - ¦ ¦--expr: a ==3 [0/0] {181} - ¦ ¦ ¦--expr: a ==3 [0/2] {182} - ¦ ¦ ¦ ¦--expr: a [0/1] {184} - ¦ ¦ ¦ ¦ °--SYMBOL: a [0/0] {183} - ¦ ¦ ¦ ¦--EQ: == [0/0] {185} - ¦ ¦ ¦ °--expr: 3 [0/0] {187} - ¦ ¦ ¦ °--NUM_CONST: 3 [0/0] {186} - ¦ ¦ ¦--OR2: || [1/2] {188} - ¦ ¦ °--expr: b == [0/0] {189} - ¦ ¦ ¦--expr: b [0/1] {191} - ¦ ¦ ¦ °--SYMBOL: b [0/0] {190} - ¦ ¦ ¦--EQ: == [0/1] {192} - ¦ ¦ °--expr: v [0/0] {194} - ¦ ¦ °--SYMBOL: v [0/0] {193} - ¦ ¦--',': , [0/0] {195} - ¦ °--']': ] [0/0] {196} - ¦--expr: x[a = [2/0] {197} - ¦ ¦--expr: x [0/0] {199} - ¦ ¦ °--SYMBOL: x [0/0] {198} - ¦ ¦--'[': [ [0/0] {200} - ¦ ¦--expr: a ==3 [0/0] {201} - ¦ ¦ ¦--expr: a ==3 [0/2] {202} - ¦ ¦ ¦ ¦--expr: a [0/1] {204} - ¦ ¦ ¦ ¦ °--SYMBOL: a [0/0] {203} - ¦ ¦ ¦ ¦--EQ: == [0/0] {205} - ¦ ¦ ¦ °--expr: 3 [0/0] {207} - ¦ ¦ ¦ °--NUM_CONST: 3 [0/0] {206} - ¦ ¦ ¦--AND2: && [1/2] {208} - ¦ ¦ °--expr: b == [0/0] {209} - ¦ ¦ ¦--expr: b [0/1] {211} - ¦ ¦ ¦ °--SYMBOL: b [0/0] {210} - ¦ ¦ ¦--EQ: == [0/1] {212} - ¦ ¦ °--expr: v [0/0] {214} - ¦ ¦ °--SYMBOL: v [0/0] {213} - ¦ ¦--',': , [0/0] {215} - ¦ °--']': ] [0/0] {216} - ¦--expr: x[a = [2/0] {217} - ¦ ¦--expr: x [0/0] {219} - ¦ ¦ °--SYMBOL: x [0/0] {218} - ¦ ¦--'[': [ [0/0] {220} - ¦ ¦--expr: a ==3 [0/0] {221} - ¦ ¦ ¦--expr: a ==3 [0/2] {222} - ¦ ¦ ¦ ¦--expr: a [0/1] {224} - ¦ ¦ ¦ ¦ °--SYMBOL: a [0/0] {223} - ¦ ¦ ¦ ¦--EQ: == [0/0] {225} - ¦ ¦ ¦ °--expr: 3 [0/0] {227} - ¦ ¦ ¦ °--NUM_CONST: 3 [0/0] {226} - ¦ ¦ ¦--AND: & [1/2] {228} - ¦ ¦ °--expr: b == [0/0] {229} - ¦ ¦ ¦--expr: b [0/1] {231} - ¦ ¦ ¦ °--SYMBOL: b [0/0] {230} - ¦ ¦ ¦--EQ: == [0/1] {232} - ¦ ¦ °--expr: v [0/0] {234} - ¦ ¦ °--SYMBOL: v [0/0] {233} - ¦ ¦--',': , [0/0] {235} - ¦ °--']': ] [0/0] {236} - ¦--expr: x[a = [2/0] {237} - ¦ ¦--expr: x [0/0] {239} - ¦ ¦ °--SYMBOL: x [0/0] {238} - ¦ ¦--'[': [ [0/0] {240} - ¦ ¦--expr: a ==3 [0/0] {241} - ¦ ¦ ¦--expr: a ==3 [0/1] {242} - ¦ ¦ ¦ ¦--expr: a [0/1] {244} - ¦ ¦ ¦ ¦ °--SYMBOL: a [0/0] {243} - ¦ ¦ ¦ ¦--EQ: == [0/0] {245} - ¦ ¦ ¦ °--expr: 3 [0/0] {247} - ¦ ¦ ¦ °--NUM_CONST: 3 [0/0] {246} - ¦ ¦ ¦--AND2: && [0/4] {248} - ¦ ¦ °--expr: b == [1/0] {249} - ¦ ¦ ¦--expr: b [0/1] {251} - ¦ ¦ ¦ °--SYMBOL: b [0/0] {250} - ¦ ¦ ¦--EQ: == [0/1] {252} - ¦ ¦ °--expr: v [0/0] {254} - ¦ ¦ °--SYMBOL: v [0/0] {253} - ¦ ¦--',': , [0/0] {255} - ¦ °--']': ] [0/0] {256} - °--expr: x[a = [2/0] {257} - ¦--expr: x [0/0] {259} - ¦ °--SYMBOL: x [0/0] {258} - ¦--'[': [ [0/0] {260} - ¦--expr: a ==3 [0/0] {261} - ¦ ¦--expr: a ==3 [0/1] {262} - ¦ ¦ ¦--expr: a [0/1] {264} - ¦ ¦ ¦ °--SYMBOL: a [0/0] {263} - ¦ ¦ ¦--EQ: == [0/0] {265} - ¦ ¦ °--expr: 3 [0/0] {267} - ¦ ¦ °--NUM_CONST: 3 [0/0] {266} - ¦ ¦--AND: & [0/3] {268} - ¦ °--expr: b == [1/0] {269} - ¦ ¦--expr: b [0/1] {271} - ¦ ¦ °--SYMBOL: b [0/0] {270} - ¦ ¦--EQ: == [0/1] {272} - ¦ °--expr: v [0/0] {274} - ¦ °--SYMBOL: v [0/0] {273} - ¦--',': , [0/0] {275} - °--']': ] [0/0] {276} + ¦--expr: fac[ + [2/0] {117} + ¦ ¦--expr: fac [0/0] {119} + ¦ ¦ °--SYMBOL: fac [0/0] {118} + ¦ ¦--'[': [ [0/2] {120} + ¦ ¦--',': , [2/1] {121} + ¦ ¦--expr: `:`(a [0/0] {122} + ¦ ¦ ¦--expr: `:` [0/0] {124} + ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: `:` [0/0] {123} + ¦ ¦ ¦--'(': ( [0/0] {125} + ¦ ¦ ¦--SYMBOL_SUB: a [0/1] {126} + ¦ ¦ ¦--EQ_SUB: = [0/1] {127} + ¦ ¦ ¦--expr: c [0/0] {129} + ¦ ¦ ¦ °--SYMBOL: c [0/0] {128} + ¦ ¦ °--')': ) [0/0] {130} + ¦ °--']': ] [4/0] {131} + ¦--expr: x[a = [2/0] {132} + ¦ ¦--expr: x [0/0] {134} + ¦ ¦ °--SYMBOL: x [0/0] {133} + ¦ ¦--'[': [ [0/0] {135} + ¦ ¦--expr: a ==3 [0/0] {136} + ¦ ¦ ¦--expr: a ==3 [0/1] {137} + ¦ ¦ ¦ ¦--expr: a [0/1] {139} + ¦ ¦ ¦ ¦ °--SYMBOL: a [0/0] {138} + ¦ ¦ ¦ ¦--EQ: == [0/0] {140} + ¦ ¦ ¦ °--expr: 3 [0/0] {142} + ¦ ¦ ¦ °--NUM_CONST: 3 [0/0] {141} + ¦ ¦ ¦--OR: | [0/2] {143} + ¦ ¦ °--expr: b == [1/0] {144} + ¦ ¦ ¦--expr: b [0/1] {146} + ¦ ¦ ¦ °--SYMBOL: b [0/0] {145} + ¦ ¦ ¦--EQ: == [0/1] {147} + ¦ ¦ °--expr: v [0/0] {149} + ¦ ¦ °--SYMBOL: v [0/0] {148} + ¦ ¦--',': , [0/0] {150} + ¦ °--']': ] [0/0] {151} + ¦--expr: x[a = [2/0] {152} + ¦ ¦--expr: x [0/0] {154} + ¦ ¦ °--SYMBOL: x [0/0] {153} + ¦ ¦--'[': [ [0/0] {155} + ¦ ¦--expr: a ==3 [0/0] {156} + ¦ ¦ ¦--expr: a ==3 [0/2] {157} + ¦ ¦ ¦ ¦--expr: a [0/1] {159} + ¦ ¦ ¦ ¦ °--SYMBOL: a [0/0] {158} + ¦ ¦ ¦ ¦--EQ: == [0/0] {160} + ¦ ¦ ¦ °--expr: 3 [0/0] {162} + ¦ ¦ ¦ °--NUM_CONST: 3 [0/0] {161} + ¦ ¦ ¦--OR: | [1/2] {163} + ¦ ¦ °--expr: b == [0/0] {164} + ¦ ¦ ¦--expr: b [0/1] {166} + ¦ ¦ ¦ °--SYMBOL: b [0/0] {165} + ¦ ¦ ¦--EQ: == [0/1] {167} + ¦ ¦ °--expr: v [0/0] {169} + ¦ ¦ °--SYMBOL: v [0/0] {168} + ¦ ¦--',': , [0/0] {170} + ¦ °--']': ] [0/0] {171} + ¦--expr: x[a = [2/0] {172} + ¦ ¦--expr: x [0/0] {174} + ¦ ¦ °--SYMBOL: x [0/0] {173} + ¦ ¦--'[': [ [0/0] {175} + ¦ ¦--expr: a ==3 [0/0] {176} + ¦ ¦ ¦--expr: a ==3 [0/1] {177} + ¦ ¦ ¦ ¦--expr: a [0/1] {179} + ¦ ¦ ¦ ¦ °--SYMBOL: a [0/0] {178} + ¦ ¦ ¦ ¦--EQ: == [0/0] {180} + ¦ ¦ ¦ °--expr: 3 [0/0] {182} + ¦ ¦ ¦ °--NUM_CONST: 3 [0/0] {181} + ¦ ¦ ¦--OR2: || [0/4] {183} + ¦ ¦ °--expr: b == [1/0] {184} + ¦ ¦ ¦--expr: b [0/1] {186} + ¦ ¦ ¦ °--SYMBOL: b [0/0] {185} + ¦ ¦ ¦--EQ: == [0/1] {187} + ¦ ¦ °--expr: v [0/0] {189} + ¦ ¦ °--SYMBOL: v [0/0] {188} + ¦ ¦--',': , [0/0] {190} + ¦ °--']': ] [0/0] {191} + ¦--expr: x[a = [2/0] {192} + ¦ ¦--expr: x [0/0] {194} + ¦ ¦ °--SYMBOL: x [0/0] {193} + ¦ ¦--'[': [ [0/0] {195} + ¦ ¦--expr: a ==3 [0/0] {196} + ¦ ¦ ¦--expr: a ==3 [0/2] {197} + ¦ ¦ ¦ ¦--expr: a [0/1] {199} + ¦ ¦ ¦ ¦ °--SYMBOL: a [0/0] {198} + ¦ ¦ ¦ ¦--EQ: == [0/0] {200} + ¦ ¦ ¦ °--expr: 3 [0/0] {202} + ¦ ¦ ¦ °--NUM_CONST: 3 [0/0] {201} + ¦ ¦ ¦--OR2: || [1/2] {203} + ¦ ¦ °--expr: b == [0/0] {204} + ¦ ¦ ¦--expr: b [0/1] {206} + ¦ ¦ ¦ °--SYMBOL: b [0/0] {205} + ¦ ¦ ¦--EQ: == [0/1] {207} + ¦ ¦ °--expr: v [0/0] {209} + ¦ ¦ °--SYMBOL: v [0/0] {208} + ¦ ¦--',': , [0/0] {210} + ¦ °--']': ] [0/0] {211} + ¦--expr: x[a = [2/0] {212} + ¦ ¦--expr: x [0/0] {214} + ¦ ¦ °--SYMBOL: x [0/0] {213} + ¦ ¦--'[': [ [0/0] {215} + ¦ ¦--expr: a ==3 [0/0] {216} + ¦ ¦ ¦--expr: a ==3 [0/2] {217} + ¦ ¦ ¦ ¦--expr: a [0/1] {219} + ¦ ¦ ¦ ¦ °--SYMBOL: a [0/0] {218} + ¦ ¦ ¦ ¦--EQ: == [0/0] {220} + ¦ ¦ ¦ °--expr: 3 [0/0] {222} + ¦ ¦ ¦ °--NUM_CONST: 3 [0/0] {221} + ¦ ¦ ¦--AND2: && [1/2] {223} + ¦ ¦ °--expr: b == [0/0] {224} + ¦ ¦ ¦--expr: b [0/1] {226} + ¦ ¦ ¦ °--SYMBOL: b [0/0] {225} + ¦ ¦ ¦--EQ: == [0/1] {227} + ¦ ¦ °--expr: v [0/0] {229} + ¦ ¦ °--SYMBOL: v [0/0] {228} + ¦ ¦--',': , [0/0] {230} + ¦ °--']': ] [0/0] {231} + ¦--expr: x[a = [2/0] {232} + ¦ ¦--expr: x [0/0] {234} + ¦ ¦ °--SYMBOL: x [0/0] {233} + ¦ ¦--'[': [ [0/0] {235} + ¦ ¦--expr: a ==3 [0/0] {236} + ¦ ¦ ¦--expr: a ==3 [0/2] {237} + ¦ ¦ ¦ ¦--expr: a [0/1] {239} + ¦ ¦ ¦ ¦ °--SYMBOL: a [0/0] {238} + ¦ ¦ ¦ ¦--EQ: == [0/0] {240} + ¦ ¦ ¦ °--expr: 3 [0/0] {242} + ¦ ¦ ¦ °--NUM_CONST: 3 [0/0] {241} + ¦ ¦ ¦--AND: & [1/2] {243} + ¦ ¦ °--expr: b == [0/0] {244} + ¦ ¦ ¦--expr: b [0/1] {246} + ¦ ¦ ¦ °--SYMBOL: b [0/0] {245} + ¦ ¦ ¦--EQ: == [0/1] {247} + ¦ ¦ °--expr: v [0/0] {249} + ¦ ¦ °--SYMBOL: v [0/0] {248} + ¦ ¦--',': , [0/0] {250} + ¦ °--']': ] [0/0] {251} + ¦--expr: x[a = [2/0] {252} + ¦ ¦--expr: x [0/0] {254} + ¦ ¦ °--SYMBOL: x [0/0] {253} + ¦ ¦--'[': [ [0/0] {255} + ¦ ¦--expr: a ==3 [0/0] {256} + ¦ ¦ ¦--expr: a ==3 [0/1] {257} + ¦ ¦ ¦ ¦--expr: a [0/1] {259} + ¦ ¦ ¦ ¦ °--SYMBOL: a [0/0] {258} + ¦ ¦ ¦ ¦--EQ: == [0/0] {260} + ¦ ¦ ¦ °--expr: 3 [0/0] {262} + ¦ ¦ ¦ °--NUM_CONST: 3 [0/0] {261} + ¦ ¦ ¦--AND2: && [0/4] {263} + ¦ ¦ °--expr: b == [1/0] {264} + ¦ ¦ ¦--expr: b [0/1] {266} + ¦ ¦ ¦ °--SYMBOL: b [0/0] {265} + ¦ ¦ ¦--EQ: == [0/1] {267} + ¦ ¦ °--expr: v [0/0] {269} + ¦ ¦ °--SYMBOL: v [0/0] {268} + ¦ ¦--',': , [0/0] {270} + ¦ °--']': ] [0/0] {271} + ¦--expr: x[a = [2/0] {272} + ¦ ¦--expr: x [0/0] {274} + ¦ ¦ °--SYMBOL: x [0/0] {273} + ¦ ¦--'[': [ [0/0] {275} + ¦ ¦--expr: a ==3 [0/0] {276} + ¦ ¦ ¦--expr: a ==3 [0/1] {277} + ¦ ¦ ¦ ¦--expr: a [0/1] {279} + ¦ ¦ ¦ ¦ °--SYMBOL: a [0/0] {278} + ¦ ¦ ¦ ¦--EQ: == [0/0] {280} + ¦ ¦ ¦ °--expr: 3 [0/0] {282} + ¦ ¦ ¦ °--NUM_CONST: 3 [0/0] {281} + ¦ ¦ ¦--AND: & [0/3] {283} + ¦ ¦ °--expr: b == [1/0] {284} + ¦ ¦ ¦--expr: b [0/1] {286} + ¦ ¦ ¦ °--SYMBOL: b [0/0] {285} + ¦ ¦ ¦--EQ: == [0/1] {287} + ¦ ¦ °--expr: v [0/0] {289} + ¦ ¦ °--SYMBOL: v [0/0] {288} + ¦ ¦--',': , [0/0] {290} + ¦ °--']': ] [0/0] {291} + ¦--expr: x[ + + + [2/0] {292} + ¦ ¦--expr: x [0/0] {294} + ¦ ¦ °--SYMBOL: x [0/0] {293} + ¦ ¦--'[': [ [0/2] {295} + ¦ ¦--expr: a ==3 [3/0] {296} + ¦ ¦ ¦--expr: a ==3 [0/1] {297} + ¦ ¦ ¦ ¦--expr: a [0/1] {299} + ¦ ¦ ¦ ¦ °--SYMBOL: a [0/0] {298} + ¦ ¦ ¦ ¦--EQ: == [0/0] {300} + ¦ ¦ ¦ °--expr: 3 [0/0] {302} + ¦ ¦ ¦ °--NUM_CONST: 3 [0/0] {301} + ¦ ¦ ¦--AND: & [0/4] {303} + ¦ ¦ °--expr: b == [1/0] {304} + ¦ ¦ ¦--expr: b [0/1] {306} + ¦ ¦ ¦ °--SYMBOL: b [0/0] {305} + ¦ ¦ ¦--EQ: == [0/1] {307} + ¦ ¦ °--expr: v [0/0] {309} + ¦ ¦ °--SYMBOL: v [0/0] {308} + ¦ ¦--',': , [0/2] {310} + ¦ °--']': ] [3/0] {311} + ¦--expr: x[ + + [2/0] {312} + ¦ ¦--expr: x [0/0] {314} + ¦ ¦ °--SYMBOL: x [0/0] {313} + ¦ ¦--'[': [ [0/2] {315} + ¦ ¦--expr: a [2/0] {317} + ¦ ¦ °--SYMBOL: a [0/0] {316} + ¦ ¦--',': , [0/2] {318} + ¦ ¦--expr: b [1/0] {320} + ¦ ¦ °--SYMBOL: b [0/0] {319} + ¦ °--']': ] [1/0] {321} + ¦--expr: x[ + [2/0] {322} + ¦ ¦--expr: x [0/0] {324} + ¦ ¦ °--SYMBOL: x [0/0] {323} + ¦ ¦--'[': [ [0/2] {325} + ¦ ¦--expr: a [1/0] {327} + ¦ ¦ °--SYMBOL: a [0/0] {326} + ¦ ¦--',': , [0/2] {328} + ¦ ¦--expr: b [1/0] {330} + ¦ ¦ °--SYMBOL: b [0/0] {329} + ¦ °--']': ] [2/0] {331} + °--expr: x[ + + [2/0] {332} + ¦--expr: x [0/0] {334} + ¦ °--SYMBOL: x [0/0] {333} + ¦--'[': [ [0/2] {335} + ¦--expr: a [2/0] {337} + ¦ °--SYMBOL: a [0/0] {336} + ¦--',': , [0/2] {338} + ¦--expr: b [1/0] {340} + ¦ °--SYMBOL: b [0/0] {339} + °--']': ] [2/0] {341} diff --git a/tests/testthat/indention_square_brackets/square_brackets_line_break-out.R b/tests/testthat/indention_square_brackets/square_brackets_line_break-out.R index ae6be434b..112c04b31 100644 --- a/tests/testthat/indention_square_brackets/square_brackets_line_break-out.R +++ b/tests/testthat/indention_square_brackets/square_brackets_line_break-out.R @@ -25,6 +25,10 @@ fac[ fac[, `:`(a = c)] +fac[ + , `:`(a = c) +] + x[a == 3 | b == v, ] @@ -48,3 +52,23 @@ x[a == 3 && x[a == 3 & b == v, ] + +x[ + a == 3 & + b == v, +] + +x[ + a, + b +] + +x[ + a, + b +] + +x[ + a, + b +] From 280b272c92010688c0cc0257355cf334abc5e8d2 Mon Sep 17 00:00:00 2001 From: Indrajeet Patil Date: Wed, 1 May 2024 18:58:18 +0200 Subject: [PATCH 05/20] bandaid --- R/rules-spaces.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/R/rules-spaces.R b/R/rules-spaces.R index 54b76bbd8..728e372ac 100644 --- a/R/rules-spaces.R +++ b/R/rules-spaces.R @@ -140,7 +140,7 @@ remove_space_before_opening_paren <- function(pd_flat) { pd_flat } -remove_space_after_opening_paren <- function(pd_flat, strict) { +remove_space_after_opening_paren <- function(pd_flat, strict = TRUE) { braces <- c("'('", "'['", "LBB") paren_after <- pd_flat$token %in% braces if (!any(paren_after)) { @@ -156,7 +156,7 @@ remove_space_after_opening_paren <- function(pd_flat, strict) { pd_flat } -remove_space_before_closing_paren <- function(pd_flat, strict) { +remove_space_before_closing_paren <- function(pd_flat, strict = TRUE) { braces <- c("')'", "']'") paren_after <- pd_flat$token %in% braces if (!any(paren_after)) { From 8f4bda9498c748908f19010c1ebaafa28b1dc83c Mon Sep 17 00:00:00 2001 From: Indrajeet Patil Date: Tue, 7 May 2024 22:28:53 +0200 Subject: [PATCH 06/20] include tests with comments; remove strict param --- R/rules-spaces.R | 20 ++-- R/style-guides.R | 10 +- .../multi_line_curly_only-in.R | 2 + .../multi_line_curly_only-in_tree | 50 +++++----- .../multi_line_curly_only-out.R | 3 + .../arithmetic_start-in.R | 3 + .../arithmetic_start-in_tree | 18 ++-- .../arithmetic_start-out.R | 3 + .../square_brackets_line_break-in.R | 3 +- .../square_brackets_line_break-in_tree | 97 ++++++++++--------- .../square_brackets_line_break-out.R | 2 + .../blank-non-strict-out.R | 2 - 12 files changed, 110 insertions(+), 103 deletions(-) diff --git a/R/rules-spaces.R b/R/rules-spaces.R index 728e372ac..77ecd4878 100644 --- a/R/rules-spaces.R +++ b/R/rules-spaces.R @@ -140,34 +140,30 @@ remove_space_before_opening_paren <- function(pd_flat) { pd_flat } -remove_space_after_opening_paren <- function(pd_flat, strict = TRUE) { +remove_space_after_opening_paren <- function(pd_flat) { braces <- c("'('", "'['", "LBB") paren_after <- pd_flat$token %in% braces if (!any(paren_after)) { return(pd_flat) } # remove blank lines after opening braces - if (strict) { - pd_flat$lag_newlines[ - lag(pd_flat$token %in% braces) & pd_flat$lag_newlines > 1L - ] <- 1L - } + pd_flat$lag_newlines[ + lag(pd_flat$token %in% braces) & pd_flat$lag_newlines > 1L + ] <- 1L pd_flat$spaces[paren_after & (pd_flat$newlines == 0L)] <- 0L pd_flat } -remove_space_before_closing_paren <- function(pd_flat, strict = TRUE) { +remove_space_before_closing_paren <- function(pd_flat) { braces <- c("')'", "']'") paren_after <- pd_flat$token %in% braces if (!any(paren_after)) { return(pd_flat) } # remove blank lines before closing braces - if (strict) { - pd_flat$lag_newlines[ - pd_flat$token %in% braces & pd_flat$lag_newlines > 1L - ] <- 1L - } + pd_flat$lag_newlines[ + pd_flat$token %in% braces & pd_flat$lag_newlines > 1L + ] <- 1L paren_before <- lead(paren_after, default = FALSE) pd_flat$spaces[paren_before & (pd_flat$newlines == 0L)] <- 0L pd_flat diff --git a/R/style-guides.R b/R/style-guides.R index 2eb8cd975..735e6a1f5 100644 --- a/R/style-guides.R +++ b/R/style-guides.R @@ -87,10 +87,7 @@ tidyverse_style <- function(scope = "tokens", } space_manipulators <- if ("spaces" %in% scope) { list( - remove_space_before_closing_paren = purrr::partial( - remove_space_before_closing_paren, - strict = strict - ), + remove_space_before_closing_paren = remove_space_before_closing_paren, remove_space_before_opening_paren = if (strict) { remove_space_before_opening_paren }, @@ -108,10 +105,7 @@ tidyverse_style <- function(scope = "tokens", spacing_around_op = purrr::partial(set_space_around_op, strict = strict ), - remove_space_after_opening_paren = purrr::partial( - remove_space_after_opening_paren, - strict = strict - ), + remove_space_after_opening_paren = remove_space_after_opening_paren, remove_space_after_excl = remove_space_after_excl, set_space_after_bang_bang = set_space_after_bang_bang, remove_space_before_dollar = remove_space_before_dollar, diff --git a/tests/testthat/indention_curly_brackets/multi_line_curly_only-in.R b/tests/testthat/indention_curly_brackets/multi_line_curly_only-in.R index e8bca1432..6f7e9c5b5 100644 --- a/tests/testthat/indention_curly_brackets/multi_line_curly_only-in.R +++ b/tests/testthat/indention_curly_brackets/multi_line_curly_only-in.R @@ -5,8 +5,10 @@ { + # some additions {1 + 3} {2 + sin(pi)} + # nothing to see here } diff --git a/tests/testthat/indention_curly_brackets/multi_line_curly_only-in_tree b/tests/testthat/indention_curly_brackets/multi_line_curly_only-in_tree index 4e4ee22af..8c94a7c77 100644 --- a/tests/testthat/indention_curly_brackets/multi_line_curly_only-in_tree +++ b/tests/testthat/indention_curly_brackets/multi_line_curly_only-in_tree @@ -30,27 +30,29 @@ ROOT (token: short_text [lag_newlines/spaces] {pos_id}) [2/0] {27} ¦--'{': { [0/8] {28} - ¦--expr: {1 + [2/8] {29} - ¦ ¦--'{': { [0/0] {30} - ¦ ¦--expr: 1 + 3 [0/0] {31} - ¦ ¦ ¦--expr: 1 [0/1] {33} - ¦ ¦ ¦ °--NUM_CONST: 1 [0/0] {32} - ¦ ¦ ¦--'+': + [0/1] {34} - ¦ ¦ °--expr: 3 [0/0] {36} - ¦ ¦ °--NUM_CONST: 3 [0/0] {35} - ¦ °--'}': } [0/0] {37} - ¦--expr: {2 + [1/6] {38} - ¦ ¦--'{': { [0/0] {39} - ¦ ¦--expr: 2 + s [0/0] {40} - ¦ ¦ ¦--expr: 2 [0/1] {42} - ¦ ¦ ¦ °--NUM_CONST: 2 [0/0] {41} - ¦ ¦ ¦--'+': + [0/1] {43} - ¦ ¦ °--expr: sin(p [0/0] {44} - ¦ ¦ ¦--expr: sin [0/0] {46} - ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: sin [0/0] {45} - ¦ ¦ ¦--'(': ( [0/0] {47} - ¦ ¦ ¦--expr: pi [0/0] {49} - ¦ ¦ ¦ °--SYMBOL: pi [0/0] {48} - ¦ ¦ °--')': ) [0/0] {50} - ¦ °--'}': } [0/0] {51} - °--'}': } [3/0] {52} + ¦--COMMENT: # som [2/8] {29} + ¦--expr: {1 + [1/8] {30} + ¦ ¦--'{': { [0/0] {31} + ¦ ¦--expr: 1 + 3 [0/0] {32} + ¦ ¦ ¦--expr: 1 [0/1] {34} + ¦ ¦ ¦ °--NUM_CONST: 1 [0/0] {33} + ¦ ¦ ¦--'+': + [0/1] {35} + ¦ ¦ °--expr: 3 [0/0] {37} + ¦ ¦ °--NUM_CONST: 3 [0/0] {36} + ¦ °--'}': } [0/0] {38} + ¦--expr: {2 + [1/8] {39} + ¦ ¦--'{': { [0/0] {40} + ¦ ¦--expr: 2 + s [0/0] {41} + ¦ ¦ ¦--expr: 2 [0/1] {43} + ¦ ¦ ¦ °--NUM_CONST: 2 [0/0] {42} + ¦ ¦ ¦--'+': + [0/1] {44} + ¦ ¦ °--expr: sin(p [0/0] {45} + ¦ ¦ ¦--expr: sin [0/0] {47} + ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: sin [0/0] {46} + ¦ ¦ ¦--'(': ( [0/0] {48} + ¦ ¦ ¦--expr: pi [0/0] {50} + ¦ ¦ ¦ °--SYMBOL: pi [0/0] {49} + ¦ ¦ °--')': ) [0/0] {51} + ¦ °--'}': } [0/0] {52} + ¦--COMMENT: # not [2/6] {53} + °--'}': } [2/0] {54} diff --git a/tests/testthat/indention_curly_brackets/multi_line_curly_only-out.R b/tests/testthat/indention_curly_brackets/multi_line_curly_only-out.R index e4c5631c4..9ad5a4c06 100644 --- a/tests/testthat/indention_curly_brackets/multi_line_curly_only-out.R +++ b/tests/testthat/indention_curly_brackets/multi_line_curly_only-out.R @@ -8,10 +8,13 @@ } { + # some additions { 1 + 3 } { 2 + sin(pi) } + + # nothing to see here } diff --git a/tests/testthat/indention_round_brackets/arithmetic_start-in.R b/tests/testthat/indention_round_brackets/arithmetic_start-in.R index 5d7b411f1..22e25bcbf 100644 --- a/tests/testthat/indention_round_brackets/arithmetic_start-in.R +++ b/tests/testthat/indention_round_brackets/arithmetic_start-in.R @@ -8,7 +8,10 @@ 1 + 2 + ( + # the space below is intentional + 3 + 4 + # but the one here isn't ) diff --git a/tests/testthat/indention_round_brackets/arithmetic_start-in_tree b/tests/testthat/indention_round_brackets/arithmetic_start-in_tree index 90e895710..bb349123c 100644 --- a/tests/testthat/indention_round_brackets/arithmetic_start-in_tree +++ b/tests/testthat/indention_round_brackets/arithmetic_start-in_tree @@ -36,11 +36,13 @@ ROOT (token: short_text [lag_newlines/spaces] {pos_id}) ¦ °--expr: ( [0/0] {31} ¦ ¦--'(': ( [0/16] {32} - ¦ ¦--expr: 3 + 4 [1/14] {33} - ¦ ¦ ¦--expr: 3 [0/1] {35} - ¦ ¦ ¦ °--NUM_CONST: 3 [0/0] {34} - ¦ ¦ ¦--'+': + [0/1] {36} - ¦ ¦ °--expr: 4 [0/0] {38} - ¦ ¦ °--NUM_CONST: 4 [0/0] {37} - ¦ °--')': ) [3/0] {39} - °--')': ) [1/0] {40} + ¦ ¦--COMMENT: # the [1/16] {33} + ¦ ¦--expr: 3 + 4 [2/16] {34} + ¦ ¦ ¦--expr: 3 [0/1] {36} + ¦ ¦ ¦ °--NUM_CONST: 3 [0/0] {35} + ¦ ¦ ¦--'+': + [0/1] {37} + ¦ ¦ °--expr: 4 [0/0] {39} + ¦ ¦ °--NUM_CONST: 4 [0/0] {38} + ¦ ¦--COMMENT: # but [1/14] {40} + ¦ °--')': ) [3/0] {41} + °--')': ) [1/0] {42} diff --git a/tests/testthat/indention_round_brackets/arithmetic_start-out.R b/tests/testthat/indention_round_brackets/arithmetic_start-out.R index 337db97f2..efaf16e7b 100644 --- a/tests/testthat/indention_round_brackets/arithmetic_start-out.R +++ b/tests/testthat/indention_round_brackets/arithmetic_start-out.R @@ -7,6 +7,9 @@ ( 1 + 2 + ( + # the space below is intentional + 3 + 4 + # but the one here isn't ) ) diff --git a/tests/testthat/indention_square_brackets/square_brackets_line_break-in.R b/tests/testthat/indention_square_brackets/square_brackets_line_break-in.R index 645dcaaee..bb0f3aca6 100644 --- a/tests/testthat/indention_square_brackets/square_brackets_line_break-in.R +++ b/tests/testthat/indention_square_brackets/square_brackets_line_break-in.R @@ -55,9 +55,10 @@ x[a ==3 & x[ - + # comments above a ==3 & b == v, + # or below shouldn't be an issue ] diff --git a/tests/testthat/indention_square_brackets/square_brackets_line_break-in_tree b/tests/testthat/indention_square_brackets/square_brackets_line_break-in_tree index 5f73336d2..3ab82d3d9 100644 --- a/tests/testthat/indention_square_brackets/square_brackets_line_break-in_tree +++ b/tests/testthat/indention_square_brackets/square_brackets_line_break-in_tree @@ -296,59 +296,60 @@ ROOT (token: short_text [lag_newlines/spaces] {pos_id}) ¦ °--']': ] [0/0] {291} ¦--expr: x[ - - [2/0] {292} + [2/0] {292} ¦ ¦--expr: x [0/0] {294} ¦ ¦ °--SYMBOL: x [0/0] {293} ¦ ¦--'[': [ [0/2] {295} - ¦ ¦--expr: a ==3 [3/0] {296} - ¦ ¦ ¦--expr: a ==3 [0/1] {297} - ¦ ¦ ¦ ¦--expr: a [0/1] {299} - ¦ ¦ ¦ ¦ °--SYMBOL: a [0/0] {298} - ¦ ¦ ¦ ¦--EQ: == [0/0] {300} - ¦ ¦ ¦ °--expr: 3 [0/0] {302} - ¦ ¦ ¦ °--NUM_CONST: 3 [0/0] {301} - ¦ ¦ ¦--AND: & [0/4] {303} - ¦ ¦ °--expr: b == [1/0] {304} - ¦ ¦ ¦--expr: b [0/1] {306} - ¦ ¦ ¦ °--SYMBOL: b [0/0] {305} - ¦ ¦ ¦--EQ: == [0/1] {307} - ¦ ¦ °--expr: v [0/0] {309} - ¦ ¦ °--SYMBOL: v [0/0] {308} - ¦ ¦--',': , [0/2] {310} - ¦ °--']': ] [3/0] {311} + ¦ ¦--COMMENT: # com [2/2] {296} + ¦ ¦--expr: a ==3 [1/0] {297} + ¦ ¦ ¦--expr: a ==3 [0/1] {298} + ¦ ¦ ¦ ¦--expr: a [0/1] {300} + ¦ ¦ ¦ ¦ °--SYMBOL: a [0/0] {299} + ¦ ¦ ¦ ¦--EQ: == [0/0] {301} + ¦ ¦ ¦ °--expr: 3 [0/0] {303} + ¦ ¦ ¦ °--NUM_CONST: 3 [0/0] {302} + ¦ ¦ ¦--AND: & [0/4] {304} + ¦ ¦ °--expr: b == [1/0] {305} + ¦ ¦ ¦--expr: b [0/1] {307} + ¦ ¦ ¦ °--SYMBOL: b [0/0] {306} + ¦ ¦ ¦--EQ: == [0/1] {308} + ¦ ¦ °--expr: v [0/0] {310} + ¦ ¦ °--SYMBOL: v [0/0] {309} + ¦ ¦--',': , [0/2] {311} + ¦ ¦--COMMENT: # or [1/2] {312} + ¦ °--']': ] [3/0] {313} ¦--expr: x[ - [2/0] {312} - ¦ ¦--expr: x [0/0] {314} - ¦ ¦ °--SYMBOL: x [0/0] {313} - ¦ ¦--'[': [ [0/2] {315} - ¦ ¦--expr: a [2/0] {317} - ¦ ¦ °--SYMBOL: a [0/0] {316} - ¦ ¦--',': , [0/2] {318} - ¦ ¦--expr: b [1/0] {320} - ¦ ¦ °--SYMBOL: b [0/0] {319} - ¦ °--']': ] [1/0] {321} + [2/0] {314} + ¦ ¦--expr: x [0/0] {316} + ¦ ¦ °--SYMBOL: x [0/0] {315} + ¦ ¦--'[': [ [0/2] {317} + ¦ ¦--expr: a [2/0] {319} + ¦ ¦ °--SYMBOL: a [0/0] {318} + ¦ ¦--',': , [0/2] {320} + ¦ ¦--expr: b [1/0] {322} + ¦ ¦ °--SYMBOL: b [0/0] {321} + ¦ °--']': ] [1/0] {323} ¦--expr: x[ - [2/0] {322} - ¦ ¦--expr: x [0/0] {324} - ¦ ¦ °--SYMBOL: x [0/0] {323} - ¦ ¦--'[': [ [0/2] {325} - ¦ ¦--expr: a [1/0] {327} - ¦ ¦ °--SYMBOL: a [0/0] {326} - ¦ ¦--',': , [0/2] {328} - ¦ ¦--expr: b [1/0] {330} - ¦ ¦ °--SYMBOL: b [0/0] {329} - ¦ °--']': ] [2/0] {331} + [2/0] {324} + ¦ ¦--expr: x [0/0] {326} + ¦ ¦ °--SYMBOL: x [0/0] {325} + ¦ ¦--'[': [ [0/2] {327} + ¦ ¦--expr: a [1/0] {329} + ¦ ¦ °--SYMBOL: a [0/0] {328} + ¦ ¦--',': , [0/2] {330} + ¦ ¦--expr: b [1/0] {332} + ¦ ¦ °--SYMBOL: b [0/0] {331} + ¦ °--']': ] [2/0] {333} °--expr: x[ - [2/0] {332} - ¦--expr: x [0/0] {334} - ¦ °--SYMBOL: x [0/0] {333} - ¦--'[': [ [0/2] {335} - ¦--expr: a [2/0] {337} - ¦ °--SYMBOL: a [0/0] {336} - ¦--',': , [0/2] {338} - ¦--expr: b [1/0] {340} - ¦ °--SYMBOL: b [0/0] {339} - °--']': ] [2/0] {341} + [2/0] {334} + ¦--expr: x [0/0] {336} + ¦ °--SYMBOL: x [0/0] {335} + ¦--'[': [ [0/2] {337} + ¦--expr: a [2/0] {339} + ¦ °--SYMBOL: a [0/0] {338} + ¦--',': , [0/2] {340} + ¦--expr: b [1/0] {342} + ¦ °--SYMBOL: b [0/0] {341} + °--']': ] [2/0] {343} diff --git a/tests/testthat/indention_square_brackets/square_brackets_line_break-out.R b/tests/testthat/indention_square_brackets/square_brackets_line_break-out.R index 112c04b31..a6534d45a 100644 --- a/tests/testthat/indention_square_brackets/square_brackets_line_break-out.R +++ b/tests/testthat/indention_square_brackets/square_brackets_line_break-out.R @@ -54,8 +54,10 @@ x[a == 3 & b == v, ] x[ + # comments above a == 3 & b == v, + # or below shouldn't be an issue ] x[ diff --git a/tests/testthat/line_breaks_fun_call/blank-non-strict-out.R b/tests/testthat/line_breaks_fun_call/blank-non-strict-out.R index 21225f5f8..02330a9ec 100644 --- a/tests/testthat/line_breaks_fun_call/blank-non-strict-out.R +++ b/tests/testthat/line_breaks_fun_call/blank-non-strict-out.R @@ -1,6 +1,4 @@ call( - - 1 ) From 2df29fb5dd61011d8daa2c5d55521322d5ce2562 Mon Sep 17 00:00:00 2001 From: Indrajeet Patil Date: Sat, 11 May 2024 13:28:00 +0200 Subject: [PATCH 07/20] create new transformers for removing empty lines --- R/rules-line-breaks.R | 27 ++++++++++++++++++++++++- R/rules-spaces.R | 8 -------- R/style-guides.R | 4 +++- tests/testthat/test-transformers-drop.R | 4 +++- 4 files changed, 32 insertions(+), 11 deletions(-) diff --git a/R/rules-line-breaks.R b/R/rules-line-breaks.R index 5c6f3345b..e77792369 100644 --- a/R/rules-line-breaks.R +++ b/R/rules-line-breaks.R @@ -244,7 +244,7 @@ remove_line_breaks_in_fun_dec <- function(pd) { pd } -#' + add_line_break_after_pipe <- function(pd) { is_pipe <- pd$token %in% c("SPECIAL-PIPE", "PIPE") pd$lag_newlines[lag(is_pipe) & pd$lag_newlines > 1L] <- 1L @@ -417,3 +417,28 @@ set_line_break_after_ggplot2_plus <- function(pd) { } pd } + + +remove_empty_line_after_opening_braces <- function(pd) { + opening_braces <- c("'('", "'['", "LBB") + paren_after <- pd$token %in% opening_braces + if (!any(paren_after)) { + return(pd) + } + pd$lag_newlines[ + lag(pd$token %in% opening_braces) & pd$lag_newlines > 1L + ] <- 1L + pd +} + +remove_empty_line_before_closing_braces <- function(pd) { + closing_braces <- c("')'", "']'", "RBB") + paren_before <- pd$token %in% closing_braces + if (!any(paren_before)) { + return(pd) + } + pd$lag_newlines[ + pd$token %in% closing_braces & pd$lag_newlines > 1L + ] <- 1L + pd +} diff --git a/R/rules-spaces.R b/R/rules-spaces.R index 77ecd4878..b0857f337 100644 --- a/R/rules-spaces.R +++ b/R/rules-spaces.R @@ -146,10 +146,6 @@ remove_space_after_opening_paren <- function(pd_flat) { if (!any(paren_after)) { return(pd_flat) } - # remove blank lines after opening braces - pd_flat$lag_newlines[ - lag(pd_flat$token %in% braces) & pd_flat$lag_newlines > 1L - ] <- 1L pd_flat$spaces[paren_after & (pd_flat$newlines == 0L)] <- 0L pd_flat } @@ -160,10 +156,6 @@ remove_space_before_closing_paren <- function(pd_flat) { if (!any(paren_after)) { return(pd_flat) } - # remove blank lines before closing braces - pd_flat$lag_newlines[ - pd_flat$token %in% braces & pd_flat$lag_newlines > 1L - ] <- 1L paren_before <- lead(paren_after, default = FALSE) pd_flat$spaces[paren_before & (pd_flat$newlines == 0L)] <- 0L pd_flat diff --git a/R/style-guides.R b/R/style-guides.R index 735e6a1f5..815ad1cfe 100644 --- a/R/style-guides.R +++ b/R/style-guides.R @@ -166,7 +166,9 @@ tidyverse_style <- function(scope = "tokens", add_line_break_after_pipe = if (strict) add_line_break_after_pipe, set_line_break_after_ggplot2_plus = if (strict) { set_line_break_after_ggplot2_plus - } + }, + remove_empty_line_after_opening_braces = remove_empty_line_after_opening_braces, + remove_empty_line_before_closing_braces = remove_empty_line_before_closing_braces ) } diff --git a/tests/testthat/test-transformers-drop.R b/tests/testthat/test-transformers-drop.R index f3d5731fe..8f57790f0 100644 --- a/tests/testthat/test-transformers-drop.R +++ b/tests/testthat/test-transformers-drop.R @@ -76,7 +76,9 @@ test_that("tidyverse transformers are correctly dropped", { "set_line_break_after_opening_if_call_is_multi_line", "set_line_break_before_closing_call", "remove_line_break_in_fun_call", - "set_line_break_after_ggplot2_plus" + "set_line_break_after_ggplot2_plus", + "remove_empty_line_after_opening_braces", + "remove_empty_line_before_closing_braces" ) expect_setequal(names(t_fun$line_break), names_line_break) From e0e2ed4d6e8e4b06c6bded34876fe71882108a8a Mon Sep 17 00:00:00 2001 From: Indrajeet Patil Date: Sat, 11 May 2024 13:31:46 +0200 Subject: [PATCH 08/20] better naming --- R/rules-line-breaks.R | 4 ++-- R/rules-spaces.R | 11 ++++++----- R/style-guides.R | 4 ++-- tests/testthat/test-transformers-drop.R | 4 ++-- 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/R/rules-line-breaks.R b/R/rules-line-breaks.R index e77792369..6b0dcc34d 100644 --- a/R/rules-line-breaks.R +++ b/R/rules-line-breaks.R @@ -419,7 +419,7 @@ set_line_break_after_ggplot2_plus <- function(pd) { } -remove_empty_line_after_opening_braces <- function(pd) { +remove_empty_lines_after_opening_braces <- function(pd) { opening_braces <- c("'('", "'['", "LBB") paren_after <- pd$token %in% opening_braces if (!any(paren_after)) { @@ -431,7 +431,7 @@ remove_empty_line_after_opening_braces <- function(pd) { pd } -remove_empty_line_before_closing_braces <- function(pd) { +remove_empty_lines_before_closing_braces <- function(pd) { closing_braces <- c("')'", "']'", "RBB") paren_before <- pd$token %in% closing_braces if (!any(paren_before)) { diff --git a/R/rules-spaces.R b/R/rules-spaces.R index b0857f337..c96584d6c 100644 --- a/R/rules-spaces.R +++ b/R/rules-spaces.R @@ -131,7 +131,8 @@ remove_space_after_unary_pm_nested <- function(pd) { } remove_space_before_opening_paren <- function(pd_flat) { - paren_after <- pd_flat$token %in% c("'('", "'['", "LBB") + opening_braces <- c("'('", "'['", "LBB") + paren_after <- pd_flat$token %in% opening_braces if (!any(paren_after)) { return(pd_flat) } @@ -141,8 +142,8 @@ remove_space_before_opening_paren <- function(pd_flat) { } remove_space_after_opening_paren <- function(pd_flat) { - braces <- c("'('", "'['", "LBB") - paren_after <- pd_flat$token %in% braces + opening_braces <- c("'('", "'['", "LBB") + paren_after <- pd_flat$token %in% opening_braces if (!any(paren_after)) { return(pd_flat) } @@ -151,8 +152,8 @@ remove_space_after_opening_paren <- function(pd_flat) { } remove_space_before_closing_paren <- function(pd_flat) { - braces <- c("')'", "']'") - paren_after <- pd_flat$token %in% braces + closing_braces <- c("')'", "']'") + paren_after <- pd_flat$token %in% closing_braces if (!any(paren_after)) { return(pd_flat) } diff --git a/R/style-guides.R b/R/style-guides.R index 815ad1cfe..2b83ab0c2 100644 --- a/R/style-guides.R +++ b/R/style-guides.R @@ -167,8 +167,8 @@ tidyverse_style <- function(scope = "tokens", set_line_break_after_ggplot2_plus = if (strict) { set_line_break_after_ggplot2_plus }, - remove_empty_line_after_opening_braces = remove_empty_line_after_opening_braces, - remove_empty_line_before_closing_braces = remove_empty_line_before_closing_braces + remove_empty_lines_after_opening_braces = remove_empty_lines_after_opening_braces, + remove_empty_lines_before_closing_braces = remove_empty_lines_before_closing_braces ) } diff --git a/tests/testthat/test-transformers-drop.R b/tests/testthat/test-transformers-drop.R index 8f57790f0..e9709d260 100644 --- a/tests/testthat/test-transformers-drop.R +++ b/tests/testthat/test-transformers-drop.R @@ -77,8 +77,8 @@ test_that("tidyverse transformers are correctly dropped", { "set_line_break_before_closing_call", "remove_line_break_in_fun_call", "set_line_break_after_ggplot2_plus", - "remove_empty_line_after_opening_braces", - "remove_empty_line_before_closing_braces" + "remove_empty_lines_after_opening_braces", + "remove_empty_lines_before_closing_braces" ) expect_setequal(names(t_fun$line_break), names_line_break) From 226615d2bf9c2e7afeb4b74c116554d99349623a Mon Sep 17 00:00:00 2001 From: Indrajeet Patil Date: Sat, 11 May 2024 13:42:54 +0200 Subject: [PATCH 09/20] add tests with pipes --- .../base-pipe-line-breaks-in.R | 12 + .../base-pipe-line-breaks-in_tree | 929 +++++++++--------- .../base-pipe-line-breaks-out.R | 8 + .../testthat/line_breaks_and_other/comma-in.R | 11 + .../line_breaks_and_other/comma-in_tree | 117 ++- .../line_breaks_and_other/comma-out.R | 8 + 6 files changed, 586 insertions(+), 499 deletions(-) diff --git a/tests/testthat/line_breaks_and_other/base-pipe-line-breaks-in.R b/tests/testthat/line_breaks_and_other/base-pipe-line-breaks-in.R index 880f22cf0..641e72d52 100644 --- a/tests/testthat/line_breaks_and_other/base-pipe-line-breaks-in.R +++ b/tests/testthat/line_breaks_and_other/base-pipe-line-breaks-in.R @@ -82,6 +82,18 @@ blew(y = 2, x |> {a |> c() +1} +{ + + ( + + # some comment + + a |> c() + 1 + + ) + +} + b |> f() |> # never move comment to next line as it can be styler: off or nolint k() |> diff --git a/tests/testthat/line_breaks_and_other/base-pipe-line-breaks-in_tree b/tests/testthat/line_breaks_and_other/base-pipe-line-breaks-in_tree index c685ecc97..f70d57412 100644 --- a/tests/testthat/line_breaks_and_other/base-pipe-line-breaks-in_tree +++ b/tests/testthat/line_breaks_and_other/base-pipe-line-breaks-in_tree @@ -1,465 +1,488 @@ -ROOT (token: short_text [lag_newlines/spaces] {pos_id}) - ¦--expr: c(a | [0/0] {1} - ¦ ¦--expr: c [0/0] {3} - ¦ ¦ °--SYMBOL_FUNCTION_CALL: c [0/0] {2} - ¦ ¦--'(': ( [0/0] {4} - ¦ ¦--expr: a |> [0/0] {5} - ¦ ¦ ¦--expr: a [0/1] {7} - ¦ ¦ ¦ °--SYMBOL: a [0/0] {6} - ¦ ¦ ¦--PIPE: |> [0/1] {8} - ¦ ¦ °--expr: b() [0/0] {9} - ¦ ¦ ¦--expr: b [0/0] {11} - ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: b [0/0] {10} - ¦ ¦ ¦--'(': ( [0/0] {12} - ¦ ¦ °--')': ) [0/0] {13} - ¦ °--')': ) [0/0] {14} - ¦--expr: c(a + [2/0] {15} - ¦ ¦--expr: c [0/0] {17} - ¦ ¦ °--SYMBOL_FUNCTION_CALL: c [0/0] {16} - ¦ ¦--'(': ( [0/0] {18} - ¦ ¦--expr: a + b [0/0] {19} - ¦ ¦ ¦--expr: a [0/1] {21} - ¦ ¦ ¦ °--SYMBOL: a [0/0] {20} - ¦ ¦ ¦--'+': + [0/1] {22} - ¦ ¦ ¦--expr: b [0/1] {25} - ¦ ¦ ¦ °--SYMBOL: b [0/0] {24} - ¦ ¦ ¦--PIPE: |> [0/1] {26} - ¦ ¦ °--expr: c() [0/0] {27} - ¦ ¦ ¦--expr: c [0/0] {29} - ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: c [0/0] {28} - ¦ ¦ ¦--'(': ( [0/0] {30} - ¦ ¦ °--')': ) [0/0] {31} - ¦ °--')': ) [0/0] {32} - ¦--expr: c(a | [3/0] {33} - ¦ ¦--expr: c [0/0] {35} - ¦ ¦ °--SYMBOL_FUNCTION_CALL: c [0/0] {34} - ¦ ¦--'(': ( [0/0] {36} - ¦ ¦--expr: a |> [0/0] {37} - ¦ ¦ ¦--expr: a [0/1] {39} - ¦ ¦ ¦ °--SYMBOL: a [0/0] {38} - ¦ ¦ ¦--PIPE: |> [0/1] {40} - ¦ ¦ °--expr: b() [0/0] {41} - ¦ ¦ ¦--expr: b [0/0] {43} - ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: b [0/0] {42} - ¦ ¦ ¦--'(': ( [0/0] {44} - ¦ ¦ °--')': ) [0/0] {45} - ¦ °--')': ) [1/0] {46} - ¦--expr: c(a | [2/0] {47} - ¦ ¦--expr: c [0/0] {49} - ¦ ¦ °--SYMBOL_FUNCTION_CALL: c [0/0] {48} - ¦ ¦--'(': ( [0/0] {50} - ¦ ¦--expr: a |> [0/1] {51} - ¦ ¦ ¦--expr: a [0/1] {53} - ¦ ¦ ¦ °--SYMBOL: a [0/0] {52} - ¦ ¦ ¦--PIPE: |> [0/1] {54} - ¦ ¦ °--expr: b() [0/0] {55} - ¦ ¦ ¦--expr: b [0/0] {57} - ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: b [0/0] {56} - ¦ ¦ ¦--'(': ( [0/0] {58} - ¦ ¦ °--')': ) [0/0] {59} - ¦ ¦--COMMENT: # 33 [0/0] {60} - ¦ °--')': ) [1/0] {61} +ROOT (token: short_text [lag_newlines/spaces] {pos_id}) + ¦--expr: c(a | [0/0] {1} + ¦ ¦--expr: c [0/0] {3} + ¦ ¦ °--SYMBOL_FUNCTION_CALL: c [0/0] {2} + ¦ ¦--'(': ( [0/0] {4} + ¦ ¦--expr: a |> [0/0] {5} + ¦ ¦ ¦--expr: a [0/1] {7} + ¦ ¦ ¦ °--SYMBOL: a [0/0] {6} + ¦ ¦ ¦--PIPE: |> [0/1] {8} + ¦ ¦ °--expr: b() [0/0] {9} + ¦ ¦ ¦--expr: b [0/0] {11} + ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: b [0/0] {10} + ¦ ¦ ¦--'(': ( [0/0] {12} + ¦ ¦ °--')': ) [0/0] {13} + ¦ °--')': ) [0/0] {14} + ¦--expr: c(a + [2/0] {15} + ¦ ¦--expr: c [0/0] {17} + ¦ ¦ °--SYMBOL_FUNCTION_CALL: c [0/0] {16} + ¦ ¦--'(': ( [0/0] {18} + ¦ ¦--expr: a + b [0/0] {19} + ¦ ¦ ¦--expr: a [0/1] {21} + ¦ ¦ ¦ °--SYMBOL: a [0/0] {20} + ¦ ¦ ¦--'+': + [0/1] {22} + ¦ ¦ ¦--expr: b [0/1] {25} + ¦ ¦ ¦ °--SYMBOL: b [0/0] {24} + ¦ ¦ ¦--PIPE: |> [0/1] {26} + ¦ ¦ °--expr: c() [0/0] {27} + ¦ ¦ ¦--expr: c [0/0] {29} + ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: c [0/0] {28} + ¦ ¦ ¦--'(': ( [0/0] {30} + ¦ ¦ °--')': ) [0/0] {31} + ¦ °--')': ) [0/0] {32} + ¦--expr: c(a | [3/0] {33} + ¦ ¦--expr: c [0/0] {35} + ¦ ¦ °--SYMBOL_FUNCTION_CALL: c [0/0] {34} + ¦ ¦--'(': ( [0/0] {36} + ¦ ¦--expr: a |> [0/0] {37} + ¦ ¦ ¦--expr: a [0/1] {39} + ¦ ¦ ¦ °--SYMBOL: a [0/0] {38} + ¦ ¦ ¦--PIPE: |> [0/1] {40} + ¦ ¦ °--expr: b() [0/0] {41} + ¦ ¦ ¦--expr: b [0/0] {43} + ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: b [0/0] {42} + ¦ ¦ ¦--'(': ( [0/0] {44} + ¦ ¦ °--')': ) [0/0] {45} + ¦ °--')': ) [1/0] {46} + ¦--expr: c(a | [2/0] {47} + ¦ ¦--expr: c [0/0] {49} + ¦ ¦ °--SYMBOL_FUNCTION_CALL: c [0/0] {48} + ¦ ¦--'(': ( [0/0] {50} + ¦ ¦--expr: a |> [0/1] {51} + ¦ ¦ ¦--expr: a [0/1] {53} + ¦ ¦ ¦ °--SYMBOL: a [0/0] {52} + ¦ ¦ ¦--PIPE: |> [0/1] {54} + ¦ ¦ °--expr: b() [0/0] {55} + ¦ ¦ ¦--expr: b [0/0] {57} + ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: b [0/0] {56} + ¦ ¦ ¦--'(': ( [0/0] {58} + ¦ ¦ °--')': ) [0/0] {59} + ¦ ¦--COMMENT: # 33 [0/0] {60} + ¦ °--')': ) [1/0] {61} ¦--expr: c( - [2/0] {62} - ¦ ¦--expr: c [0/0] {64} - ¦ ¦ °--SYMBOL_FUNCTION_CALL: c [0/0] {63} - ¦ ¦--'(': ( [0/2] {65} - ¦ ¦--expr: a + b [1/2] {66} - ¦ ¦ ¦--expr: a [0/1] {68} - ¦ ¦ ¦ °--SYMBOL: a [0/0] {67} - ¦ ¦ ¦--'+': + [0/1] {69} - ¦ ¦ ¦--expr: b [0/1] {72} - ¦ ¦ ¦ °--SYMBOL: b [0/0] {71} - ¦ ¦ ¦--PIPE: |> [0/1] {73} - ¦ ¦ °--expr: c() [0/0] {74} - ¦ ¦ ¦--expr: c [0/0] {76} - ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: c [0/0] {75} - ¦ ¦ ¦--'(': ( [0/0] {77} - ¦ ¦ °--')': ) [0/0] {78} - ¦ °--')': ) [1/0] {79} + [2/0] {62} + ¦ ¦--expr: c [0/0] {64} + ¦ ¦ °--SYMBOL_FUNCTION_CALL: c [0/0] {63} + ¦ ¦--'(': ( [0/2] {65} + ¦ ¦--expr: a + b [1/2] {66} + ¦ ¦ ¦--expr: a [0/1] {68} + ¦ ¦ ¦ °--SYMBOL: a [0/0] {67} + ¦ ¦ ¦--'+': + [0/1] {69} + ¦ ¦ ¦--expr: b [0/1] {72} + ¦ ¦ ¦ °--SYMBOL: b [0/0] {71} + ¦ ¦ ¦--PIPE: |> [0/1] {73} + ¦ ¦ °--expr: c() [0/0] {74} + ¦ ¦ ¦--expr: c [0/0] {76} + ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: c [0/0] {75} + ¦ ¦ ¦--'(': ( [0/0] {77} + ¦ ¦ °--')': ) [0/0] {78} + ¦ °--')': ) [1/0] {79} ¦--expr: c( - [2/0] {80} - ¦ ¦--expr: c [0/0] {82} - ¦ ¦ °--SYMBOL_FUNCTION_CALL: c [0/0] {81} - ¦ ¦--'(': ( [0/2] {83} - ¦ ¦--expr: a + b [1/0] {84} - ¦ ¦ ¦--expr: a [0/1] {86} - ¦ ¦ ¦ °--SYMBOL: a [0/0] {85} - ¦ ¦ ¦--'+': + [0/1] {87} - ¦ ¦ ¦--expr: b [0/1] {90} - ¦ ¦ ¦ °--SYMBOL: b [0/0] {89} - ¦ ¦ ¦--PIPE: |> [0/4] {91} - ¦ ¦ °--expr: c() [1/0] {92} - ¦ ¦ ¦--expr: c [0/0] {94} - ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: c [0/0] {93} - ¦ ¦ ¦--'(': ( [0/0] {95} - ¦ ¦ °--')': ) [0/0] {96} - ¦ °--')': ) [0/0] {97} - ¦--expr: c(a + [2/0] {98} - ¦ ¦--expr: c [0/0] {100} - ¦ ¦ °--SYMBOL_FUNCTION_CALL: c [0/0] {99} - ¦ ¦--'(': ( [0/0] {101} - ¦ ¦--expr: a + b [0/0] {102} - ¦ ¦ ¦--expr: a [0/1] {104} - ¦ ¦ ¦ °--SYMBOL: a [0/0] {103} - ¦ ¦ ¦--'+': + [0/1] {105} - ¦ ¦ ¦--expr: b [0/1] {108} - ¦ ¦ ¦ °--SYMBOL: b [0/0] {107} - ¦ ¦ ¦--PIPE: |> [0/4] {109} - ¦ ¦ °--expr: c() [1/0] {110} - ¦ ¦ ¦--expr: c [0/0] {112} - ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: c [0/0] {111} - ¦ ¦ ¦--'(': ( [0/0] {113} - ¦ ¦ °--')': ) [0/0] {114} - ¦ °--')': ) [1/0] {115} + [2/0] {80} + ¦ ¦--expr: c [0/0] {82} + ¦ ¦ °--SYMBOL_FUNCTION_CALL: c [0/0] {81} + ¦ ¦--'(': ( [0/2] {83} + ¦ ¦--expr: a + b [1/0] {84} + ¦ ¦ ¦--expr: a [0/1] {86} + ¦ ¦ ¦ °--SYMBOL: a [0/0] {85} + ¦ ¦ ¦--'+': + [0/1] {87} + ¦ ¦ ¦--expr: b [0/1] {90} + ¦ ¦ ¦ °--SYMBOL: b [0/0] {89} + ¦ ¦ ¦--PIPE: |> [0/4] {91} + ¦ ¦ °--expr: c() [1/0] {92} + ¦ ¦ ¦--expr: c [0/0] {94} + ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: c [0/0] {93} + ¦ ¦ ¦--'(': ( [0/0] {95} + ¦ ¦ °--')': ) [0/0] {96} + ¦ °--')': ) [0/0] {97} + ¦--expr: c(a + [2/0] {98} + ¦ ¦--expr: c [0/0] {100} + ¦ ¦ °--SYMBOL_FUNCTION_CALL: c [0/0] {99} + ¦ ¦--'(': ( [0/0] {101} + ¦ ¦--expr: a + b [0/0] {102} + ¦ ¦ ¦--expr: a [0/1] {104} + ¦ ¦ ¦ °--SYMBOL: a [0/0] {103} + ¦ ¦ ¦--'+': + [0/1] {105} + ¦ ¦ ¦--expr: b [0/1] {108} + ¦ ¦ ¦ °--SYMBOL: b [0/0] {107} + ¦ ¦ ¦--PIPE: |> [0/4] {109} + ¦ ¦ °--expr: c() [1/0] {110} + ¦ ¦ ¦--expr: c [0/0] {112} + ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: c [0/0] {111} + ¦ ¦ ¦--'(': ( [0/0] {113} + ¦ ¦ °--')': ) [0/0] {114} + ¦ °--')': ) [1/0] {115} ¦--expr: c( - [2/0] {116} - ¦ ¦--expr: c [0/0] {118} - ¦ ¦ °--SYMBOL_FUNCTION_CALL: c [0/0] {117} - ¦ ¦--'(': ( [0/2] {119} - ¦ ¦--expr: a + b [1/0] {120} - ¦ ¦ ¦--expr: a [0/1] {122} - ¦ ¦ ¦ °--SYMBOL: a [0/0] {121} - ¦ ¦ ¦--'+': + [0/1] {123} - ¦ ¦ ¦--expr: b [0/1] {126} - ¦ ¦ ¦ °--SYMBOL: b [0/0] {125} - ¦ ¦ ¦--PIPE: |> [0/1] {127} - ¦ ¦ ¦--COMMENT: # 654 [0/4] {128} - ¦ ¦ °--expr: c() [1/0] {129} - ¦ ¦ ¦--expr: c [0/0] {131} - ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: c [0/0] {130} - ¦ ¦ ¦--'(': ( [0/0] {132} - ¦ ¦ °--')': ) [0/0] {133} - ¦ °--')': ) [1/0] {134} - ¦--expr: c( # [2/0] {135} - ¦ ¦--expr: c [0/0] {137} - ¦ ¦ °--SYMBOL_FUNCTION_CALL: c [0/0] {136} - ¦ ¦--'(': ( [0/1] {138} - ¦ ¦--COMMENT: # rr [0/2] {139} - ¦ ¦--expr: a + b [1/0] {140} - ¦ ¦ ¦--expr: a [0/1] {142} - ¦ ¦ ¦ °--SYMBOL: a [0/0] {141} - ¦ ¦ ¦--'+': + [0/1] {143} - ¦ ¦ ¦--expr: b [0/1] {146} - ¦ ¦ ¦ °--SYMBOL: b [0/0] {145} - ¦ ¦ ¦--PIPE: |> [0/4] {147} - ¦ ¦ °--expr: c() [1/0] {148} - ¦ ¦ ¦--expr: c [0/0] {150} - ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: c [0/0] {149} - ¦ ¦ ¦--'(': ( [0/0] {151} - ¦ ¦ °--')': ) [0/0] {152} - ¦ °--')': ) [1/0] {153} + [2/0] {116} + ¦ ¦--expr: c [0/0] {118} + ¦ ¦ °--SYMBOL_FUNCTION_CALL: c [0/0] {117} + ¦ ¦--'(': ( [0/2] {119} + ¦ ¦--expr: a + b [1/0] {120} + ¦ ¦ ¦--expr: a [0/1] {122} + ¦ ¦ ¦ °--SYMBOL: a [0/0] {121} + ¦ ¦ ¦--'+': + [0/1] {123} + ¦ ¦ ¦--expr: b [0/1] {126} + ¦ ¦ ¦ °--SYMBOL: b [0/0] {125} + ¦ ¦ ¦--PIPE: |> [0/1] {127} + ¦ ¦ ¦--COMMENT: # 654 [0/4] {128} + ¦ ¦ °--expr: c() [1/0] {129} + ¦ ¦ ¦--expr: c [0/0] {131} + ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: c [0/0] {130} + ¦ ¦ ¦--'(': ( [0/0] {132} + ¦ ¦ °--')': ) [0/0] {133} + ¦ °--')': ) [1/0] {134} + ¦--expr: c( # [2/0] {135} + ¦ ¦--expr: c [0/0] {137} + ¦ ¦ °--SYMBOL_FUNCTION_CALL: c [0/0] {136} + ¦ ¦--'(': ( [0/1] {138} + ¦ ¦--COMMENT: # rr [0/2] {139} + ¦ ¦--expr: a + b [1/0] {140} + ¦ ¦ ¦--expr: a [0/1] {142} + ¦ ¦ ¦ °--SYMBOL: a [0/0] {141} + ¦ ¦ ¦--'+': + [0/1] {143} + ¦ ¦ ¦--expr: b [0/1] {146} + ¦ ¦ ¦ °--SYMBOL: b [0/0] {145} + ¦ ¦ ¦--PIPE: |> [0/4] {147} + ¦ ¦ °--expr: c() [1/0] {148} + ¦ ¦ ¦--expr: c [0/0] {150} + ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: c [0/0] {149} + ¦ ¦ ¦--'(': ( [0/0] {151} + ¦ ¦ °--')': ) [0/0] {152} + ¦ °--')': ) [1/0] {153} ¦--expr: c( - [2/0] {154} - ¦ ¦--expr: c [0/0] {156} - ¦ ¦ °--SYMBOL_FUNCTION_CALL: c [0/0] {155} - ¦ ¦--'(': ( [0/2] {157} + [2/0] {154} + ¦ ¦--expr: c [0/0] {156} + ¦ ¦ °--SYMBOL_FUNCTION_CALL: c [0/0] {155} + ¦ ¦--'(': ( [0/2] {157} ¦ ¦--expr: a + - [1/0] {158} - ¦ ¦ ¦--expr: a [0/1] {160} - ¦ ¦ ¦ °--SYMBOL: a [0/0] {159} - ¦ ¦ ¦--'+': + [0/4] {161} - ¦ ¦ ¦--expr: b [1/1] {164} - ¦ ¦ ¦ °--SYMBOL: b [0/0] {163} - ¦ ¦ ¦--PIPE: |> [0/1] {165} - ¦ ¦ °--expr: c() [0/0] {166} - ¦ ¦ ¦--expr: c [0/0] {168} - ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: c [0/0] {167} - ¦ ¦ ¦--'(': ( [0/0] {169} - ¦ ¦ °--')': ) [0/0] {170} - ¦ °--')': ) [1/0] {171} - ¦--expr: c(a + [2/0] {172} - ¦ ¦--expr: c [0/0] {174} - ¦ ¦ °--SYMBOL_FUNCTION_CALL: c [0/0] {173} - ¦ ¦--'(': ( [0/0] {175} + [1/0] {158} + ¦ ¦ ¦--expr: a [0/1] {160} + ¦ ¦ ¦ °--SYMBOL: a [0/0] {159} + ¦ ¦ ¦--'+': + [0/4] {161} + ¦ ¦ ¦--expr: b [1/1] {164} + ¦ ¦ ¦ °--SYMBOL: b [0/0] {163} + ¦ ¦ ¦--PIPE: |> [0/1] {165} + ¦ ¦ °--expr: c() [0/0] {166} + ¦ ¦ ¦--expr: c [0/0] {168} + ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: c [0/0] {167} + ¦ ¦ ¦--'(': ( [0/0] {169} + ¦ ¦ °--')': ) [0/0] {170} + ¦ °--')': ) [1/0] {171} + ¦--expr: c(a + [2/0] {172} + ¦ ¦--expr: c [0/0] {174} + ¦ ¦ °--SYMBOL_FUNCTION_CALL: c [0/0] {173} + ¦ ¦--'(': ( [0/0] {175} ¦ ¦--expr: a + - [0/0] {176} - ¦ ¦ ¦--expr: a [0/1] {178} - ¦ ¦ ¦ °--SYMBOL: a [0/0] {177} - ¦ ¦ ¦--'+': + [0/4] {179} - ¦ ¦ ¦--expr: b [1/1] {182} - ¦ ¦ ¦ °--SYMBOL: b [0/0] {181} - ¦ ¦ ¦--PIPE: |> [0/1] {183} - ¦ ¦ °--expr: c() [0/0] {184} - ¦ ¦ ¦--expr: c [0/0] {186} - ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: c [0/0] {185} - ¦ ¦ ¦--'(': ( [0/0] {187} - ¦ ¦ °--')': ) [0/0] {188} - ¦ °--')': ) [1/0] {189} - ¦--expr: a |> [2/0] {190} - ¦ ¦--expr: a [0/1] {192} - ¦ ¦ °--SYMBOL: a [0/0] {191} - ¦ ¦--PIPE: |> [0/1] {193} + [0/0] {176} + ¦ ¦ ¦--expr: a [0/1] {178} + ¦ ¦ ¦ °--SYMBOL: a [0/0] {177} + ¦ ¦ ¦--'+': + [0/4] {179} + ¦ ¦ ¦--expr: b [1/1] {182} + ¦ ¦ ¦ °--SYMBOL: b [0/0] {181} + ¦ ¦ ¦--PIPE: |> [0/1] {183} + ¦ ¦ °--expr: c() [0/0] {184} + ¦ ¦ ¦--expr: c [0/0] {186} + ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: c [0/0] {185} + ¦ ¦ ¦--'(': ( [0/0] {187} + ¦ ¦ °--')': ) [0/0] {188} + ¦ °--')': ) [1/0] {189} + ¦--expr: a |> [2/0] {190} + ¦ ¦--expr: a [0/1] {192} + ¦ ¦ °--SYMBOL: a [0/0] {191} + ¦ ¦--PIPE: |> [0/1] {193} ¦ °--expr: b( -) [0/0] {194} - ¦ ¦--expr: b [0/0] {196} - ¦ ¦ °--SYMBOL_FUNCTION_CALL: b [0/0] {195} - ¦ ¦--'(': ( [0/0] {197} - ¦ °--')': ) [1/0] {198} - ¦--expr: a |> [2/0] {199} - ¦ ¦--expr: a [0/1] {202} - ¦ ¦ °--SYMBOL: a [0/0] {201} - ¦ ¦--PIPE: |> [0/1] {203} +) [0/0] {194} + ¦ ¦--expr: b [0/0] {196} + ¦ ¦ °--SYMBOL_FUNCTION_CALL: b [0/0] {195} + ¦ ¦--'(': ( [0/0] {197} + ¦ °--')': ) [1/0] {198} + ¦--expr: a |> [2/0] {199} + ¦ ¦--expr: a [0/1] {202} + ¦ ¦ °--SYMBOL: a [0/0] {201} + ¦ ¦--PIPE: |> [0/1] {203} ¦ ¦--expr: b( -) [0/1] {204} - ¦ ¦ ¦--expr: b [0/0] {206} - ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: b [0/0] {205} - ¦ ¦ ¦--'(': ( [0/0] {207} - ¦ ¦ °--')': ) [1/0] {208} - ¦ ¦--PIPE: |> [0/1] {209} - ¦ °--expr: q() [0/0] {210} - ¦ ¦--expr: q [0/0] {212} - ¦ ¦ °--SYMBOL_FUNCTION_CALL: q [0/0] {211} - ¦ ¦--'(': ( [0/0] {213} - ¦ °--')': ) [0/0] {214} +) [0/1] {204} + ¦ ¦ ¦--expr: b [0/0] {206} + ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: b [0/0] {205} + ¦ ¦ ¦--'(': ( [0/0] {207} + ¦ ¦ °--')': ) [1/0] {208} + ¦ ¦--PIPE: |> [0/1] {209} + ¦ °--expr: q() [0/0] {210} + ¦ ¦--expr: q [0/0] {212} + ¦ ¦ °--SYMBOL_FUNCTION_CALL: q [0/0] {211} + ¦ ¦--'(': ( [0/0] {213} + ¦ °--')': ) [0/0] {214} ¦--expr: a |> - [2/0] {215} - ¦ ¦--expr: a [0/1] {217} - ¦ ¦ °--SYMBOL: a [0/0] {216} - ¦ ¦--PIPE: |> [0/2] {218} - ¦ °--expr: b() [1/0] {219} - ¦ ¦--expr: b [0/0] {221} - ¦ ¦ °--SYMBOL_FUNCTION_CALL: b [0/0] {220} - ¦ ¦--'(': ( [0/0] {222} - ¦ °--')': ) [0/0] {223} - ¦--expr: a |> [2/0] {224} - ¦ ¦--expr: a [0/1] {227} - ¦ ¦ °--SYMBOL: a [0/0] {226} - ¦ ¦--PIPE: |> [0/1] {228} - ¦ ¦--expr: b() [0/1] {229} - ¦ ¦ ¦--expr: b [0/0] {231} - ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: b [0/0] {230} - ¦ ¦ ¦--'(': ( [0/0] {232} - ¦ ¦ °--')': ) [0/0] {233} - ¦ ¦--PIPE: |> [0/1] {234} - ¦ °--expr: c() [0/0] {235} - ¦ ¦--expr: c [0/0] {237} - ¦ ¦ °--SYMBOL_FUNCTION_CALL: c [0/0] {236} - ¦ ¦--'(': ( [0/0] {238} - ¦ °--')': ) [0/0] {239} - ¦--COMMENT: # sho [2/0] {240} - ¦--expr: a |> [1/0] {241} - ¦ ¦--expr: a [0/1] {243} - ¦ ¦ °--SYMBOL: a [0/0] {242} - ¦ ¦--PIPE: |> [0/1] {244} - ¦ °--expr: b() [0/0] {245} - ¦ ¦--expr: b [0/0] {247} - ¦ ¦ °--SYMBOL_FUNCTION_CALL: b [0/0] {246} - ¦ ¦--'(': ( [0/0] {248} - ¦ °--')': ) [0/0] {249} - ¦--expr: fun(x [2/0] {250} - ¦ ¦--expr: fun [0/0] {252} - ¦ ¦ °--SYMBOL_FUNCTION_CALL: fun [0/0] {251} - ¦ ¦--'(': ( [0/0] {253} - ¦ ¦--expr: x [0/0] {255} - ¦ ¦ °--SYMBOL: x [0/0] {254} - ¦ ¦--',': , [0/2] {256} - ¦ ¦--expr: a |> [1/0] {257} - ¦ ¦ ¦--expr: a [0/1] {259} - ¦ ¦ ¦ °--SYMBOL: a [0/0] {258} - ¦ ¦ ¦--PIPE: |> [0/1] {260} - ¦ ¦ °--expr: b() [0/0] {261} - ¦ ¦ ¦--expr: b [0/0] {263} - ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: b [0/0] {262} - ¦ ¦ ¦--'(': ( [0/0] {264} - ¦ ¦ °--')': ) [0/0] {265} - ¦ °--')': ) [0/0] {266} - ¦--expr: fun(x [2/0] {267} - ¦ ¦--expr: fun [0/0] {269} - ¦ ¦ °--SYMBOL_FUNCTION_CALL: fun [0/0] {268} - ¦ ¦--'(': ( [0/0] {270} - ¦ ¦--expr: x [0/0] {272} - ¦ ¦ °--SYMBOL: x [0/0] {271} - ¦ ¦--',': , [0/4] {273} - ¦ ¦--SYMBOL_SUB: gg [1/1] {274} - ¦ ¦--EQ_SUB: = [0/1] {275} - ¦ ¦--expr: a |> [0/0] {276} - ¦ ¦ ¦--expr: a [0/1] {278} - ¦ ¦ ¦ °--SYMBOL: a [0/0] {277} - ¦ ¦ ¦--PIPE: |> [0/1] {279} - ¦ ¦ °--expr: b() [0/0] {280} - ¦ ¦ ¦--expr: b [0/0] {282} - ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: b [0/0] {281} - ¦ ¦ ¦--'(': ( [0/0] {283} - ¦ ¦ °--')': ) [0/0] {284} - ¦ ¦--',': , [0/4] {285} - ¦ ¦--expr: tt |> [1/0] {286} - ¦ ¦ ¦--expr: tt [0/1] {288} - ¦ ¦ ¦ °--SYMBOL: tt [0/0] {287} - ¦ ¦ ¦--PIPE: |> [0/1] {289} - ¦ ¦ °--expr: q() [0/0] {290} - ¦ ¦ ¦--expr: q [0/0] {292} - ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: q [0/0] {291} - ¦ ¦ ¦--'(': ( [0/0] {293} - ¦ ¦ °--')': ) [0/0] {294} - ¦ °--')': ) [0/0] {295} - ¦--expr: fun(x [2/0] {296} - ¦ ¦--expr: fun [0/0] {298} - ¦ ¦ °--SYMBOL_FUNCTION_CALL: fun [0/0] {297} - ¦ ¦--'(': ( [0/0] {299} - ¦ ¦--expr: x [0/0] {301} - ¦ ¦ °--SYMBOL: x [0/0] {300} - ¦ ¦--',': , [0/1] {302} - ¦ ¦--SYMBOL_SUB: gg [0/1] {303} - ¦ ¦--EQ_SUB: = [0/1] {304} - ¦ ¦--expr: a |> [0/0] {305} - ¦ ¦ ¦--expr: a [0/1] {307} - ¦ ¦ ¦ °--SYMBOL: a [0/0] {306} - ¦ ¦ ¦--PIPE: |> [0/1] {308} - ¦ ¦ °--expr: b() [0/0] {309} - ¦ ¦ ¦--expr: b [0/0] {311} - ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: b [0/0] {310} - ¦ ¦ ¦--'(': ( [0/0] {312} - ¦ ¦ °--')': ) [0/0] {313} - ¦ ¦--',': , [0/1] {314} - ¦ ¦--expr: tt |> [0/0] {315} - ¦ ¦ ¦--expr: tt [0/1] {317} - ¦ ¦ ¦ °--SYMBOL: tt [0/0] {316} - ¦ ¦ ¦--PIPE: |> [0/1] {318} - ¦ ¦ °--expr: q() [0/0] {319} - ¦ ¦ ¦--expr: q [0/0] {321} - ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: q [0/0] {320} - ¦ ¦ ¦--'(': ( [0/0] {322} - ¦ ¦ °--')': ) [0/0] {323} - ¦ °--')': ) [0/0] {324} - ¦--expr_or_assign_or_help: z = a [2/0] {325} - ¦ ¦--expr: z [0/1] {327} - ¦ ¦ °--SYMBOL: z [0/0] {326} - ¦ ¦--EQ_ASSIGN: = [0/1] {328} - ¦ ¦--expr: a [0/1] {331} - ¦ ¦ °--SYMBOL: a [0/0] {330} - ¦ ¦--PIPE: |> [0/1] {332} - ¦ °--expr: b() [0/0] {333} - ¦ ¦--expr: b [0/0] {335} - ¦ ¦ °--SYMBOL_FUNCTION_CALL: b [0/0] {334} - ¦ ¦--'(': ( [0/0] {336} - ¦ °--')': ) [0/0] {337} - ¦--expr: fun( [2/0] {338} - ¦ ¦--expr: fun [0/0] {340} - ¦ ¦ °--SYMBOL_FUNCTION_CALL: fun [0/0] {339} - ¦ ¦--'(': ( [0/1] {341} - ¦ ¦--SYMBOL_SUB: s [0/1] {342} - ¦ ¦--EQ_SUB: = [0/1] {343} - ¦ ¦--expr: g(x) [0/0] {344} - ¦ ¦ ¦--expr: g [0/0] {346} - ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: g [0/0] {345} - ¦ ¦ ¦--'(': ( [0/0] {347} - ¦ ¦ ¦--expr: x [0/0] {349} - ¦ ¦ ¦ °--SYMBOL: x [0/0] {348} - ¦ ¦ °--')': ) [0/0] {350} - ¦ ¦--',': , [0/4] {351} - ¦ ¦--SYMBOL_SUB: gg [1/1] {352} - ¦ ¦--EQ_SUB: = [0/1] {353} - ¦ ¦--expr: a(n = [0/0] {354} - ¦ ¦ ¦--expr: a(n = [0/1] {355} - ¦ ¦ ¦ ¦--expr: a [0/0] {357} - ¦ ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: a [0/0] {356} - ¦ ¦ ¦ ¦--'(': ( [0/0] {358} - ¦ ¦ ¦ ¦--expr: n == [0/0] {359} - ¦ ¦ ¦ ¦ ¦--expr: n [0/1] {361} - ¦ ¦ ¦ ¦ ¦ °--SYMBOL: n [0/0] {360} - ¦ ¦ ¦ ¦ ¦--EQ: == [0/1] {362} - ¦ ¦ ¦ ¦ °--expr: 2 [0/0] {364} - ¦ ¦ ¦ ¦ °--NUM_CONST: 2 [0/0] {363} - ¦ ¦ ¦ °--')': ) [0/0] {365} - ¦ ¦ ¦--PIPE: |> [0/1] {366} - ¦ ¦ °--expr: b() [0/0] {367} - ¦ ¦ ¦--expr: b [0/0] {369} - ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: b [0/0] {368} - ¦ ¦ ¦--'(': ( [0/0] {370} - ¦ ¦ °--')': ) [0/0] {371} - ¦ ¦--',': , [0/4] {372} - ¦ ¦--expr: tt |> [1/0] {373} - ¦ ¦ ¦--expr: tt [0/1] {375} - ¦ ¦ ¦ °--SYMBOL: tt [0/0] {374} - ¦ ¦ ¦--PIPE: |> [0/1] {376} - ¦ ¦ °--expr: q(r = [0/0] {377} - ¦ ¦ ¦--expr: q [0/0] {379} - ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: q [0/0] {378} - ¦ ¦ ¦--'(': ( [0/0] {380} - ¦ ¦ ¦--SYMBOL_SUB: r [0/1] {381} - ¦ ¦ ¦--EQ_SUB: = [0/1] {382} - ¦ ¦ ¦--expr: 3 [0/0] {384} - ¦ ¦ ¦ °--NUM_CONST: 3 [0/0] {383} - ¦ ¦ °--')': ) [0/0] {385} - ¦ °--')': ) [0/0] {386} - ¦--COMMENT: # FIX [2/0] {387} - ¦--expr: blew( [1/0] {388} - ¦ ¦--expr: blew [0/0] {390} - ¦ ¦ °--SYMBOL_FUNCTION_CALL: blew [0/0] {389} - ¦ ¦--'(': ( [0/0] {391} + [2/0] {215} + ¦ ¦--expr: a [0/1] {217} + ¦ ¦ °--SYMBOL: a [0/0] {216} + ¦ ¦--PIPE: |> [0/2] {218} + ¦ °--expr: b() [1/0] {219} + ¦ ¦--expr: b [0/0] {221} + ¦ ¦ °--SYMBOL_FUNCTION_CALL: b [0/0] {220} + ¦ ¦--'(': ( [0/0] {222} + ¦ °--')': ) [0/0] {223} + ¦--expr: a |> [2/0] {224} + ¦ ¦--expr: a [0/1] {227} + ¦ ¦ °--SYMBOL: a [0/0] {226} + ¦ ¦--PIPE: |> [0/1] {228} + ¦ ¦--expr: b() [0/1] {229} + ¦ ¦ ¦--expr: b [0/0] {231} + ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: b [0/0] {230} + ¦ ¦ ¦--'(': ( [0/0] {232} + ¦ ¦ °--')': ) [0/0] {233} + ¦ ¦--PIPE: |> [0/1] {234} + ¦ °--expr: c() [0/0] {235} + ¦ ¦--expr: c [0/0] {237} + ¦ ¦ °--SYMBOL_FUNCTION_CALL: c [0/0] {236} + ¦ ¦--'(': ( [0/0] {238} + ¦ °--')': ) [0/0] {239} + ¦--COMMENT: # sho [2/0] {240} + ¦--expr: a |> [1/0] {241} + ¦ ¦--expr: a [0/1] {243} + ¦ ¦ °--SYMBOL: a [0/0] {242} + ¦ ¦--PIPE: |> [0/1] {244} + ¦ °--expr: b() [0/0] {245} + ¦ ¦--expr: b [0/0] {247} + ¦ ¦ °--SYMBOL_FUNCTION_CALL: b [0/0] {246} + ¦ ¦--'(': ( [0/0] {248} + ¦ °--')': ) [0/0] {249} + ¦--expr: fun(x [2/0] {250} + ¦ ¦--expr: fun [0/0] {252} + ¦ ¦ °--SYMBOL_FUNCTION_CALL: fun [0/0] {251} + ¦ ¦--'(': ( [0/0] {253} + ¦ ¦--expr: x [0/0] {255} + ¦ ¦ °--SYMBOL: x [0/0] {254} + ¦ ¦--',': , [0/2] {256} + ¦ ¦--expr: a |> [1/0] {257} + ¦ ¦ ¦--expr: a [0/1] {259} + ¦ ¦ ¦ °--SYMBOL: a [0/0] {258} + ¦ ¦ ¦--PIPE: |> [0/1] {260} + ¦ ¦ °--expr: b() [0/0] {261} + ¦ ¦ ¦--expr: b [0/0] {263} + ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: b [0/0] {262} + ¦ ¦ ¦--'(': ( [0/0] {264} + ¦ ¦ °--')': ) [0/0] {265} + ¦ °--')': ) [0/0] {266} + ¦--expr: fun(x [2/0] {267} + ¦ ¦--expr: fun [0/0] {269} + ¦ ¦ °--SYMBOL_FUNCTION_CALL: fun [0/0] {268} + ¦ ¦--'(': ( [0/0] {270} + ¦ ¦--expr: x [0/0] {272} + ¦ ¦ °--SYMBOL: x [0/0] {271} + ¦ ¦--',': , [0/4] {273} + ¦ ¦--SYMBOL_SUB: gg [1/1] {274} + ¦ ¦--EQ_SUB: = [0/1] {275} + ¦ ¦--expr: a |> [0/0] {276} + ¦ ¦ ¦--expr: a [0/1] {278} + ¦ ¦ ¦ °--SYMBOL: a [0/0] {277} + ¦ ¦ ¦--PIPE: |> [0/1] {279} + ¦ ¦ °--expr: b() [0/0] {280} + ¦ ¦ ¦--expr: b [0/0] {282} + ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: b [0/0] {281} + ¦ ¦ ¦--'(': ( [0/0] {283} + ¦ ¦ °--')': ) [0/0] {284} + ¦ ¦--',': , [0/4] {285} + ¦ ¦--expr: tt |> [1/0] {286} + ¦ ¦ ¦--expr: tt [0/1] {288} + ¦ ¦ ¦ °--SYMBOL: tt [0/0] {287} + ¦ ¦ ¦--PIPE: |> [0/1] {289} + ¦ ¦ °--expr: q() [0/0] {290} + ¦ ¦ ¦--expr: q [0/0] {292} + ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: q [0/0] {291} + ¦ ¦ ¦--'(': ( [0/0] {293} + ¦ ¦ °--')': ) [0/0] {294} + ¦ °--')': ) [0/0] {295} + ¦--expr: fun(x [2/0] {296} + ¦ ¦--expr: fun [0/0] {298} + ¦ ¦ °--SYMBOL_FUNCTION_CALL: fun [0/0] {297} + ¦ ¦--'(': ( [0/0] {299} + ¦ ¦--expr: x [0/0] {301} + ¦ ¦ °--SYMBOL: x [0/0] {300} + ¦ ¦--',': , [0/1] {302} + ¦ ¦--SYMBOL_SUB: gg [0/1] {303} + ¦ ¦--EQ_SUB: = [0/1] {304} + ¦ ¦--expr: a |> [0/0] {305} + ¦ ¦ ¦--expr: a [0/1] {307} + ¦ ¦ ¦ °--SYMBOL: a [0/0] {306} + ¦ ¦ ¦--PIPE: |> [0/1] {308} + ¦ ¦ °--expr: b() [0/0] {309} + ¦ ¦ ¦--expr: b [0/0] {311} + ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: b [0/0] {310} + ¦ ¦ ¦--'(': ( [0/0] {312} + ¦ ¦ °--')': ) [0/0] {313} + ¦ ¦--',': , [0/1] {314} + ¦ ¦--expr: tt |> [0/0] {315} + ¦ ¦ ¦--expr: tt [0/1] {317} + ¦ ¦ ¦ °--SYMBOL: tt [0/0] {316} + ¦ ¦ ¦--PIPE: |> [0/1] {318} + ¦ ¦ °--expr: q() [0/0] {319} + ¦ ¦ ¦--expr: q [0/0] {321} + ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: q [0/0] {320} + ¦ ¦ ¦--'(': ( [0/0] {322} + ¦ ¦ °--')': ) [0/0] {323} + ¦ °--')': ) [0/0] {324} + ¦--expr_or_assign_or_help: z = a [2/0] {325} + ¦ ¦--expr: z [0/1] {327} + ¦ ¦ °--SYMBOL: z [0/0] {326} + ¦ ¦--EQ_ASSIGN: = [0/1] {328} + ¦ ¦--expr: a [0/1] {331} + ¦ ¦ °--SYMBOL: a [0/0] {330} + ¦ ¦--PIPE: |> [0/1] {332} + ¦ °--expr: b() [0/0] {333} + ¦ ¦--expr: b [0/0] {335} + ¦ ¦ °--SYMBOL_FUNCTION_CALL: b [0/0] {334} + ¦ ¦--'(': ( [0/0] {336} + ¦ °--')': ) [0/0] {337} + ¦--expr: fun( [2/0] {338} + ¦ ¦--expr: fun [0/0] {340} + ¦ ¦ °--SYMBOL_FUNCTION_CALL: fun [0/0] {339} + ¦ ¦--'(': ( [0/1] {341} + ¦ ¦--SYMBOL_SUB: s [0/1] {342} + ¦ ¦--EQ_SUB: = [0/1] {343} + ¦ ¦--expr: g(x) [0/0] {344} + ¦ ¦ ¦--expr: g [0/0] {346} + ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: g [0/0] {345} + ¦ ¦ ¦--'(': ( [0/0] {347} + ¦ ¦ ¦--expr: x [0/0] {349} + ¦ ¦ ¦ °--SYMBOL: x [0/0] {348} + ¦ ¦ °--')': ) [0/0] {350} + ¦ ¦--',': , [0/4] {351} + ¦ ¦--SYMBOL_SUB: gg [1/1] {352} + ¦ ¦--EQ_SUB: = [0/1] {353} + ¦ ¦--expr: a(n = [0/0] {354} + ¦ ¦ ¦--expr: a(n = [0/1] {355} + ¦ ¦ ¦ ¦--expr: a [0/0] {357} + ¦ ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: a [0/0] {356} + ¦ ¦ ¦ ¦--'(': ( [0/0] {358} + ¦ ¦ ¦ ¦--expr: n == [0/0] {359} + ¦ ¦ ¦ ¦ ¦--expr: n [0/1] {361} + ¦ ¦ ¦ ¦ ¦ °--SYMBOL: n [0/0] {360} + ¦ ¦ ¦ ¦ ¦--EQ: == [0/1] {362} + ¦ ¦ ¦ ¦ °--expr: 2 [0/0] {364} + ¦ ¦ ¦ ¦ °--NUM_CONST: 2 [0/0] {363} + ¦ ¦ ¦ °--')': ) [0/0] {365} + ¦ ¦ ¦--PIPE: |> [0/1] {366} + ¦ ¦ °--expr: b() [0/0] {367} + ¦ ¦ ¦--expr: b [0/0] {369} + ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: b [0/0] {368} + ¦ ¦ ¦--'(': ( [0/0] {370} + ¦ ¦ °--')': ) [0/0] {371} + ¦ ¦--',': , [0/4] {372} + ¦ ¦--expr: tt |> [1/0] {373} + ¦ ¦ ¦--expr: tt [0/1] {375} + ¦ ¦ ¦ °--SYMBOL: tt [0/0] {374} + ¦ ¦ ¦--PIPE: |> [0/1] {376} + ¦ ¦ °--expr: q(r = [0/0] {377} + ¦ ¦ ¦--expr: q [0/0] {379} + ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: q [0/0] {378} + ¦ ¦ ¦--'(': ( [0/0] {380} + ¦ ¦ ¦--SYMBOL_SUB: r [0/1] {381} + ¦ ¦ ¦--EQ_SUB: = [0/1] {382} + ¦ ¦ ¦--expr: 3 [0/0] {384} + ¦ ¦ ¦ °--NUM_CONST: 3 [0/0] {383} + ¦ ¦ °--')': ) [0/0] {385} + ¦ °--')': ) [0/0] {386} + ¦--COMMENT: # FIX [2/0] {387} + ¦--expr: blew( [1/0] {388} + ¦ ¦--expr: blew [0/0] {390} + ¦ ¦ °--SYMBOL_FUNCTION_CALL: blew [0/0] {389} + ¦ ¦--'(': ( [0/0] {391} ¦ ¦--expr: x |> - [0/0] {392} - ¦ ¦ ¦--expr: x [0/1] {394} - ¦ ¦ ¦ °--SYMBOL: x [0/0] {393} - ¦ ¦ ¦--PIPE: |> [0/7] {395} - ¦ ¦ °--expr: c() [2/0] {396} - ¦ ¦ ¦--expr: c [0/0] {398} - ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: c [0/0] {397} - ¦ ¦ ¦--'(': ( [0/0] {399} - ¦ ¦ °--')': ) [0/0] {400} - ¦ ¦--',': , [0/1] {401} - ¦ ¦--SYMBOL_SUB: y [0/1] {402} - ¦ ¦--EQ_SUB: = [0/1] {403} - ¦ ¦--expr: 2 [0/0] {405} - ¦ ¦ °--NUM_CONST: 2 [0/0] {404} - ¦ °--')': ) [0/0] {406} - ¦--COMMENT: # FIX [2/0] {407} - ¦--expr: blew( [1/0] {408} - ¦ ¦--expr: blew [0/0] {410} - ¦ ¦ °--SYMBOL_FUNCTION_CALL: blew [0/0] {409} - ¦ ¦--'(': ( [0/0] {411} - ¦ ¦--SYMBOL_SUB: y [0/1] {412} - ¦ ¦--EQ_SUB: = [0/1] {413} - ¦ ¦--expr: 2 [0/0] {415} - ¦ ¦ °--NUM_CONST: 2 [0/0] {414} - ¦ ¦--',': , [0/1] {416} + [0/0] {392} + ¦ ¦ ¦--expr: x [0/1] {394} + ¦ ¦ ¦ °--SYMBOL: x [0/0] {393} + ¦ ¦ ¦--PIPE: |> [0/7] {395} + ¦ ¦ °--expr: c() [2/0] {396} + ¦ ¦ ¦--expr: c [0/0] {398} + ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: c [0/0] {397} + ¦ ¦ ¦--'(': ( [0/0] {399} + ¦ ¦ °--')': ) [0/0] {400} + ¦ ¦--',': , [0/1] {401} + ¦ ¦--SYMBOL_SUB: y [0/1] {402} + ¦ ¦--EQ_SUB: = [0/1] {403} + ¦ ¦--expr: 2 [0/0] {405} + ¦ ¦ °--NUM_CONST: 2 [0/0] {404} + ¦ °--')': ) [0/0] {406} + ¦--COMMENT: # FIX [2/0] {407} + ¦--expr: blew( [1/0] {408} + ¦ ¦--expr: blew [0/0] {410} + ¦ ¦ °--SYMBOL_FUNCTION_CALL: blew [0/0] {409} + ¦ ¦--'(': ( [0/0] {411} + ¦ ¦--SYMBOL_SUB: y [0/1] {412} + ¦ ¦--EQ_SUB: = [0/1] {413} + ¦ ¦--expr: 2 [0/0] {415} + ¦ ¦ °--NUM_CONST: 2 [0/0] {414} + ¦ ¦--',': , [0/1] {416} ¦ ¦--expr: x |> - [0/0] {417} - ¦ ¦ ¦--expr: x [0/1] {419} - ¦ ¦ ¦ °--SYMBOL: x [0/0] {418} - ¦ ¦ ¦--PIPE: |> [0/7] {420} - ¦ ¦ °--expr: c() [1/0] {421} - ¦ ¦ ¦--expr: c [0/0] {423} - ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: c [0/0] {422} - ¦ ¦ ¦--'(': ( [0/0] {424} - ¦ ¦ °--')': ) [0/0] {425} - ¦ °--')': ) [0/0] {426} - ¦--expr: {a |> [3/0] {427} - ¦ ¦--'{': { [0/0] {428} - ¦ ¦--expr: a |> [0/0] {429} - ¦ ¦ ¦--expr: a [0/1] {432} - ¦ ¦ ¦ °--SYMBOL: a [0/0] {431} - ¦ ¦ ¦--PIPE: |> [0/1] {433} - ¦ ¦ ¦--expr: c() [0/1] {434} - ¦ ¦ ¦ ¦--expr: c [0/0] {436} - ¦ ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: c [0/0] {435} - ¦ ¦ ¦ ¦--'(': ( [0/0] {437} - ¦ ¦ ¦ °--')': ) [0/0] {438} - ¦ ¦ ¦--'+': + [0/0] {439} - ¦ ¦ °--expr: 1 [0/0] {441} - ¦ ¦ °--NUM_CONST: 1 [0/0] {440} - ¦ °--'}': } [0/0] {442} + [0/0] {417} + ¦ ¦ ¦--expr: x [0/1] {419} + ¦ ¦ ¦ °--SYMBOL: x [0/0] {418} + ¦ ¦ ¦--PIPE: |> [0/7] {420} + ¦ ¦ °--expr: c() [1/0] {421} + ¦ ¦ ¦--expr: c [0/0] {423} + ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: c [0/0] {422} + ¦ ¦ ¦--'(': ( [0/0] {424} + ¦ ¦ °--')': ) [0/0] {425} + ¦ °--')': ) [0/0] {426} + ¦--expr: {a |> [3/0] {427} + ¦ ¦--'{': { [0/0] {428} + ¦ ¦--expr: a |> [0/0] {429} + ¦ ¦ ¦--expr: a [0/1] {432} + ¦ ¦ ¦ °--SYMBOL: a [0/0] {431} + ¦ ¦ ¦--PIPE: |> [0/1] {433} + ¦ ¦ ¦--expr: c() [0/1] {434} + ¦ ¦ ¦ ¦--expr: c [0/0] {436} + ¦ ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: c [0/0] {435} + ¦ ¦ ¦ ¦--'(': ( [0/0] {437} + ¦ ¦ ¦ °--')': ) [0/0] {438} + ¦ ¦ ¦--'+': + [0/0] {439} + ¦ ¦ °--expr: 1 [0/0] {441} + ¦ ¦ °--NUM_CONST: 1 [0/0] {440} + ¦ °--'}': } [0/0] {442} + ¦--expr: { + + [2/0] {443} + ¦ ¦--'{': { [0/2] {444} + ¦ ¦--expr: ( + + [2/0] {445} + ¦ ¦ ¦--'(': ( [0/4] {446} + ¦ ¦ ¦--COMMENT: # som [2/4] {447} + ¦ ¦ ¦--expr: a |> [2/2] {448} + ¦ ¦ ¦ ¦--expr: a [0/1] {451} + ¦ ¦ ¦ ¦ °--SYMBOL: a [0/0] {450} + ¦ ¦ ¦ ¦--PIPE: |> [0/1] {452} + ¦ ¦ ¦ ¦--expr: c() [0/1] {453} + ¦ ¦ ¦ ¦ ¦--expr: c [0/0] {455} + ¦ ¦ ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: c [0/0] {454} + ¦ ¦ ¦ ¦ ¦--'(': ( [0/0] {456} + ¦ ¦ ¦ ¦ °--')': ) [0/0] {457} + ¦ ¦ ¦ ¦--'+': + [0/1] {458} + ¦ ¦ ¦ °--expr: 1 [0/0] {460} + ¦ ¦ ¦ °--NUM_CONST: 1 [0/0] {459} + ¦ ¦ °--')': ) [2/0] {461} + ¦ °--'}': } [2/0] {462} °--expr: b |> - [2/0] {443} - ¦--expr: b [0/1] {447} - ¦ °--SYMBOL: b [0/0] {446} - ¦--PIPE: |> [0/2] {448} - ¦--expr: f() [1/1] {449} - ¦ ¦--expr: f [0/0] {451} - ¦ ¦ °--SYMBOL_FUNCTION_CALL: f [0/0] {450} - ¦ ¦--'(': ( [0/0] {452} - ¦ °--')': ) [0/0] {453} - ¦--PIPE: |> [0/1] {454} - ¦--COMMENT: # nev [0/2] {455} - ¦--expr: k() [1/1] {456} - ¦ ¦--expr: k [0/0] {458} - ¦ ¦ °--SYMBOL_FUNCTION_CALL: k [0/0] {457} - ¦ ¦--'(': ( [0/0] {459} - ¦ °--')': ) [0/0] {460} - ¦--PIPE: |> [0/2] {461} - °--expr: x() [1/0] {462} - ¦--expr: x [0/0] {464} - ¦ °--SYMBOL_FUNCTION_CALL: x [0/0] {463} - ¦--'(': ( [0/0] {465} - °--')': ) [0/0] {466} + [2/0] {463} + ¦--expr: b [0/1] {467} + ¦ °--SYMBOL: b [0/0] {466} + ¦--PIPE: |> [0/2] {468} + ¦--expr: f() [1/1] {469} + ¦ ¦--expr: f [0/0] {471} + ¦ ¦ °--SYMBOL_FUNCTION_CALL: f [0/0] {470} + ¦ ¦--'(': ( [0/0] {472} + ¦ °--')': ) [0/0] {473} + ¦--PIPE: |> [0/1] {474} + ¦--COMMENT: # nev [0/2] {475} + ¦--expr: k() [1/1] {476} + ¦ ¦--expr: k [0/0] {478} + ¦ ¦ °--SYMBOL_FUNCTION_CALL: k [0/0] {477} + ¦ ¦--'(': ( [0/0] {479} + ¦ °--')': ) [0/0] {480} + ¦--PIPE: |> [0/2] {481} + °--expr: x() [1/0] {482} + ¦--expr: x [0/0] {484} + ¦ °--SYMBOL_FUNCTION_CALL: x [0/0] {483} + ¦--'(': ( [0/0] {485} + °--')': ) [0/0] {486} diff --git a/tests/testthat/line_breaks_and_other/base-pipe-line-breaks-out.R b/tests/testthat/line_breaks_and_other/base-pipe-line-breaks-out.R index 0fd45f0b5..346e0303c 100644 --- a/tests/testthat/line_breaks_and_other/base-pipe-line-breaks-out.R +++ b/tests/testthat/line_breaks_and_other/base-pipe-line-breaks-out.R @@ -88,6 +88,14 @@ blew(y = 2, x |> a |> c() + 1 } +{ + ( + # some comment + + a |> c() + 1 + ) +} + b |> f() |> # never move comment to next line as it can be styler: off or nolint k() |> diff --git a/tests/testthat/line_breaks_and_other/comma-in.R b/tests/testthat/line_breaks_and_other/comma-in.R index dba179386..de95104b9 100644 --- a/tests/testthat/line_breaks_and_other/comma-in.R +++ b/tests/testthat/line_breaks_and_other/comma-in.R @@ -18,3 +18,14 @@ mpg %>% , avg_hwy = mean(hwy) , n = n() , n_class = n_distinct(class)) + + +1:4 %>% { + + + ( + + . + 1 + ) + +} diff --git a/tests/testthat/line_breaks_and_other/comma-in_tree b/tests/testthat/line_breaks_and_other/comma-in_tree index 92771fe7c..9aad5df49 100644 --- a/tests/testthat/line_breaks_and_other/comma-in_tree +++ b/tests/testthat/line_breaks_and_other/comma-in_tree @@ -49,49 +49,74 @@ ROOT (token: short_text [lag_newlines/spaces] {pos_id}) ¦ ¦ °--SYMBOL: a [0/0] {47} ¦ ¦--',': , [1/0] {49} ¦ °--')': ) [0/0] {50} - °--expr: mpg % [2/0] {51} - ¦--expr: mpg [0/1] {53} - ¦ °--SYMBOL: mpg [0/0] {52} - ¦--SPECIAL-PIPE: %>% [0/4] {54} - °--expr: summa [1/0] {55} - ¦--expr: summa [0/0] {57} - ¦ °--SYMBOL_FUNCTION_CALL: summa [0/0] {56} - ¦--'(': ( [0/0] {58} - ¦--SYMBOL_SUB: avg_c [0/1] {59} - ¦--EQ_SUB: = [0/1] {60} - ¦--expr: mean( [0/0] {61} - ¦ ¦--expr: mean [0/0] {63} - ¦ ¦ °--SYMBOL_FUNCTION_CALL: mean [0/0] {62} - ¦ ¦--'(': ( [0/0] {64} - ¦ ¦--expr: cty [0/0] {66} - ¦ ¦ °--SYMBOL: cty [0/0] {65} - ¦ °--')': ) [0/0] {67} - ¦--',': , [1/1] {68} - ¦--SYMBOL_SUB: avg_h [0/1] {69} - ¦--EQ_SUB: = [0/1] {70} - ¦--expr: mean( [0/0] {71} - ¦ ¦--expr: mean [0/0] {73} - ¦ ¦ °--SYMBOL_FUNCTION_CALL: mean [0/0] {72} - ¦ ¦--'(': ( [0/0] {74} - ¦ ¦--expr: hwy [0/0] {76} - ¦ ¦ °--SYMBOL: hwy [0/0] {75} - ¦ °--')': ) [0/0] {77} - ¦--',': , [1/1] {78} - ¦--SYMBOL_SUB: n [0/1] {79} - ¦--EQ_SUB: = [0/1] {80} - ¦--expr: n() [0/0] {81} - ¦ ¦--expr: n [0/0] {83} - ¦ ¦ °--SYMBOL_FUNCTION_CALL: n [0/0] {82} - ¦ ¦--'(': ( [0/0] {84} - ¦ °--')': ) [0/0] {85} - ¦--',': , [1/1] {86} - ¦--SYMBOL_SUB: n_cla [0/1] {87} - ¦--EQ_SUB: = [0/1] {88} - ¦--expr: n_dis [0/0] {89} - ¦ ¦--expr: n_dis [0/0] {91} - ¦ ¦ °--SYMBOL_FUNCTION_CALL: n_dis [0/0] {90} - ¦ ¦--'(': ( [0/0] {92} - ¦ ¦--expr: class [0/0] {94} - ¦ ¦ °--SYMBOL: class [0/0] {93} - ¦ °--')': ) [0/0] {95} - °--')': ) [0/0] {96} + ¦--expr: mpg % [2/0] {51} + ¦ ¦--expr: mpg [0/1] {53} + ¦ ¦ °--SYMBOL: mpg [0/0] {52} + ¦ ¦--SPECIAL-PIPE: %>% [0/4] {54} + ¦ °--expr: summa [1/0] {55} + ¦ ¦--expr: summa [0/0] {57} + ¦ ¦ °--SYMBOL_FUNCTION_CALL: summa [0/0] {56} + ¦ ¦--'(': ( [0/0] {58} + ¦ ¦--SYMBOL_SUB: avg_c [0/1] {59} + ¦ ¦--EQ_SUB: = [0/1] {60} + ¦ ¦--expr: mean( [0/0] {61} + ¦ ¦ ¦--expr: mean [0/0] {63} + ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: mean [0/0] {62} + ¦ ¦ ¦--'(': ( [0/0] {64} + ¦ ¦ ¦--expr: cty [0/0] {66} + ¦ ¦ ¦ °--SYMBOL: cty [0/0] {65} + ¦ ¦ °--')': ) [0/0] {67} + ¦ ¦--',': , [1/1] {68} + ¦ ¦--SYMBOL_SUB: avg_h [0/1] {69} + ¦ ¦--EQ_SUB: = [0/1] {70} + ¦ ¦--expr: mean( [0/0] {71} + ¦ ¦ ¦--expr: mean [0/0] {73} + ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: mean [0/0] {72} + ¦ ¦ ¦--'(': ( [0/0] {74} + ¦ ¦ ¦--expr: hwy [0/0] {76} + ¦ ¦ ¦ °--SYMBOL: hwy [0/0] {75} + ¦ ¦ °--')': ) [0/0] {77} + ¦ ¦--',': , [1/1] {78} + ¦ ¦--SYMBOL_SUB: n [0/1] {79} + ¦ ¦--EQ_SUB: = [0/1] {80} + ¦ ¦--expr: n() [0/0] {81} + ¦ ¦ ¦--expr: n [0/0] {83} + ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: n [0/0] {82} + ¦ ¦ ¦--'(': ( [0/0] {84} + ¦ ¦ °--')': ) [0/0] {85} + ¦ ¦--',': , [1/1] {86} + ¦ ¦--SYMBOL_SUB: n_cla [0/1] {87} + ¦ ¦--EQ_SUB: = [0/1] {88} + ¦ ¦--expr: n_dis [0/0] {89} + ¦ ¦ ¦--expr: n_dis [0/0] {91} + ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: n_dis [0/0] {90} + ¦ ¦ ¦--'(': ( [0/0] {92} + ¦ ¦ ¦--expr: class [0/0] {94} + ¦ ¦ ¦ °--SYMBOL: class [0/0] {93} + ¦ ¦ °--')': ) [0/0] {95} + ¦ °--')': ) [0/0] {96} + °--expr: 1:4 % [3/0] {97} + ¦--expr: 1:4 [0/1] {98} + ¦ ¦--expr: 1 [0/0] {100} + ¦ ¦ °--NUM_CONST: 1 [0/0] {99} + ¦ ¦--':': : [0/0] {101} + ¦ °--expr: 4 [0/0] {103} + ¦ °--NUM_CONST: 4 [0/0] {102} + ¦--SPECIAL-PIPE: %>% [0/1] {104} + °--expr: { + + + [0/0] {105} + ¦--'{': { [0/4] {106} + ¦--expr: ( + + [3/0] {107} + ¦ ¦--'(': ( [0/8] {108} + ¦ ¦--expr: . + 1 [2/4] {109} + ¦ ¦ ¦--expr: . [0/1] {111} + ¦ ¦ ¦ °--SYMBOL: . [0/0] {110} + ¦ ¦ ¦--'+': + [0/1] {112} + ¦ ¦ °--expr: 1 [0/0] {114} + ¦ ¦ °--NUM_CONST: 1 [0/0] {113} + ¦ °--')': ) [1/0] {115} + °--'}': } [2/0] {116} diff --git a/tests/testthat/line_breaks_and_other/comma-out.R b/tests/testthat/line_breaks_and_other/comma-out.R index 826ef5d41..14842c18e 100644 --- a/tests/testthat/line_breaks_and_other/comma-out.R +++ b/tests/testthat/line_breaks_and_other/comma-out.R @@ -21,3 +21,11 @@ mpg %>% n = n(), n_class = n_distinct(class) ) + + +1:4 %>% + { + ( + . + 1 + ) + } From 0d67987791e44f2ebdc67ecd31b9e3420eea0be6 Mon Sep 17 00:00:00 2001 From: Indrajeet Patil Date: Sat, 11 May 2024 13:52:27 +0200 Subject: [PATCH 10/20] also add tests for roxygen comments --- .../13-empty-lines-in.R | 10 + .../13-empty-lines-in_tree | 190 +++++++++--------- .../13-empty-lines-out.R | 10 +- 3 files changed, 117 insertions(+), 93 deletions(-) diff --git a/tests/testthat/roxygen-examples-complete/13-empty-lines-in.R b/tests/testthat/roxygen-examples-complete/13-empty-lines-in.R index e1ab00834..1af04bba3 100644 --- a/tests/testthat/roxygen-examples-complete/13-empty-lines-in.R +++ b/tests/testthat/roxygen-examples-complete/13-empty-lines-in.R @@ -12,17 +12,27 @@ #' #' #' +#' ( +#' +#' #' # more #' a <- 3 +#' +#' ) #' # a comment #' \dontrun{ +#' { +#' #' x #' +#' } +#' #' y # hi #' #' # more #' #' a <- 3 +#' #' } #' @importFrom purrr compact #' @export diff --git a/tests/testthat/roxygen-examples-complete/13-empty-lines-in_tree b/tests/testthat/roxygen-examples-complete/13-empty-lines-in_tree index b511569eb..f16a8469d 100644 --- a/tests/testthat/roxygen-examples-complete/13-empty-lines-in_tree +++ b/tests/testthat/roxygen-examples-complete/13-empty-lines-in_tree @@ -12,109 +12,119 @@ ROOT (token: short_text [lag_newlines/spaces] {pos_id}) ¦--COMMENT: #' [1/0] {11} ¦--COMMENT: #' [1/0] {12} ¦--COMMENT: #' [1/0] {13} - ¦--COMMENT: #' # [1/0] {14} - ¦--COMMENT: #' a [1/0] {15} - ¦--COMMENT: #' # [1/0] {16} - ¦--COMMENT: #' \d [1/0] {17} - ¦--COMMENT: #' x [1/0] {18} + ¦--COMMENT: #' ( [1/0] {14} + ¦--COMMENT: #' [1/0] {15} + ¦--COMMENT: #' [1/0] {16} + ¦--COMMENT: #' # [1/0] {17} + ¦--COMMENT: #' a [1/0] {18} ¦--COMMENT: #' [1/0] {19} - ¦--COMMENT: #' y [1/0] {20} - ¦--COMMENT: #' [1/0] {21} - ¦--COMMENT: #' # [1/0] {22} - ¦--COMMENT: #' [1/0] {23} - ¦--COMMENT: #' a [1/0] {24} - ¦--COMMENT: #' } [1/0] {25} - ¦--COMMENT: #' @i [1/0] {26} - ¦--COMMENT: #' @e [1/0] {27} - °--expr: creat [1/0] {28} - ¦--expr: creat [0/1] {30} - ¦ °--SYMBOL: creat [0/0] {29} - ¦--LEFT_ASSIGN: <- [0/1] {31} - °--expr: funct [0/0] {32} - ¦--FUNCTION: funct [0/0] {33} - ¦--'(': ( [0/0] {34} - ¦--SYMBOL_FORMALS: initi [0/1] {35} - ¦--EQ_FORMALS: = [0/1] {36} - ¦--expr: defau [0/0] {38} - ¦ °--SYMBOL: defau [0/0] {37} - ¦--',': , [0/31] {39} - ¦--SYMBOL_FORMALS: line_ [1/1] {40} - ¦--EQ_FORMALS: = [0/1] {41} - ¦--expr: NULL [0/0] {43} - ¦ °--NULL_CONST: NULL [0/0] {42} - ¦--',': , [0/31] {44} - ¦--SYMBOL_FORMALS: space [1/1] {45} + ¦--COMMENT: #' ) [1/0] {20} + ¦--COMMENT: #' # [1/0] {21} + ¦--COMMENT: #' \d [1/0] {22} + ¦--COMMENT: #' { [1/0] {23} + ¦--COMMENT: #' [1/0] {24} + ¦--COMMENT: #' x [1/0] {25} + ¦--COMMENT: #' [1/0] {26} + ¦--COMMENT: #' } [1/0] {27} + ¦--COMMENT: #' [1/0] {28} + ¦--COMMENT: #' y [1/0] {29} + ¦--COMMENT: #' [1/0] {30} + ¦--COMMENT: #' # [1/0] {31} + ¦--COMMENT: #' [1/0] {32} + ¦--COMMENT: #' a [1/0] {33} + ¦--COMMENT: #' [1/0] {34} + ¦--COMMENT: #' } [1/0] {35} + ¦--COMMENT: #' @i [1/0] {36} + ¦--COMMENT: #' @e [1/0] {37} + °--expr: creat [1/0] {38} + ¦--expr: creat [0/1] {40} + ¦ °--SYMBOL: creat [0/0] {39} + ¦--LEFT_ASSIGN: <- [0/1] {41} + °--expr: funct [0/0] {42} + ¦--FUNCTION: funct [0/0] {43} + ¦--'(': ( [0/0] {44} + ¦--SYMBOL_FORMALS: initi [0/1] {45} ¦--EQ_FORMALS: = [0/1] {46} - ¦--expr: NULL [0/0] {48} - ¦ °--NULL_CONST: NULL [0/0] {47} + ¦--expr: defau [0/0] {48} + ¦ °--SYMBOL: defau [0/0] {47} ¦--',': , [0/31] {49} - ¦--SYMBOL_FORMALS: token [1/1] {50} + ¦--SYMBOL_FORMALS: line_ [1/1] {50} ¦--EQ_FORMALS: = [0/1] {51} ¦--expr: NULL [0/0] {53} ¦ °--NULL_CONST: NULL [0/0] {52} ¦--',': , [0/31] {54} - ¦--SYMBOL_FORMALS: inden [1/1] {55} + ¦--SYMBOL_FORMALS: space [1/1] {55} ¦--EQ_FORMALS: = [0/1] {56} ¦--expr: NULL [0/0] {58} ¦ °--NULL_CONST: NULL [0/0] {57} ¦--',': , [0/31] {59} - ¦--SYMBOL_FORMALS: use_r [1/1] {60} + ¦--SYMBOL_FORMALS: token [1/1] {60} ¦--EQ_FORMALS: = [0/1] {61} - ¦--expr: FALSE [0/0] {63} - ¦ °--NUM_CONST: FALSE [0/0] {62} + ¦--expr: NULL [0/0] {63} + ¦ °--NULL_CONST: NULL [0/0] {62} ¦--',': , [0/31] {64} - ¦--SYMBOL_FORMALS: reind [1/1] {65} + ¦--SYMBOL_FORMALS: inden [1/1] {65} ¦--EQ_FORMALS: = [0/1] {66} - ¦--expr: tidyv [0/0] {67} - ¦ ¦--expr: tidyv [0/0] {69} - ¦ ¦ °--SYMBOL_FUNCTION_CALL: tidyv [0/0] {68} - ¦ ¦--'(': ( [0/0] {70} - ¦ °--')': ) [0/0] {71} - ¦--')': ) [0/1] {72} + ¦--expr: NULL [0/0] {68} + ¦ °--NULL_CONST: NULL [0/0] {67} + ¦--',': , [0/31] {69} + ¦--SYMBOL_FORMALS: use_r [1/1] {70} + ¦--EQ_FORMALS: = [0/1] {71} + ¦--expr: FALSE [0/0] {73} + ¦ °--NUM_CONST: FALSE [0/0] {72} + ¦--',': , [0/31] {74} + ¦--SYMBOL_FORMALS: reind [1/1] {75} + ¦--EQ_FORMALS: = [0/1] {76} + ¦--expr: tidyv [0/0] {77} + ¦ ¦--expr: tidyv [0/0] {79} + ¦ ¦ °--SYMBOL_FUNCTION_CALL: tidyv [0/0] {78} + ¦ ¦--'(': ( [0/0] {80} + ¦ °--')': ) [0/0] {81} + ¦--')': ) [0/1] {82} °--expr: { - l [0/0] {73} - ¦--'{': { [0/2] {74} - ¦--expr: list( [1/0] {75} - ¦ ¦--expr: list( [0/1] {76} - ¦ ¦ ¦--expr: list [0/0] {78} - ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: list [0/0] {77} - ¦ ¦ ¦--'(': ( [0/4] {79} - ¦ ¦ ¦--COMMENT: # tra [1/4] {80} - ¦ ¦ ¦--SYMBOL_SUB: initi [1/1] {81} - ¦ ¦ ¦--EQ_SUB: = [0/1] {82} - ¦ ¦ ¦--expr: list( [0/0] {83} - ¦ ¦ ¦ ¦--expr: list [0/0] {85} - ¦ ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: list [0/0] {84} - ¦ ¦ ¦ ¦--'(': ( [0/0] {86} - ¦ ¦ ¦ ¦--expr: initi [0/0] {88} - ¦ ¦ ¦ ¦ °--SYMBOL: initi [0/0] {87} - ¦ ¦ ¦ °--')': ) [0/0] {89} - ¦ ¦ ¦--',': , [0/4] {90} - ¦ ¦ ¦--expr: line_ [1/0] {92} - ¦ ¦ ¦ °--SYMBOL: line_ [0/0] {91} - ¦ ¦ ¦--',': , [0/4] {93} - ¦ ¦ ¦--expr: space [1/0] {95} - ¦ ¦ ¦ °--SYMBOL: space [0/0] {94} - ¦ ¦ ¦--',': , [0/4] {96} - ¦ ¦ ¦--expr: token [1/0] {98} - ¦ ¦ ¦ °--SYMBOL: token [0/0] {97} - ¦ ¦ ¦--',': , [0/4] {99} - ¦ ¦ ¦--expr: inden [1/0] {101} - ¦ ¦ ¦ °--SYMBOL: inden [0/0] {100} - ¦ ¦ ¦--',': , [0/4] {102} - ¦ ¦ ¦--COMMENT: # tra [1/4] {103} - ¦ ¦ ¦--expr: use_r [1/0] {105} - ¦ ¦ ¦ °--SYMBOL: use_r [0/0] {104} + l [0/0] {83} + ¦--'{': { [0/2] {84} + ¦--expr: list( [1/0] {85} + ¦ ¦--expr: list( [0/1] {86} + ¦ ¦ ¦--expr: list [0/0] {88} + ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: list [0/0] {87} + ¦ ¦ ¦--'(': ( [0/4] {89} + ¦ ¦ ¦--COMMENT: # tra [1/4] {90} + ¦ ¦ ¦--SYMBOL_SUB: initi [1/1] {91} + ¦ ¦ ¦--EQ_SUB: = [0/1] {92} + ¦ ¦ ¦--expr: list( [0/0] {93} + ¦ ¦ ¦ ¦--expr: list [0/0] {95} + ¦ ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: list [0/0] {94} + ¦ ¦ ¦ ¦--'(': ( [0/0] {96} + ¦ ¦ ¦ ¦--expr: initi [0/0] {98} + ¦ ¦ ¦ ¦ °--SYMBOL: initi [0/0] {97} + ¦ ¦ ¦ °--')': ) [0/0] {99} + ¦ ¦ ¦--',': , [0/4] {100} + ¦ ¦ ¦--expr: line_ [1/0] {102} + ¦ ¦ ¦ °--SYMBOL: line_ [0/0] {101} + ¦ ¦ ¦--',': , [0/4] {103} + ¦ ¦ ¦--expr: space [1/0] {105} + ¦ ¦ ¦ °--SYMBOL: space [0/0] {104} ¦ ¦ ¦--',': , [0/4] {106} - ¦ ¦ ¦--expr: reind [1/2] {108} - ¦ ¦ ¦ °--SYMBOL: reind [0/0] {107} - ¦ ¦ °--')': ) [1/0] {109} - ¦ ¦--SPECIAL-PIPE: %>% [0/4] {110} - ¦ °--expr: map(c [1/0] {111} - ¦ ¦--expr: map [0/0] {113} - ¦ ¦ °--SYMBOL_FUNCTION_CALL: map [0/0] {112} - ¦ ¦--'(': ( [0/0] {114} - ¦ ¦--expr: compa [0/0] {116} - ¦ ¦ °--SYMBOL: compa [0/0] {115} - ¦ °--')': ) [0/0] {117} - °--'}': } [1/0] {118} + ¦ ¦ ¦--expr: token [1/0] {108} + ¦ ¦ ¦ °--SYMBOL: token [0/0] {107} + ¦ ¦ ¦--',': , [0/4] {109} + ¦ ¦ ¦--expr: inden [1/0] {111} + ¦ ¦ ¦ °--SYMBOL: inden [0/0] {110} + ¦ ¦ ¦--',': , [0/4] {112} + ¦ ¦ ¦--COMMENT: # tra [1/4] {113} + ¦ ¦ ¦--expr: use_r [1/0] {115} + ¦ ¦ ¦ °--SYMBOL: use_r [0/0] {114} + ¦ ¦ ¦--',': , [0/4] {116} + ¦ ¦ ¦--expr: reind [1/2] {118} + ¦ ¦ ¦ °--SYMBOL: reind [0/0] {117} + ¦ ¦ °--')': ) [1/0] {119} + ¦ ¦--SPECIAL-PIPE: %>% [0/4] {120} + ¦ °--expr: map(c [1/0] {121} + ¦ ¦--expr: map [0/0] {123} + ¦ ¦ °--SYMBOL_FUNCTION_CALL: map [0/0] {122} + ¦ ¦--'(': ( [0/0] {124} + ¦ ¦--expr: compa [0/0] {126} + ¦ ¦ °--SYMBOL: compa [0/0] {125} + ¦ °--')': ) [0/0] {127} + °--'}': } [1/0] {128} diff --git a/tests/testthat/roxygen-examples-complete/13-empty-lines-out.R b/tests/testthat/roxygen-examples-complete/13-empty-lines-out.R index ae4f1b9db..a2f6f567b 100644 --- a/tests/testthat/roxygen-examples-complete/13-empty-lines-out.R +++ b/tests/testthat/roxygen-examples-complete/13-empty-lines-out.R @@ -11,11 +11,15 @@ #' #' #' -#' # more -#' a <- 3 +#' ( +#' # more +#' a <- 3 +#' ) #' # a comment #' \dontrun{ -#' x +#' { +#' x +#' } #' #' y # hi #' From d1fb41e1311207d48bae3c6b9825799fa58d3c08 Mon Sep 17 00:00:00 2001 From: Indrajeet Patil Date: Sat, 11 May 2024 16:38:40 +0200 Subject: [PATCH 11/20] run on R-release on Ubuntu regression introduced in https://github.com/r-lib/styler/pull/1200 --- .github/workflows/check-full.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/check-full.yaml b/.github/workflows/check-full.yaml index d36be307c..ae20a0fbf 100644 --- a/.github/workflows/check-full.yaml +++ b/.github/workflows/check-full.yaml @@ -25,9 +25,9 @@ jobs: # use 4.1 to check with rtools40's older compiler - { os: windows-latest, r: "4.1" } - - { os: ubuntu-latest, r: "devel", http-user-agent: "release" } - - { os: ubuntu-latest, r: "devel", locale: "en_US" } + - { os: ubuntu-latest, r: "devel", locale: "en_US", http-user-agent: "release" } #- { os: ubuntu-latest, r: "release", locale: "zh_CN" } + - { os: ubuntu-latest, r: "release" } - { os: ubuntu-latest, r: "oldrel-1" } - { os: ubuntu-latest, r: "oldrel-2" } - { os: ubuntu-latest, r: "oldrel-3" } From a7056be117f4711ae894f08892c22b36f7a3c058 Mon Sep 17 00:00:00 2001 From: Indrajeet Patil Date: Sat, 11 May 2024 17:37:27 +0200 Subject: [PATCH 12/20] remove non-existing token --- R/rules-line-breaks.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/rules-line-breaks.R b/R/rules-line-breaks.R index 6b0dcc34d..4d356a32d 100644 --- a/R/rules-line-breaks.R +++ b/R/rules-line-breaks.R @@ -432,7 +432,7 @@ remove_empty_lines_after_opening_braces <- function(pd) { } remove_empty_lines_before_closing_braces <- function(pd) { - closing_braces <- c("')'", "']'", "RBB") + closing_braces <- c("')'", "']'") paren_before <- pd$token %in% closing_braces if (!any(paren_before)) { return(pd) From e744159f0016d070b5ccb62bfeb788153a33e370 Mon Sep 17 00:00:00 2001 From: Indrajeet Patil Date: Tue, 14 May 2024 22:01:26 +0200 Subject: [PATCH 13/20] use only a single transformer --- R/rules-line-breaks.R | 27 +++++++++++-------------- R/style-guides.R | 6 +++--- tests/testthat/test-transformers-drop.R | 5 ++--- 3 files changed, 17 insertions(+), 21 deletions(-) diff --git a/R/rules-line-breaks.R b/R/rules-line-breaks.R index 4d356a32d..8fc492643 100644 --- a/R/rules-line-breaks.R +++ b/R/rules-line-breaks.R @@ -419,26 +419,23 @@ set_line_break_after_ggplot2_plus <- function(pd) { } -remove_empty_lines_after_opening_braces <- function(pd) { +remove_empty_lines_after_opening_and_before_closing_braces <- function(pd) { opening_braces <- c("'('", "'['", "LBB") + closing_braces <- c("')'", "']'") + paren_after <- pd$token %in% opening_braces - if (!any(paren_after)) { - return(pd) + if (any(paren_after)) { + pd$lag_newlines[ + lag(pd$token %in% opening_braces) & pd$lag_newlines > 1L + ] <- 1L } - pd$lag_newlines[ - lag(pd$token %in% opening_braces) & pd$lag_newlines > 1L - ] <- 1L - pd -} -remove_empty_lines_before_closing_braces <- function(pd) { - closing_braces <- c("')'", "']'") paren_before <- pd$token %in% closing_braces - if (!any(paren_before)) { - return(pd) + if (any(paren_before)) { + pd$lag_newlines[ + pd$token %in% closing_braces & pd$lag_newlines > 1L + ] <- 1L } - pd$lag_newlines[ - pd$token %in% closing_braces & pd$lag_newlines > 1L - ] <- 1L + pd } diff --git a/R/style-guides.R b/R/style-guides.R index 2b83ab0c2..1445586ac 100644 --- a/R/style-guides.R +++ b/R/style-guides.R @@ -130,6 +130,8 @@ tidyverse_style <- function(scope = "tokens", line_break_manipulators <- if ("line_breaks" %in% scope) { list( + remove_empty_lines_after_opening_and_before_closing_braces = + remove_empty_lines_after_opening_and_before_closing_braces, set_line_break_around_comma_and_or = set_line_break_around_comma_and_or, set_line_break_after_assignment = set_line_break_after_assignment, set_line_break_before_curly_opening = set_line_break_before_curly_opening, @@ -166,9 +168,7 @@ tidyverse_style <- function(scope = "tokens", add_line_break_after_pipe = if (strict) add_line_break_after_pipe, set_line_break_after_ggplot2_plus = if (strict) { set_line_break_after_ggplot2_plus - }, - remove_empty_lines_after_opening_braces = remove_empty_lines_after_opening_braces, - remove_empty_lines_before_closing_braces = remove_empty_lines_before_closing_braces + } ) } diff --git a/tests/testthat/test-transformers-drop.R b/tests/testthat/test-transformers-drop.R index e9709d260..77ccff008 100644 --- a/tests/testthat/test-transformers-drop.R +++ b/tests/testthat/test-transformers-drop.R @@ -71,14 +71,13 @@ test_that("tidyverse transformers are correctly dropped", { t_fun <- transformers_drop("x", t_style) names_line_break <- c( + "remove_empty_lines_after_opening_and_before_closing_braces", "set_line_break_around_comma_and_or", "set_line_break_after_assignment", "set_line_break_after_opening_if_call_is_multi_line", "set_line_break_before_closing_call", "remove_line_break_in_fun_call", - "set_line_break_after_ggplot2_plus", - "remove_empty_lines_after_opening_braces", - "remove_empty_lines_before_closing_braces" + "set_line_break_after_ggplot2_plus" ) expect_setequal(names(t_fun$line_break), names_line_break) From 2a98c4d1b8036b5f737ff61052218f192b3b22a6 Mon Sep 17 00:00:00 2001 From: Indrajeet Patil Date: Tue, 14 May 2024 22:03:28 +0200 Subject: [PATCH 14/20] Update strict.Rmd --- vignettes/strict.Rmd | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/vignettes/strict.Rmd b/vignettes/strict.Rmd index 880a5db10..13ad2509d 100644 --- a/vignettes/strict.Rmd +++ b/vignettes/strict.Rmd @@ -58,12 +58,11 @@ function() 1 ~ more() # comment ``` -- More than one line break is tolerated before closing curly brace and line breaks between curly and round braces are not removed. +- Line breaks between curly and round braces are not removed. ```{styler} test({ 1 - } ) ``` From 4b1201072d150a5cabed0a7ebf099dbd58f472bd Mon Sep 17 00:00:00 2001 From: Indrajeet Patil Date: Wed, 15 May 2024 20:22:07 +0200 Subject: [PATCH 15/20] add a test that mixes LBB with ( --- .../square_brackets_double_line_break-in.R | 14 ++++-- .../square_brackets_double_line_break-in_tree | 44 +++++++++++-------- .../square_brackets_double_line_break-out.R | 10 +++-- 3 files changed, 41 insertions(+), 27 deletions(-) diff --git a/tests/testthat/indention_square_brackets/square_brackets_double_line_break-in.R b/tests/testthat/indention_square_brackets/square_brackets_double_line_break-in.R index 6eb852298..322d25bf5 100644 --- a/tests/testthat/indention_square_brackets/square_brackets_double_line_break-in.R +++ b/tests/testthat/indention_square_brackets/square_brackets_double_line_break-in.R @@ -26,14 +26,20 @@ a[[ 2 + ]] + a[[ - 2 -]] + # this comment shouldn't mess + 1, c( + + 1, 2 + + # neither should this one + + ) -a[[ - 2 ]] diff --git a/tests/testthat/indention_square_brackets/square_brackets_double_line_break-in_tree b/tests/testthat/indention_square_brackets/square_brackets_double_line_break-in_tree index 82ce65dce..f2de64d54 100644 --- a/tests/testthat/indention_square_brackets/square_brackets_double_line_break-in_tree +++ b/tests/testthat/indention_square_brackets/square_brackets_double_line_break-in_tree @@ -52,24 +52,30 @@ ROOT (token: short_text [lag_newlines/spaces] {pos_id}) ¦ ¦--LBB: [[ [0/2] {45} ¦ ¦--expr: 2 [2/0] {47} ¦ ¦ °--NUM_CONST: 2 [0/0] {46} - ¦ ¦--']': ] [2/0] {48} + ¦ ¦--']': ] [3/0] {48} ¦ °--']': ] [0/0] {49} - ¦--expr: a[[ - - [2/0] {50} - ¦ ¦--expr: a [0/0] {52} - ¦ ¦ °--SYMBOL: a [0/0] {51} - ¦ ¦--LBB: [[ [0/2] {53} - ¦ ¦--expr: 2 [2/0] {55} - ¦ ¦ °--NUM_CONST: 2 [0/0] {54} - ¦ ¦--']': ] [1/0] {56} - ¦ °--']': ] [0/0] {57} °--expr: a[[ - [2/0] {58} - ¦--expr: a [0/0] {60} - ¦ °--SYMBOL: a [0/0] {59} - ¦--LBB: [[ [0/2] {61} - ¦--expr: 2 [1/0] {63} - ¦ °--NUM_CONST: 2 [0/0] {62} - ¦--']': ] [2/0] {64} - °--']': ] [0/0] {65} + + [3/0] {50} + ¦--expr: a [0/0] {52} + ¦ °--SYMBOL: a [0/0] {51} + ¦--LBB: [[ [0/2] {53} + ¦--COMMENT: # thi [2/2] {54} + ¦--expr: 1 [1/0] {56} + ¦ °--NUM_CONST: 1 [0/0] {55} + ¦--',': , [0/1] {57} + ¦--expr: c( + + [0/0] {58} + ¦ ¦--expr: c [0/0] {60} + ¦ ¦ °--SYMBOL_FUNCTION_CALL: c [0/0] {59} + ¦ ¦--'(': ( [0/4] {61} + ¦ ¦--expr: 1 [2/0] {63} + ¦ ¦ °--NUM_CONST: 1 [0/0] {62} + ¦ ¦--',': , [0/1] {64} + ¦ ¦--expr: 2 [0/4] {66} + ¦ ¦ °--NUM_CONST: 2 [0/0] {65} + ¦ ¦--COMMENT: # nei [2/4] {67} + ¦ °--')': ) [2/0] {68} + ¦--']': ] [3/0] {69} + °--']': ] [0/0] {70} diff --git a/tests/testthat/indention_square_brackets/square_brackets_double_line_break-out.R b/tests/testthat/indention_square_brackets/square_brackets_double_line_break-out.R index a6a371f93..378cb936b 100644 --- a/tests/testthat/indention_square_brackets/square_brackets_double_line_break-out.R +++ b/tests/testthat/indention_square_brackets/square_brackets_double_line_break-out.R @@ -26,10 +26,12 @@ a[[ 2 ]] -a[[ - 2 -]] a[[ - 2 + # this comment shouldn't mess + 1, c( + 1, 2 + + # neither should this one + ) ]] From 0a1c8b6c72409a07ea3cf2db5d26d87d623eb88c Mon Sep 17 00:00:00 2001 From: Indrajeet Patil Date: Wed, 15 May 2024 20:24:57 +0200 Subject: [PATCH 16/20] also add test for mixing `[ `and `(` --- .../square_brackets_line_break-in.R | 16 ++++--- .../square_brackets_line_break-in_tree | 47 ++++++++++--------- .../square_brackets_line_break-out.R | 12 ++--- 3 files changed, 40 insertions(+), 35 deletions(-) diff --git a/tests/testthat/indention_square_brackets/square_brackets_line_break-in.R b/tests/testthat/indention_square_brackets/square_brackets_line_break-in.R index bb0f3aca6..4d42c1ec0 100644 --- a/tests/testthat/indention_square_brackets/square_brackets_line_break-in.R +++ b/tests/testthat/indention_square_brackets/square_brackets_line_break-in.R @@ -63,21 +63,25 @@ x[ ] + x[ a, b -] -x[ - a, - b ] x[ - a, - b + # this comment shouldn't be an issue + 1, c( + + 1, 2 + + # neither should this one + + ) + ] diff --git a/tests/testthat/indention_square_brackets/square_brackets_line_break-in_tree b/tests/testthat/indention_square_brackets/square_brackets_line_break-in_tree index 3ab82d3d9..96fcabd2c 100644 --- a/tests/testthat/indention_square_brackets/square_brackets_line_break-in_tree +++ b/tests/testthat/indention_square_brackets/square_brackets_line_break-in_tree @@ -320,7 +320,7 @@ ROOT (token: short_text [lag_newlines/spaces] {pos_id}) ¦ °--']': ] [3/0] {313} ¦--expr: x[ - [2/0] {314} + [3/0] {314} ¦ ¦--expr: x [0/0] {316} ¦ ¦ °--SYMBOL: x [0/0] {315} ¦ ¦--'[': [ [0/2] {317} @@ -329,27 +329,28 @@ ROOT (token: short_text [lag_newlines/spaces] {pos_id}) ¦ ¦--',': , [0/2] {320} ¦ ¦--expr: b [1/0] {322} ¦ ¦ °--SYMBOL: b [0/0] {321} - ¦ °--']': ] [1/0] {323} - ¦--expr: x[ - [2/0] {324} - ¦ ¦--expr: x [0/0] {326} - ¦ ¦ °--SYMBOL: x [0/0] {325} - ¦ ¦--'[': [ [0/2] {327} - ¦ ¦--expr: a [1/0] {329} - ¦ ¦ °--SYMBOL: a [0/0] {328} - ¦ ¦--',': , [0/2] {330} - ¦ ¦--expr: b [1/0] {332} - ¦ ¦ °--SYMBOL: b [0/0] {331} - ¦ °--']': ] [2/0] {333} + ¦ °--']': ] [3/0] {323} °--expr: x[ - [2/0] {334} - ¦--expr: x [0/0] {336} - ¦ °--SYMBOL: x [0/0] {335} - ¦--'[': [ [0/2] {337} - ¦--expr: a [2/0] {339} - ¦ °--SYMBOL: a [0/0] {338} - ¦--',': , [0/2] {340} - ¦--expr: b [1/0] {342} - ¦ °--SYMBOL: b [0/0] {341} - °--']': ] [2/0] {343} + [2/0] {324} + ¦--expr: x [0/0] {326} + ¦ °--SYMBOL: x [0/0] {325} + ¦--'[': [ [0/2] {327} + ¦--COMMENT: # thi [2/2] {328} + ¦--expr: 1 [1/0] {330} + ¦ °--NUM_CONST: 1 [0/0] {329} + ¦--',': , [0/1] {331} + ¦--expr: c( + + [0/0] {332} + ¦ ¦--expr: c [0/0] {334} + ¦ ¦ °--SYMBOL_FUNCTION_CALL: c [0/0] {333} + ¦ ¦--'(': ( [0/2] {335} + ¦ ¦--expr: 1 [2/0] {337} + ¦ ¦ °--NUM_CONST: 1 [0/0] {336} + ¦ ¦--',': , [0/1] {338} + ¦ ¦--expr: 2 [0/2] {340} + ¦ ¦ °--NUM_CONST: 2 [0/0] {339} + ¦ ¦--COMMENT: # nei [2/2] {341} + ¦ °--')': ) [2/0] {342} + °--']': ] [3/0] {343} diff --git a/tests/testthat/indention_square_brackets/square_brackets_line_break-out.R b/tests/testthat/indention_square_brackets/square_brackets_line_break-out.R index a6534d45a..f888e3398 100644 --- a/tests/testthat/indention_square_brackets/square_brackets_line_break-out.R +++ b/tests/testthat/indention_square_brackets/square_brackets_line_break-out.R @@ -60,10 +60,6 @@ x[ # or below shouldn't be an issue ] -x[ - a, - b -] x[ a, @@ -71,6 +67,10 @@ x[ ] x[ - a, - b + # this comment shouldn't be an issue + 1, c( + 1, 2 + + # neither should this one + ) ] From 8c93aaf98f8b31f026fd7148947bc22ea8b914f5 Mon Sep 17 00:00:00 2001 From: Indrajeet Patil Date: Wed, 15 May 2024 20:57:08 +0200 Subject: [PATCH 17/20] Update pre-commit.yaml --- .github/workflows/pre-commit.yaml | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/.github/workflows/pre-commit.yaml b/.github/workflows/pre-commit.yaml index a47455f05..d9052ab1d 100644 --- a/.github/workflows/pre-commit.yaml +++ b/.github/workflows/pre-commit.yaml @@ -24,11 +24,6 @@ jobs: - uses: actions/checkout@v4 with: fetch-depth: 0 - - name: Install system dependencies - if: runner.os == 'Linux' - run: | - # your system installation code here - # sudo apt-get install -y libcurl4-openssl-dev - name: Set up Python uses: actions/setup-python@v5 with: @@ -36,7 +31,7 @@ jobs: architecture: "x64" - name: Run pre-commit uses: pre-commit/action@v3.0.1 - env: + env: SKIP: pkgdown - name: Commit files if: failure() && startsWith(github.ref, 'refs/heads') From 671f3f41aa0189e6eae6f128c91605d92175c65a Mon Sep 17 00:00:00 2001 From: Indrajeet Patil Date: Wed, 15 May 2024 20:59:34 +0200 Subject: [PATCH 18/20] Update pre-commit.yaml --- .github/workflows/pre-commit.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pre-commit.yaml b/.github/workflows/pre-commit.yaml index d9052ab1d..571edd9c7 100644 --- a/.github/workflows/pre-commit.yaml +++ b/.github/workflows/pre-commit.yaml @@ -27,7 +27,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v5 with: - python-version: "3.9" + python-version: "3.12" architecture: "x64" - name: Run pre-commit uses: pre-commit/action@v3.0.1 From b480577fab04580022017ebd9247c7e11f367dcd Mon Sep 17 00:00:00 2001 From: Indrajeet Patil Date: Wed, 15 May 2024 21:04:21 +0200 Subject: [PATCH 19/20] Revert "Update pre-commit.yaml" This reverts commit 671f3f41aa0189e6eae6f128c91605d92175c65a. --- .github/workflows/pre-commit.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pre-commit.yaml b/.github/workflows/pre-commit.yaml index 571edd9c7..d9052ab1d 100644 --- a/.github/workflows/pre-commit.yaml +++ b/.github/workflows/pre-commit.yaml @@ -27,7 +27,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v5 with: - python-version: "3.12" + python-version: "3.9" architecture: "x64" - name: Run pre-commit uses: pre-commit/action@v3.0.1 From 18bae504e18908dd29e0bbd23546cf5b3f3c4890 Mon Sep 17 00:00:00 2001 From: Indrajeet Patil Date: Wed, 15 May 2024 21:30:28 +0200 Subject: [PATCH 20/20] Update pre-commit.yaml --- .github/workflows/pre-commit.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pre-commit.yaml b/.github/workflows/pre-commit.yaml index d9052ab1d..690143359 100644 --- a/.github/workflows/pre-commit.yaml +++ b/.github/workflows/pre-commit.yaml @@ -25,7 +25,7 @@ jobs: with: fetch-depth: 0 - name: Set up Python - uses: actions/setup-python@v5 + uses: actions/setup-python@v5.1.0 with: python-version: "3.9" architecture: "x64"