From ed9c9677302f5214ece8ee8f55465f0f5ae11e19 Mon Sep 17 00:00:00 2001 From: lorenzwalthert Date: Sun, 14 Apr 2019 23:07:40 +0200 Subject: [PATCH 01/48] add unit tests --- .../while_for_if_without_curly-in.R | 9 - .../while_for_if_without_curly-in_tree | 51 ---- .../while_for_if_without_curly-out.R | 8 - ...while_for_if_without_curly_non_strict-in.R | 61 +++++ ...le_for_if_without_curly_non_strict-in_tree | 251 ++++++++++++++++++ ...hile_for_if_without_curly_non_strict-out.R | 61 +++++ .../while_for_if_without_curly_strict-in.R | 61 +++++ .../while_for_if_without_curly_strict-in_tree | 251 ++++++++++++++++++ .../while_for_if_without_curly_strict-out.R | 75 ++++++ tests/testthat/test-indention_operators.R | 8 +- .../token_adding_removing/double_braces-out.R | 4 +- 11 files changed, 770 insertions(+), 70 deletions(-) delete mode 100644 tests/testthat/indention_operators/while_for_if_without_curly-in.R delete mode 100644 tests/testthat/indention_operators/while_for_if_without_curly-in_tree delete mode 100644 tests/testthat/indention_operators/while_for_if_without_curly-out.R create mode 100644 tests/testthat/indention_operators/while_for_if_without_curly_non_strict-in.R create mode 100644 tests/testthat/indention_operators/while_for_if_without_curly_non_strict-in_tree create mode 100644 tests/testthat/indention_operators/while_for_if_without_curly_non_strict-out.R create mode 100644 tests/testthat/indention_operators/while_for_if_without_curly_strict-in.R create mode 100644 tests/testthat/indention_operators/while_for_if_without_curly_strict-in_tree create mode 100644 tests/testthat/indention_operators/while_for_if_without_curly_strict-out.R diff --git a/tests/testthat/indention_operators/while_for_if_without_curly-in.R b/tests/testthat/indention_operators/while_for_if_without_curly-in.R deleted file mode 100644 index 9e53c11b9..000000000 --- a/tests/testthat/indention_operators/while_for_if_without_curly-in.R +++ /dev/null @@ -1,9 +0,0 @@ -while (x > 3) -return(FALSE) - -for (i in 1:3) -print(i) - -if (x) -call2(3) - diff --git a/tests/testthat/indention_operators/while_for_if_without_curly-in_tree b/tests/testthat/indention_operators/while_for_if_without_curly-in_tree deleted file mode 100644 index bdf79075c..000000000 --- a/tests/testthat/indention_operators/while_for_if_without_curly-in_tree +++ /dev/null @@ -1,51 +0,0 @@ -ROOT (token: short_text [lag_newlines/spaces] {pos_id}) - ¦--expr: [0/0] {1} - ¦ ¦--WHILE: while [0/1] {2} - ¦ ¦--'(': ( [0/0] {3} - ¦ ¦--expr: [0/0] {4} - ¦ ¦ ¦--expr: [0/1] {6} - ¦ ¦ ¦ °--SYMBOL: x [0/0] {5} - ¦ ¦ ¦--GT: > [0/1] {7} - ¦ ¦ °--expr: [0/0] {9} - ¦ ¦ °--NUM_CONST: 3 [0/0] {8} - ¦ ¦--')': ) [0/0] {10} - ¦ °--expr: [1/0] {11} - ¦ ¦--expr: [0/0] {13} - ¦ ¦ °--SYMBOL_FUNCTION_CALL: retur [0/0] {12} - ¦ ¦--'(': ( [0/0] {14} - ¦ ¦--expr: [0/0] {16} - ¦ ¦ °--NUM_CONST: FALSE [0/0] {15} - ¦ °--')': ) [0/0] {17} - ¦--expr: [2/0] {18} - ¦ ¦--FOR: for [0/1] {19} - ¦ ¦--forcond: [0/0] {20} - ¦ ¦ ¦--'(': ( [0/0] {21} - ¦ ¦ ¦--SYMBOL: i [0/1] {22} - ¦ ¦ ¦--IN: in [0/1] {23} - ¦ ¦ ¦--expr: [0/0] {24} - ¦ ¦ ¦ ¦--expr: [0/0] {26} - ¦ ¦ ¦ ¦ °--NUM_CONST: 1 [0/0] {25} - ¦ ¦ ¦ ¦--':': : [0/0] {27} - ¦ ¦ ¦ °--expr: [0/0] {29} - ¦ ¦ ¦ °--NUM_CONST: 3 [0/0] {28} - ¦ ¦ °--')': ) [0/0] {30} - ¦ °--expr: [1/0] {31} - ¦ ¦--expr: [0/0] {33} - ¦ ¦ °--SYMBOL_FUNCTION_CALL: print [0/0] {32} - ¦ ¦--'(': ( [0/0] {34} - ¦ ¦--expr: [0/0] {36} - ¦ ¦ °--SYMBOL: i [0/0] {35} - ¦ °--')': ) [0/0] {37} - °--expr: [2/0] {38} - ¦--IF: if [0/1] {39} - ¦--'(': ( [0/0] {40} - ¦--expr: [0/0] {42} - ¦ °--SYMBOL: x [0/0] {41} - ¦--')': ) [0/0] {43} - °--expr: [1/0] {44} - ¦--expr: [0/0] {46} - ¦ °--SYMBOL_FUNCTION_CALL: call2 [0/0] {45} - ¦--'(': ( [0/0] {47} - ¦--expr: [0/0] {49} - ¦ °--NUM_CONST: 3 [0/0] {48} - °--')': ) [0/0] {50} diff --git a/tests/testthat/indention_operators/while_for_if_without_curly-out.R b/tests/testthat/indention_operators/while_for_if_without_curly-out.R deleted file mode 100644 index b6e06fa83..000000000 --- a/tests/testthat/indention_operators/while_for_if_without_curly-out.R +++ /dev/null @@ -1,8 +0,0 @@ -while (x > 3) - return(FALSE) - -for (i in 1:3) - print(i) - -if (x) - call2(3) diff --git a/tests/testthat/indention_operators/while_for_if_without_curly_non_strict-in.R b/tests/testthat/indention_operators/while_for_if_without_curly_non_strict-in.R new file mode 100644 index 000000000..43f1cd48e --- /dev/null +++ b/tests/testthat/indention_operators/while_for_if_without_curly_non_strict-in.R @@ -0,0 +1,61 @@ +while (x > 3) + return(FALSE) + +for (i in 1:3) + print(i) + +if (x) + call2(3) + +for (i in 1:3) # + print(i) + +for (i in + 1:3) # + print(i) + +for (i in # + 1:3) # + print(i) + +for (# + i in # + 1:3# +) # + print(i) + + +while (x > 3) # + return(FALSE) + +while (x > 3 # +) + return(FALSE) + +while ( # test + x > 3) # another + return(FALSE) + +while ( + 2 > #here + 3 # +) # + FALSE + +while ( + 2 > #here + 3 # +) + FALSE + +while ( + 2 > #here + 3 +) # + FALSE + +while (# + 2 > + 3 +) # + FALSE diff --git a/tests/testthat/indention_operators/while_for_if_without_curly_non_strict-in_tree b/tests/testthat/indention_operators/while_for_if_without_curly_non_strict-in_tree new file mode 100644 index 000000000..3f691a08e --- /dev/null +++ b/tests/testthat/indention_operators/while_for_if_without_curly_non_strict-in_tree @@ -0,0 +1,251 @@ +ROOT (token: short_text [lag_newlines/spaces] {pos_id}) + ¦--expr: [0/0] {1} + ¦ ¦--WHILE: while [0/1] {2} + ¦ ¦--'(': ( [0/0] {3} + ¦ ¦--expr: [0/0] {4} + ¦ ¦ ¦--expr: [0/1] {6} + ¦ ¦ ¦ °--SYMBOL: x [0/0] {5} + ¦ ¦ ¦--GT: > [0/1] {7} + ¦ ¦ °--expr: [0/0] {9} + ¦ ¦ °--NUM_CONST: 3 [0/0] {8} + ¦ ¦--')': ) [0/2] {10} + ¦ °--expr: [1/0] {11} + ¦ ¦--expr: [0/0] {13} + ¦ ¦ °--SYMBOL_FUNCTION_CALL: retur [0/0] {12} + ¦ ¦--'(': ( [0/0] {14} + ¦ ¦--expr: [0/0] {16} + ¦ ¦ °--NUM_CONST: FALSE [0/0] {15} + ¦ °--')': ) [0/0] {17} + ¦--expr: [2/0] {18} + ¦ ¦--FOR: for [0/1] {19} + ¦ ¦--forcond: [0/2] {20} + ¦ ¦ ¦--'(': ( [0/0] {21} + ¦ ¦ ¦--SYMBOL: i [0/1] {22} + ¦ ¦ ¦--IN: in [0/1] {23} + ¦ ¦ ¦--expr: [0/0] {24} + ¦ ¦ ¦ ¦--expr: [0/0] {26} + ¦ ¦ ¦ ¦ °--NUM_CONST: 1 [0/0] {25} + ¦ ¦ ¦ ¦--':': : [0/0] {27} + ¦ ¦ ¦ °--expr: [0/0] {29} + ¦ ¦ ¦ °--NUM_CONST: 3 [0/0] {28} + ¦ ¦ °--')': ) [0/0] {30} + ¦ °--expr: [1/0] {31} + ¦ ¦--expr: [0/0] {33} + ¦ ¦ °--SYMBOL_FUNCTION_CALL: print [0/0] {32} + ¦ ¦--'(': ( [0/0] {34} + ¦ ¦--expr: [0/0] {36} + ¦ ¦ °--SYMBOL: i [0/0] {35} + ¦ °--')': ) [0/0] {37} + ¦--expr: [2/0] {38} + ¦ ¦--IF: if [0/1] {39} + ¦ ¦--'(': ( [0/0] {40} + ¦ ¦--expr: [0/0] {42} + ¦ ¦ °--SYMBOL: x [0/0] {41} + ¦ ¦--')': ) [0/2] {43} + ¦ °--expr: [1/0] {44} + ¦ ¦--expr: [0/0] {46} + ¦ ¦ °--SYMBOL_FUNCTION_CALL: call2 [0/0] {45} + ¦ ¦--'(': ( [0/0] {47} + ¦ ¦--expr: [0/0] {49} + ¦ ¦ °--NUM_CONST: 3 [0/0] {48} + ¦ °--')': ) [0/0] {50} + ¦--expr: [2/0] {51} + ¦ ¦--FOR: for [0/1] {52} + ¦ ¦--forcond: [0/1] {53} + ¦ ¦ ¦--'(': ( [0/0] {54} + ¦ ¦ ¦--SYMBOL: i [0/1] {55} + ¦ ¦ ¦--IN: in [0/1] {56} + ¦ ¦ ¦--expr: [0/0] {57} + ¦ ¦ ¦ ¦--expr: [0/0] {59} + ¦ ¦ ¦ ¦ °--NUM_CONST: 1 [0/0] {58} + ¦ ¦ ¦ ¦--':': : [0/0] {60} + ¦ ¦ ¦ °--expr: [0/0] {62} + ¦ ¦ ¦ °--NUM_CONST: 3 [0/0] {61} + ¦ ¦ °--')': ) [0/0] {63} + ¦ ¦--COMMENT: # [0/2] {64} + ¦ °--expr: [1/0] {65} + ¦ ¦--expr: [0/0] {67} + ¦ ¦ °--SYMBOL_FUNCTION_CALL: print [0/0] {66} + ¦ ¦--'(': ( [0/0] {68} + ¦ ¦--expr: [0/0] {70} + ¦ ¦ °--SYMBOL: i [0/0] {69} + ¦ °--')': ) [0/0] {71} + ¦--expr: [2/0] {72} + ¦ ¦--FOR: for [0/1] {73} + ¦ ¦--forcond: [0/1] {74} + ¦ ¦ ¦--'(': ( [0/0] {75} + ¦ ¦ ¦--SYMBOL: i [0/1] {76} + ¦ ¦ ¦--IN: in [0/5] {77} + ¦ ¦ ¦--expr: [1/0] {78} + ¦ ¦ ¦ ¦--expr: [0/0] {80} + ¦ ¦ ¦ ¦ °--NUM_CONST: 1 [0/0] {79} + ¦ ¦ ¦ ¦--':': : [0/0] {81} + ¦ ¦ ¦ °--expr: [0/0] {83} + ¦ ¦ ¦ °--NUM_CONST: 3 [0/0] {82} + ¦ ¦ °--')': ) [0/0] {84} + ¦ ¦--COMMENT: # [0/2] {85} + ¦ °--expr: [1/0] {86} + ¦ ¦--expr: [0/0] {88} + ¦ ¦ °--SYMBOL_FUNCTION_CALL: print [0/0] {87} + ¦ ¦--'(': ( [0/0] {89} + ¦ ¦--expr: [0/0] {91} + ¦ ¦ °--SYMBOL: i [0/0] {90} + ¦ °--')': ) [0/0] {92} + ¦--expr: [2/0] {93} + ¦ ¦--FOR: for [0/1] {94} + ¦ ¦--forcond: [0/1] {95} + ¦ ¦ ¦--'(': ( [0/0] {96} + ¦ ¦ ¦--SYMBOL: i [0/1] {97} + ¦ ¦ ¦--IN: in [0/1] {98} + ¦ ¦ ¦--COMMENT: # [0/5] {99} + ¦ ¦ ¦--expr: [1/0] {100} + ¦ ¦ ¦ ¦--expr: [0/0] {102} + ¦ ¦ ¦ ¦ °--NUM_CONST: 1 [0/0] {101} + ¦ ¦ ¦ ¦--':': : [0/0] {103} + ¦ ¦ ¦ °--expr: [0/0] {105} + ¦ ¦ ¦ °--NUM_CONST: 3 [0/0] {104} + ¦ ¦ °--')': ) [0/0] {106} + ¦ ¦--COMMENT: # [0/2] {107} + ¦ °--expr: [1/0] {108} + ¦ ¦--expr: [0/0] {110} + ¦ ¦ °--SYMBOL_FUNCTION_CALL: print [0/0] {109} + ¦ ¦--'(': ( [0/0] {111} + ¦ ¦--expr: [0/0] {113} + ¦ ¦ °--SYMBOL: i [0/0] {112} + ¦ °--')': ) [0/0] {114} + ¦--expr: [2/0] {115} + ¦ ¦--FOR: for [0/1] {116} + ¦ ¦--forcond: [0/1] {117} + ¦ ¦ ¦--'(': ( [0/0] {118} + ¦ ¦ ¦--COMMENT: # [0/2] {119} + ¦ ¦ ¦--SYMBOL: i [1/1] {120} + ¦ ¦ ¦--IN: in [0/1] {121} + ¦ ¦ ¦--COMMENT: # [0/2] {122} + ¦ ¦ ¦--expr: [1/0] {123} + ¦ ¦ ¦ ¦--expr: [0/0] {125} + ¦ ¦ ¦ ¦ °--NUM_CONST: 1 [0/0] {124} + ¦ ¦ ¦ ¦--':': : [0/0] {126} + ¦ ¦ ¦ °--expr: [0/0] {128} + ¦ ¦ ¦ °--NUM_CONST: 3 [0/0] {127} + ¦ ¦ ¦--COMMENT: # [0/0] {129} + ¦ ¦ °--')': ) [1/0] {130} + ¦ ¦--COMMENT: # [0/2] {131} + ¦ °--expr: [1/0] {132} + ¦ ¦--expr: [0/0] {134} + ¦ ¦ °--SYMBOL_FUNCTION_CALL: print [0/0] {133} + ¦ ¦--'(': ( [0/0] {135} + ¦ ¦--expr: [0/0] {137} + ¦ ¦ °--SYMBOL: i [0/0] {136} + ¦ °--')': ) [0/0] {138} + ¦--expr: [3/0] {139} + ¦ ¦--WHILE: while [0/1] {140} + ¦ ¦--'(': ( [0/0] {141} + ¦ ¦--expr: [0/0] {142} + ¦ ¦ ¦--expr: [0/1] {144} + ¦ ¦ ¦ °--SYMBOL: x [0/0] {143} + ¦ ¦ ¦--GT: > [0/1] {145} + ¦ ¦ °--expr: [0/0] {147} + ¦ ¦ °--NUM_CONST: 3 [0/0] {146} + ¦ ¦--')': ) [0/1] {148} + ¦ ¦--COMMENT: # [0/2] {149} + ¦ °--expr: [1/0] {150} + ¦ ¦--expr: [0/0] {152} + ¦ ¦ °--SYMBOL_FUNCTION_CALL: retur [0/0] {151} + ¦ ¦--'(': ( [0/0] {153} + ¦ ¦--expr: [0/0] {155} + ¦ ¦ °--NUM_CONST: FALSE [0/0] {154} + ¦ °--')': ) [0/0] {156} + ¦--expr: [2/0] {157} + ¦ ¦--WHILE: while [0/1] {158} + ¦ ¦--'(': ( [0/0] {159} + ¦ ¦--expr: [0/1] {160} + ¦ ¦ ¦--expr: [0/1] {162} + ¦ ¦ ¦ °--SYMBOL: x [0/0] {161} + ¦ ¦ ¦--GT: > [0/1] {163} + ¦ ¦ °--expr: [0/0] {165} + ¦ ¦ °--NUM_CONST: 3 [0/0] {164} + ¦ ¦--COMMENT: # [0/0] {166} + ¦ ¦--')': ) [1/2] {167} + ¦ °--expr: [1/0] {168} + ¦ ¦--expr: [0/0] {170} + ¦ ¦ °--SYMBOL_FUNCTION_CALL: retur [0/0] {169} + ¦ ¦--'(': ( [0/0] {171} + ¦ ¦--expr: [0/0] {173} + ¦ ¦ °--NUM_CONST: FALSE [0/0] {172} + ¦ °--')': ) [0/0] {174} + ¦--expr: [2/0] {175} + ¦ ¦--WHILE: while [0/1] {176} + ¦ ¦--'(': ( [0/1] {177} + ¦ ¦--COMMENT: # tes [0/2] {178} + ¦ ¦--expr: [1/0] {179} + ¦ ¦ ¦--expr: [0/1] {181} + ¦ ¦ ¦ °--SYMBOL: x [0/0] {180} + ¦ ¦ ¦--GT: > [0/1] {182} + ¦ ¦ °--expr: [0/0] {184} + ¦ ¦ °--NUM_CONST: 3 [0/0] {183} + ¦ ¦--')': ) [0/1] {185} + ¦ ¦--COMMENT: # ano [0/2] {186} + ¦ °--expr: [1/0] {187} + ¦ ¦--expr: [0/0] {189} + ¦ ¦ °--SYMBOL_FUNCTION_CALL: retur [0/0] {188} + ¦ ¦--'(': ( [0/0] {190} + ¦ ¦--expr: [0/0] {192} + ¦ ¦ °--NUM_CONST: FALSE [0/0] {191} + ¦ °--')': ) [0/0] {193} + ¦--expr: [2/0] {194} + ¦ ¦--WHILE: while [0/1] {195} + ¦ ¦--'(': ( [0/2] {196} + ¦ ¦--expr: [1/1] {197} + ¦ ¦ ¦--expr: [0/1] {199} + ¦ ¦ ¦ °--NUM_CONST: 2 [0/0] {198} + ¦ ¦ ¦--GT: > [0/1] {200} + ¦ ¦ ¦--COMMENT: #here [0/2] {201} + ¦ ¦ °--expr: [1/0] {203} + ¦ ¦ °--NUM_CONST: 3 [0/0] {202} + ¦ ¦--COMMENT: # [0/0] {204} + ¦ ¦--')': ) [1/1] {205} + ¦ ¦--COMMENT: # [0/2] {206} + ¦ °--expr: [1/0] {208} + ¦ °--NUM_CONST: FALSE [0/0] {207} + ¦--expr: [2/0] {209} + ¦ ¦--WHILE: while [0/1] {210} + ¦ ¦--'(': ( [0/2] {211} + ¦ ¦--expr: [1/1] {212} + ¦ ¦ ¦--expr: [0/1] {214} + ¦ ¦ ¦ °--NUM_CONST: 2 [0/0] {213} + ¦ ¦ ¦--GT: > [0/1] {215} + ¦ ¦ ¦--COMMENT: #here [0/2] {216} + ¦ ¦ °--expr: [1/0] {218} + ¦ ¦ °--NUM_CONST: 3 [0/0] {217} + ¦ ¦--COMMENT: # [0/0] {219} + ¦ ¦--')': ) [1/2] {220} + ¦ °--expr: [1/0] {222} + ¦ °--NUM_CONST: FALSE [0/0] {221} + ¦--expr: [2/0] {223} + ¦ ¦--WHILE: while [0/1] {224} + ¦ ¦--'(': ( [0/2] {225} + ¦ ¦--expr: [1/0] {226} + ¦ ¦ ¦--expr: [0/1] {228} + ¦ ¦ ¦ °--NUM_CONST: 2 [0/0] {227} + ¦ ¦ ¦--GT: > [0/1] {229} + ¦ ¦ ¦--COMMENT: #here [0/2] {230} + ¦ ¦ °--expr: [1/0] {232} + ¦ ¦ °--NUM_CONST: 3 [0/0] {231} + ¦ ¦--')': ) [1/1] {233} + ¦ ¦--COMMENT: # [0/2] {234} + ¦ °--expr: [1/0] {236} + ¦ °--NUM_CONST: FALSE [0/0] {235} + °--expr: [2/0] {237} + ¦--WHILE: while [0/1] {238} + ¦--'(': ( [0/0] {239} + ¦--COMMENT: # [0/2] {240} + ¦--expr: [1/0] {241} + ¦ ¦--expr: [0/1] {243} + ¦ ¦ °--NUM_CONST: 2 [0/0] {242} + ¦ ¦--GT: > [0/2] {244} + ¦ °--expr: [1/0] {246} + ¦ °--NUM_CONST: 3 [0/0] {245} + ¦--')': ) [1/1] {247} + ¦--COMMENT: # [0/2] {248} + °--expr: [1/0] {250} + °--NUM_CONST: FALSE [0/0] {249} diff --git a/tests/testthat/indention_operators/while_for_if_without_curly_non_strict-out.R b/tests/testthat/indention_operators/while_for_if_without_curly_non_strict-out.R new file mode 100644 index 000000000..00490d0db --- /dev/null +++ b/tests/testthat/indention_operators/while_for_if_without_curly_non_strict-out.R @@ -0,0 +1,61 @@ +while (x > 3) + return(FALSE) + +for (i in 1:3) + print(i) + +if (x) + call2(3) + +for (i in 1:3) # + print(i) + +for (i in + 1:3) # + print(i) + +for (i in # + 1:3) # + print(i) + +for ( # + i in # + 1:3 # +) # + print(i) + + +while (x > 3) # + return(FALSE) + +while (x > 3 # +) + return(FALSE) + +while ( # test + x > 3) # another + return(FALSE) + +while ( + 2 > # here + 3 # +) # + FALSE + +while ( + 2 > # here + 3 # +) + FALSE + +while ( + 2 > # here + 3 +) # + FALSE + +while ( # + 2 > + 3 +) # + FALSE diff --git a/tests/testthat/indention_operators/while_for_if_without_curly_strict-in.R b/tests/testthat/indention_operators/while_for_if_without_curly_strict-in.R new file mode 100644 index 000000000..3bda095e9 --- /dev/null +++ b/tests/testthat/indention_operators/while_for_if_without_curly_strict-in.R @@ -0,0 +1,61 @@ +while (x > 3) +return(FALSE) + +for (i in 1:3) +print(i) + +if (x) +call2(3) + +for (i in 1:3) # + print(i) + +for (i in + 1:3) # + print(i) + +for (i in # + 1:3) # + print(i) + +for (# + i in # + 1:3# + ) # + print(i) + + +while (x > 3) # + return(FALSE) + +while (x > 3 # + ) + return(FALSE) + +while ( # test + x > 3) # another + return(FALSE) + +while ( + 2 > #here + 3 # + ) # + FALSE + +while ( + 2 > #here + 3 # +) + FALSE + +while ( + 2 > #here + 3 +) # + FALSE + +while (# + 2 > + 3 +) # + FALSE diff --git a/tests/testthat/indention_operators/while_for_if_without_curly_strict-in_tree b/tests/testthat/indention_operators/while_for_if_without_curly_strict-in_tree new file mode 100644 index 000000000..6cb3cfc8d --- /dev/null +++ b/tests/testthat/indention_operators/while_for_if_without_curly_strict-in_tree @@ -0,0 +1,251 @@ +ROOT (token: short_text [lag_newlines/spaces] {pos_id}) + ¦--expr: [0/0] {1} + ¦ ¦--WHILE: while [0/1] {2} + ¦ ¦--'(': ( [0/0] {3} + ¦ ¦--expr: [0/0] {4} + ¦ ¦ ¦--expr: [0/1] {6} + ¦ ¦ ¦ °--SYMBOL: x [0/0] {5} + ¦ ¦ ¦--GT: > [0/1] {7} + ¦ ¦ °--expr: [0/0] {9} + ¦ ¦ °--NUM_CONST: 3 [0/0] {8} + ¦ ¦--')': ) [0/0] {10} + ¦ °--expr: [1/0] {11} + ¦ ¦--expr: [0/0] {13} + ¦ ¦ °--SYMBOL_FUNCTION_CALL: retur [0/0] {12} + ¦ ¦--'(': ( [0/0] {14} + ¦ ¦--expr: [0/0] {16} + ¦ ¦ °--NUM_CONST: FALSE [0/0] {15} + ¦ °--')': ) [0/0] {17} + ¦--expr: [2/0] {18} + ¦ ¦--FOR: for [0/1] {19} + ¦ ¦--forcond: [0/0] {20} + ¦ ¦ ¦--'(': ( [0/0] {21} + ¦ ¦ ¦--SYMBOL: i [0/1] {22} + ¦ ¦ ¦--IN: in [0/1] {23} + ¦ ¦ ¦--expr: [0/0] {24} + ¦ ¦ ¦ ¦--expr: [0/0] {26} + ¦ ¦ ¦ ¦ °--NUM_CONST: 1 [0/0] {25} + ¦ ¦ ¦ ¦--':': : [0/0] {27} + ¦ ¦ ¦ °--expr: [0/0] {29} + ¦ ¦ ¦ °--NUM_CONST: 3 [0/0] {28} + ¦ ¦ °--')': ) [0/0] {30} + ¦ °--expr: [1/0] {31} + ¦ ¦--expr: [0/0] {33} + ¦ ¦ °--SYMBOL_FUNCTION_CALL: print [0/0] {32} + ¦ ¦--'(': ( [0/0] {34} + ¦ ¦--expr: [0/0] {36} + ¦ ¦ °--SYMBOL: i [0/0] {35} + ¦ °--')': ) [0/0] {37} + ¦--expr: [2/0] {38} + ¦ ¦--IF: if [0/1] {39} + ¦ ¦--'(': ( [0/0] {40} + ¦ ¦--expr: [0/0] {42} + ¦ ¦ °--SYMBOL: x [0/0] {41} + ¦ ¦--')': ) [0/0] {43} + ¦ °--expr: [1/0] {44} + ¦ ¦--expr: [0/0] {46} + ¦ ¦ °--SYMBOL_FUNCTION_CALL: call2 [0/0] {45} + ¦ ¦--'(': ( [0/0] {47} + ¦ ¦--expr: [0/0] {49} + ¦ ¦ °--NUM_CONST: 3 [0/0] {48} + ¦ °--')': ) [0/0] {50} + ¦--expr: [2/0] {51} + ¦ ¦--FOR: for [0/1] {52} + ¦ ¦--forcond: [0/1] {53} + ¦ ¦ ¦--'(': ( [0/0] {54} + ¦ ¦ ¦--SYMBOL: i [0/1] {55} + ¦ ¦ ¦--IN: in [0/1] {56} + ¦ ¦ ¦--expr: [0/0] {57} + ¦ ¦ ¦ ¦--expr: [0/0] {59} + ¦ ¦ ¦ ¦ °--NUM_CONST: 1 [0/0] {58} + ¦ ¦ ¦ ¦--':': : [0/0] {60} + ¦ ¦ ¦ °--expr: [0/0] {62} + ¦ ¦ ¦ °--NUM_CONST: 3 [0/0] {61} + ¦ ¦ °--')': ) [0/0] {63} + ¦ ¦--COMMENT: # [0/2] {64} + ¦ °--expr: [1/0] {65} + ¦ ¦--expr: [0/0] {67} + ¦ ¦ °--SYMBOL_FUNCTION_CALL: print [0/0] {66} + ¦ ¦--'(': ( [0/0] {68} + ¦ ¦--expr: [0/0] {70} + ¦ ¦ °--SYMBOL: i [0/0] {69} + ¦ °--')': ) [0/0] {71} + ¦--expr: [2/0] {72} + ¦ ¦--FOR: for [0/1] {73} + ¦ ¦--forcond: [0/1] {74} + ¦ ¦ ¦--'(': ( [0/0] {75} + ¦ ¦ ¦--SYMBOL: i [0/1] {76} + ¦ ¦ ¦--IN: in [0/5] {77} + ¦ ¦ ¦--expr: [1/0] {78} + ¦ ¦ ¦ ¦--expr: [0/0] {80} + ¦ ¦ ¦ ¦ °--NUM_CONST: 1 [0/0] {79} + ¦ ¦ ¦ ¦--':': : [0/0] {81} + ¦ ¦ ¦ °--expr: [0/0] {83} + ¦ ¦ ¦ °--NUM_CONST: 3 [0/0] {82} + ¦ ¦ °--')': ) [0/0] {84} + ¦ ¦--COMMENT: # [0/2] {85} + ¦ °--expr: [1/0] {86} + ¦ ¦--expr: [0/0] {88} + ¦ ¦ °--SYMBOL_FUNCTION_CALL: print [0/0] {87} + ¦ ¦--'(': ( [0/0] {89} + ¦ ¦--expr: [0/0] {91} + ¦ ¦ °--SYMBOL: i [0/0] {90} + ¦ °--')': ) [0/0] {92} + ¦--expr: [2/0] {93} + ¦ ¦--FOR: for [0/1] {94} + ¦ ¦--forcond: [0/1] {95} + ¦ ¦ ¦--'(': ( [0/0] {96} + ¦ ¦ ¦--SYMBOL: i [0/1] {97} + ¦ ¦ ¦--IN: in [0/1] {98} + ¦ ¦ ¦--COMMENT: # [0/5] {99} + ¦ ¦ ¦--expr: [1/0] {100} + ¦ ¦ ¦ ¦--expr: [0/0] {102} + ¦ ¦ ¦ ¦ °--NUM_CONST: 1 [0/0] {101} + ¦ ¦ ¦ ¦--':': : [0/0] {103} + ¦ ¦ ¦ °--expr: [0/0] {105} + ¦ ¦ ¦ °--NUM_CONST: 3 [0/0] {104} + ¦ ¦ °--')': ) [0/0] {106} + ¦ ¦--COMMENT: # [0/2] {107} + ¦ °--expr: [1/0] {108} + ¦ ¦--expr: [0/0] {110} + ¦ ¦ °--SYMBOL_FUNCTION_CALL: print [0/0] {109} + ¦ ¦--'(': ( [0/0] {111} + ¦ ¦--expr: [0/0] {113} + ¦ ¦ °--SYMBOL: i [0/0] {112} + ¦ °--')': ) [0/0] {114} + ¦--expr: [2/0] {115} + ¦ ¦--FOR: for [0/1] {116} + ¦ ¦--forcond: [0/1] {117} + ¦ ¦ ¦--'(': ( [0/0] {118} + ¦ ¦ ¦--COMMENT: # [0/2] {119} + ¦ ¦ ¦--SYMBOL: i [1/1] {120} + ¦ ¦ ¦--IN: in [0/1] {121} + ¦ ¦ ¦--COMMENT: # [0/5] {122} + ¦ ¦ ¦--expr: [1/0] {123} + ¦ ¦ ¦ ¦--expr: [0/0] {125} + ¦ ¦ ¦ ¦ °--NUM_CONST: 1 [0/0] {124} + ¦ ¦ ¦ ¦--':': : [0/0] {126} + ¦ ¦ ¦ °--expr: [0/0] {128} + ¦ ¦ ¦ °--NUM_CONST: 3 [0/0] {127} + ¦ ¦ ¦--COMMENT: # [0/2] {129} + ¦ ¦ °--')': ) [1/0] {130} + ¦ ¦--COMMENT: # [0/2] {131} + ¦ °--expr: [1/0] {132} + ¦ ¦--expr: [0/0] {134} + ¦ ¦ °--SYMBOL_FUNCTION_CALL: print [0/0] {133} + ¦ ¦--'(': ( [0/0] {135} + ¦ ¦--expr: [0/0] {137} + ¦ ¦ °--SYMBOL: i [0/0] {136} + ¦ °--')': ) [0/0] {138} + ¦--expr: [3/0] {139} + ¦ ¦--WHILE: while [0/1] {140} + ¦ ¦--'(': ( [0/0] {141} + ¦ ¦--expr: [0/0] {142} + ¦ ¦ ¦--expr: [0/1] {144} + ¦ ¦ ¦ °--SYMBOL: x [0/0] {143} + ¦ ¦ ¦--GT: > [0/1] {145} + ¦ ¦ °--expr: [0/0] {147} + ¦ ¦ °--NUM_CONST: 3 [0/0] {146} + ¦ ¦--')': ) [0/1] {148} + ¦ ¦--COMMENT: # [0/2] {149} + ¦ °--expr: [1/0] {150} + ¦ ¦--expr: [0/0] {152} + ¦ ¦ °--SYMBOL_FUNCTION_CALL: retur [0/0] {151} + ¦ ¦--'(': ( [0/0] {153} + ¦ ¦--expr: [0/0] {155} + ¦ ¦ °--NUM_CONST: FALSE [0/0] {154} + ¦ °--')': ) [0/0] {156} + ¦--expr: [2/0] {157} + ¦ ¦--WHILE: while [0/1] {158} + ¦ ¦--'(': ( [0/0] {159} + ¦ ¦--expr: [0/1] {160} + ¦ ¦ ¦--expr: [0/1] {162} + ¦ ¦ ¦ °--SYMBOL: x [0/0] {161} + ¦ ¦ ¦--GT: > [0/1] {163} + ¦ ¦ °--expr: [0/0] {165} + ¦ ¦ °--NUM_CONST: 3 [0/0] {164} + ¦ ¦--COMMENT: # [0/7] {166} + ¦ ¦--')': ) [1/2] {167} + ¦ °--expr: [1/0] {168} + ¦ ¦--expr: [0/0] {170} + ¦ ¦ °--SYMBOL_FUNCTION_CALL: retur [0/0] {169} + ¦ ¦--'(': ( [0/0] {171} + ¦ ¦--expr: [0/0] {173} + ¦ ¦ °--NUM_CONST: FALSE [0/0] {172} + ¦ °--')': ) [0/0] {174} + ¦--expr: [2/0] {175} + ¦ ¦--WHILE: while [0/1] {176} + ¦ ¦--'(': ( [0/1] {177} + ¦ ¦--COMMENT: # tes [0/2] {178} + ¦ ¦--expr: [1/0] {179} + ¦ ¦ ¦--expr: [0/1] {181} + ¦ ¦ ¦ °--SYMBOL: x [0/0] {180} + ¦ ¦ ¦--GT: > [0/1] {182} + ¦ ¦ °--expr: [0/0] {184} + ¦ ¦ °--NUM_CONST: 3 [0/0] {183} + ¦ ¦--')': ) [0/1] {185} + ¦ ¦--COMMENT: # ano [0/2] {186} + ¦ °--expr: [1/0] {187} + ¦ ¦--expr: [0/0] {189} + ¦ ¦ °--SYMBOL_FUNCTION_CALL: retur [0/0] {188} + ¦ ¦--'(': ( [0/0] {190} + ¦ ¦--expr: [0/0] {192} + ¦ ¦ °--NUM_CONST: FALSE [0/0] {191} + ¦ °--')': ) [0/0] {193} + ¦--expr: [2/0] {194} + ¦ ¦--WHILE: while [0/1] {195} + ¦ ¦--'(': ( [0/2] {196} + ¦ ¦--expr: [1/1] {197} + ¦ ¦ ¦--expr: [0/1] {199} + ¦ ¦ ¦ °--NUM_CONST: 2 [0/0] {198} + ¦ ¦ ¦--GT: > [0/1] {200} + ¦ ¦ ¦--COMMENT: #here [0/2] {201} + ¦ ¦ °--expr: [1/0] {203} + ¦ ¦ °--NUM_CONST: 3 [0/0] {202} + ¦ ¦--COMMENT: # [0/2] {204} + ¦ ¦--')': ) [1/1] {205} + ¦ ¦--COMMENT: # [0/2] {206} + ¦ °--expr: [1/0] {208} + ¦ °--NUM_CONST: FALSE [0/0] {207} + ¦--expr: [2/0] {209} + ¦ ¦--WHILE: while [0/1] {210} + ¦ ¦--'(': ( [0/2] {211} + ¦ ¦--expr: [1/1] {212} + ¦ ¦ ¦--expr: [0/1] {214} + ¦ ¦ ¦ °--NUM_CONST: 2 [0/0] {213} + ¦ ¦ ¦--GT: > [0/1] {215} + ¦ ¦ ¦--COMMENT: #here [0/2] {216} + ¦ ¦ °--expr: [1/0] {218} + ¦ ¦ °--NUM_CONST: 3 [0/0] {217} + ¦ ¦--COMMENT: # [0/0] {219} + ¦ ¦--')': ) [1/2] {220} + ¦ °--expr: [1/0] {222} + ¦ °--NUM_CONST: FALSE [0/0] {221} + ¦--expr: [2/0] {223} + ¦ ¦--WHILE: while [0/1] {224} + ¦ ¦--'(': ( [0/2] {225} + ¦ ¦--expr: [1/0] {226} + ¦ ¦ ¦--expr: [0/1] {228} + ¦ ¦ ¦ °--NUM_CONST: 2 [0/0] {227} + ¦ ¦ ¦--GT: > [0/1] {229} + ¦ ¦ ¦--COMMENT: #here [0/2] {230} + ¦ ¦ °--expr: [1/0] {232} + ¦ ¦ °--NUM_CONST: 3 [0/0] {231} + ¦ ¦--')': ) [1/1] {233} + ¦ ¦--COMMENT: # [0/2] {234} + ¦ °--expr: [1/0] {236} + ¦ °--NUM_CONST: FALSE [0/0] {235} + °--expr: [2/0] {237} + ¦--WHILE: while [0/1] {238} + ¦--'(': ( [0/0] {239} + ¦--COMMENT: # [0/2] {240} + ¦--expr: [1/0] {241} + ¦ ¦--expr: [0/1] {243} + ¦ ¦ °--NUM_CONST: 2 [0/0] {242} + ¦ ¦--GT: > [0/2] {244} + ¦ °--expr: [1/0] {246} + ¦ °--NUM_CONST: 3 [0/0] {245} + ¦--')': ) [1/1] {247} + ¦--COMMENT: # [0/2] {248} + °--expr: [1/0] {250} + °--NUM_CONST: FALSE [0/0] {249} diff --git a/tests/testthat/indention_operators/while_for_if_without_curly_strict-out.R b/tests/testthat/indention_operators/while_for_if_without_curly_strict-out.R new file mode 100644 index 000000000..e759975fc --- /dev/null +++ b/tests/testthat/indention_operators/while_for_if_without_curly_strict-out.R @@ -0,0 +1,75 @@ +while (x > 3) { + return(FALSE) +} + +for (i in 1:3) { + print(i) +} + +if (x) { + call2(3) +} + +for (i in 1:3) { # + print(i) +} + +for (i in + 1:3) { # + print(i) +} + +for (i in # + 1:3) { # + print(i) +} + +for ( # + i in # + 1:3 # +) { # + print(i) +} + + +while (x > 3) { # + return(FALSE) +} + +while (x > 3 # +) { + return(FALSE) +} + +while ( # test + x > 3) { # another + return(FALSE) +} + +while ( + 2 > # here + 3 # +) { # + FALSE +} + +while ( + 2 > # here + 3 # +) { + FALSE +} + +while ( + 2 > # here + 3 +) { # + FALSE +} + +while ( # + 2 > + 3 +) { # + FALSE +} diff --git a/tests/testthat/test-indention_operators.R b/tests/testthat/test-indention_operators.R index 13498eb4a..f245eeed2 100644 --- a/tests/testthat/test-indention_operators.R +++ b/tests/testthat/test-indention_operators.R @@ -20,10 +20,16 @@ test_that("mathematical operators are indended correctly", { test_that("while / for / if without curly brackets", { expect_warning(test_collection("indention_operators", - "while_for_if_without_curly", + "while_for_if_without_curly_non_strict", transformer = style_text, strict = FALSE), NA) }) +test_that("while / for / if without curly brackets", { + expect_warning(test_collection("indention_operators", + "while_for_if_without_curly_strict", + transformer = style_text, strict = TRUE), NA) +}) + test_that("nested for and indention", { expect_warning(test_collection("indention_operators", diff --git a/tests/testthat/token_adding_removing/double_braces-out.R b/tests/testthat/token_adding_removing/double_braces-out.R index 2bba0cc21..4df1c6536 100644 --- a/tests/testthat/token_adding_removing/double_braces-out.R +++ b/tests/testthat/token_adding_removing/double_braces-out.R @@ -2,4 +2,6 @@ if (X) { return(TRUE) } -if (X) return(FALSE) +if (X) { + return(FALSE) +} From 9360ae88fdf8dcb9132d186520f5e694be93b2d2 Mon Sep 17 00:00:00 2001 From: lorenzwalthert Date: Sun, 14 Apr 2019 23:31:52 +0200 Subject: [PATCH 02/48] document expr-is functions --- R/expr-is.R | 61 ++++++++++++++++++++++++++++---------------- man/next_terminal.Rd | 25 ++++++++++++++++++ 2 files changed, 64 insertions(+), 22 deletions(-) create mode 100644 man/next_terminal.Rd diff --git a/R/expr-is.R b/R/expr-is.R index 75eeca1e6..8a56abf53 100644 --- a/R/expr-is.R +++ b/R/expr-is.R @@ -13,6 +13,45 @@ is_curly_expr <- function(pd) { pd$token[1] == "'{'" } +is_for_expr <- function(pd) { + pd$token[1] == "FOR" +} + +#' @describeIn pd_is Checks whether `pd` contains is a conditional expression. +#' @keywords internal +is_cond_expr <- function(pd) { + pd$token[1] == "IF" +} + +#' @describeIn pd_is Checks whether `pd` contains is a while loop. +#' @keywords internal +is_while_expr <- function(pd) { + pd$token[1] == "WHILE" +} + +#' @describeIn pd_is Checks whether `pd` is a function call. +#' @keywords internal +is_function_call <- function(pd) { + if (is.null(pd)) return(FALSE) + if (is.na(pd$token_before[2])) return(FALSE) + pd$token_before[2] == "SYMBOL_FUNCTION_CALL" +} + +#' @describeIn pd_is Checks whether `pd` is a function declaration. +#' @keywords internal +is_function_dec <- function(pd) { + if (is.null(pd)) return(FALSE) + pd$token[1] == "FUNCTION" +} + +#' @describeIn pd_is Checks for every token whether or not it is a comment. +#' @keywords internal +is_comment <- function(pd) { + if (is.null(pd)) return(FALSE) + pd$token == "COMMENT" +} + + #' Check whether a parse table contains a tilde #' @@ -46,25 +85,6 @@ is_subset_expr <- function(pd) { pd$token[2] == "'['" } -#' @describeIn pd_is Checks whether `pd` is a function call. -#' @keywords internal -is_function_call <- function(pd) { - if (is.null(pd)) return(FALSE) - if (is.na(pd$token_before[2])) return(FALSE) - pd$token_before[2] == "SYMBOL_FUNCTION_CALL" -} - -#' @describeIn pd_is Checks whether `pd` is a function declaration. -#' @keywords internal -is_function_dec <- function(pd) { - if (is.null(pd)) return(FALSE) - pd$token[1] == "FUNCTION" -} - -is_comment <- function(pd) { - if (is.null(pd)) return(FALSE) - pd$token == "COMMENT" -} #' Identify comments that are shebangs #' @@ -129,6 +149,3 @@ contains_else_expr_that_needs_braces <- function(pd) { } } -is_cond_expr <- function(pd) { - pd$token[1] == "IF" -} diff --git a/man/next_terminal.Rd b/man/next_terminal.Rd new file mode 100644 index 000000000..e53e92cc7 --- /dev/null +++ b/man/next_terminal.Rd @@ -0,0 +1,25 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/utils.R +\name{next_terminal} +\alias{next_terminal} +\title{If the first is a terminal, return it. If not, go inside it and search the +next terminal} +\usage{ +next_terminal(pd, stack = FALSE, vars = c("pos_id", "token", "text"), + exclude_tokens = list()) +} +\arguments{ +\item{pd}{A nest.} + +\item{stack}{Whether or not to stack non-terminals. The order is inside-out, +i.e. the first non-terminal on top, the terminal last.} +} +\description{ +If the first is a terminal, return it. If not, go inside it and search the +next terminal +} +\examples{ +pd <- compute_parse_data_nested("if (TRUE) f()") +styler::next_terminal(pd) +} +\keyword{internal} From 3bae4bbdce4681e2f2a84f686eb5da308fab6e40 Mon Sep 17 00:00:00 2001 From: lorenzwalthert Date: Sun, 14 Apr 2019 23:32:37 +0200 Subject: [PATCH 03/48] API change (not really): renaming in tidyverse stylde guide: wrap_if_else_multi_line_in_curly -> wrap_if_else_while_for_multi_line_in_curly --- R/style-guides.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/R/style-guides.R b/R/style-guides.R index 075452ded..89980ff83 100644 --- a/R/style-guides.R +++ b/R/style-guides.R @@ -152,8 +152,8 @@ tidyverse_style <- function(scope = "tokens", resolve_semicolon, add_brackets_in_pipe, remove_terminal_token_before_and_after, - wrap_if_else_multi_line_in_curly = - if (strict) wrap_if_else_multi_line_in_curly + wrap_if_else_while_for_multi_line_in_curly = + if (strict) wrap_if_else_while_for_multi_line_in_curly ) } From 511f7a0d599f184707570bee4ac6cc0dfa962e18 Mon Sep 17 00:00:00 2001 From: lorenzwalthert Date: Mon, 15 Apr 2019 00:14:33 +0200 Subject: [PATCH 04/48] implement next_terminal(), used to check if next terminal is return statement --- R/utils.R | 41 +++++++++++++++++++++++++++++++++++++++++ man/next_terminal.Rd | 22 ++++++++++++++++++---- 2 files changed, 59 insertions(+), 4 deletions(-) diff --git a/R/utils.R b/R/utils.R index 788d2af3e..12344afb4 100644 --- a/R/utils.R +++ b/R/utils.R @@ -121,6 +121,47 @@ previous_non_comment <- function(pd, pos) { last(setdiff(candidates, which(pd$token == "COMMENT"))) } +#' Tell me what the next terminal is +#' +#' If the first is a terminal, return it. If not, go inside it and search the +#' next terminal +#' @param pd A nest. +#' @param stack Whether or not to also return information on the tokens that +#' are between `pd` and the first terminal, so the returned tibble can be +#' understood as a transition path from `pd` to the next terminal, instead of +#' the information at the terminal only. The order is inside-out, +#' i.e. the first non-terminal on top, the terminal last. +#' @param vars The variables to return. +#' @param tokens_exclude A vector with tokens to exclude. This can be helpful if +#' one wants to find the next token that is not a comment for example. +#' @return +#' Returns a tibble (which is **not** a valid parse table for +#' `stack = TRUE`), with `vars` and another variable `position` that denotes +#' the index each element in the transition. This can be helpful in conjunction +#' with [purrr::pluck()] or [purrr::modify_in()] to reach the terminal in the +#' nested structure. +#' @keywords internal +#' @examples +#' pd <- compute_parse_data_nested("if (TRUE) f()") +#' styler::next_terminal(pd) +next_terminal <- function(pd, + stack = FALSE, + vars = c("pos_id", "token", "text"), + tokens_exclude = c()) { + + pd$position <- seq2(1, nrow(pd)) + pd <- pd[!(pd$token %in% tokens_exclude),] + if (pd$terminal[1]) { + pd[1, c("position", vars)] + } else { + current <- next_terminal(pd$child[[1]], stack = stack, vars = vars, tokens_exclude = tokens_exclude) + if (stack) { + bind_rows(pd[1, c("position", vars)], current) + } else { + current + } + } +} #' Find the index of the last comment in the sequence of comments-only tokens diff --git a/man/next_terminal.Rd b/man/next_terminal.Rd index e53e92cc7..834e01ed9 100644 --- a/man/next_terminal.Rd +++ b/man/next_terminal.Rd @@ -2,17 +2,31 @@ % Please edit documentation in R/utils.R \name{next_terminal} \alias{next_terminal} -\title{If the first is a terminal, return it. If not, go inside it and search the -next terminal} +\title{Tell me what the next terminal is} \usage{ next_terminal(pd, stack = FALSE, vars = c("pos_id", "token", "text"), - exclude_tokens = list()) + tokens_exclude = c()) } \arguments{ \item{pd}{A nest.} -\item{stack}{Whether or not to stack non-terminals. The order is inside-out, +\item{stack}{Whether or not to also return information on the tokens that +are between \code{pd} and the first terminal, so the returned tibble can be +understood as a transition path from \code{pd} to the next terminal, instead of +the information at the terminal only. The order is inside-out, i.e. the first non-terminal on top, the terminal last.} + +\item{vars}{The variables to return.} + +\item{tokens_exclude}{A vector with tokens to exclude. This can be helpful if +one wants to find the next token that is not a comment for example.} +} +\value{ +Returns a tibble (which is \strong{not} a valid parse table for +\code{stack = TRUE}), with \code{vars} and another variable \code{position} that denotes +the index each element in the transition. This can be helpful in conjunction +with \code{\link[purrr:pluck]{purrr::pluck()}} or \code{\link[purrr:modify_in]{purrr::modify_in()}} to reach the terminal in the +nested structure. } \description{ If the first is a terminal, return it. If not, go inside it and search the From e1627db34190907f7eb4abf470772f7fbb14a5d0 Mon Sep 17 00:00:00 2001 From: lorenzwalthert Date: Mon, 15 Apr 2019 00:19:21 +0200 Subject: [PATCH 05/48] also add braces to for and while loops, independent of whether they contain a return() statement + refactor --- R/rules-other.R | 82 +++++++++++++------ man/if_for_while_part_requires_braces.Rd | 20 +++++ man/pd_is.Rd | 15 ++++ man/wrap_else_multiline_curly.Rd | 21 +++++ ..._if_else_while_for_multi_line_in_curly.Rd} | 11 ++- man/wrap_multiline_curly.Rd | 24 ++++++ man/wrap_subexpr_in_curly.Rd | 3 - 7 files changed, 143 insertions(+), 33 deletions(-) create mode 100644 man/if_for_while_part_requires_braces.Rd create mode 100644 man/wrap_else_multiline_curly.Rd rename man/{wrap_if_else_multi_line_in_curly.Rd => wrap_if_else_while_for_multi_line_in_curly.Rd} (50%) create mode 100644 man/wrap_multiline_curly.Rd diff --git a/R/rules-other.R b/R/rules-other.R index a4e750086..4617158de 100644 --- a/R/rules-other.R +++ b/R/rules-other.R @@ -8,48 +8,69 @@ add_brackets_in_pipe_one <- function(pd, pos) { next_non_comment <- next_non_comment(pd, pos) rh_child <- pd$child[[next_non_comment]] if (nrow(rh_child) < 2 && rh_child$token == "SYMBOL") { - new_pos_ids <- create_pos_ids(pd$child[[next_non_comment]], 1, after = TRUE, n = 2) + child <- pd$child[[next_non_comment]] + new_pos_ids <- create_pos_ids(child, 1, after = TRUE, n = 2) new_pd <- create_tokens( - tokens = c("'('", "')'"), texts = c("(", ")"), pos_ids = new_pos_ids, + tokens = c("'('", "')'"), + texts = c("(", ")"), + pos_ids = new_pos_ids, lag_newlines = rep(0, 2) ) - pd$child[[next_non_comment]] <- - bind_rows(pd$child[[next_non_comment]], new_pd) %>% + pd$child[[next_non_comment]] <- bind_rows( + pd$child[[next_non_comment]], + new_pd + ) %>% arrange(pos_id) } pd } -#' Wrap if-else statement in curly braces +#' Wrap if-else, while and for statements in curly braces #' -#' Wrap an if-else statement in curly braces if it is not already wrapped in -#' a such. +#' Wrap statements in curly braces if it is not already wrapped in a such. #' @param pd A parse table. #' @param indent_by The amount of spaces used to indent an expression in curly #' braces. Used for unindention. #' @keywords internal -wrap_if_else_multi_line_in_curly <- function(pd, indent_by = 2) { +#' @importFrom purrr when +wrap_if_else_while_for_multi_line_in_curly <- function(pd, indent_by = 2) { + key_token <- when(pd, + is_cond_expr(.) ~ "')'", + is_while_expr(.) ~ "')'", + is_for_expr(.) ~ "forcond" + ) + if (length(key_token) > 0) { + pd <- pd %>% + wrap_multiline_curly(indent_by, + space_after = ifelse(contains_else_expr(pd), 1, 0), + key_token = key_token + ) + } if (is_cond_expr(pd)) { pd <- pd %>% - wrap_if_multiline_curly(indent_by, - space_after = ifelse(contains_else_expr(pd), 1, 0) - ) %>% wrap_else_multiline_curly(indent_by, space_after = 0) } pd } - -wrap_if_multiline_curly <- function(pd, indent_by, space_after = 1) { - if (if_part_requires_braces(pd)) { - closing_brace_ind <- which(pd$token == "')'")[1] +#' Wrap a multi-line statement in curly braces +#' +#' @inheritParams wrap_if_else_while_for_multi_line_in_curly +#' @inheritParams wrap_subexpr_in_curly +#' @param key_token The token that comes right before the token that contains +#' the expression to be wrapped (ignoring comments). For if and while loops, +#' this is the closing "')'", for a for-loop it's "forcond". +#' @keywords internal +wrap_multiline_curly <- function(pd, indent_by, space_after = 1, key_token) { + to_be_wrapped_expr_with_child <- next_non_comment( + pd, which(pd$token == key_token)[1] + ) + next_terminal <- next_terminal(pd[to_be_wrapped_expr_with_child,])$text + requires_braces <- if_for_while_part_requires_braces(pd, key_token) + if (requires_braces | next_terminal == "return") { + closing_brace_ind <- which(pd$token == key_token)[1] pd$spaces[closing_brace_ind] <- 1L - to_be_wrapped_expr_with_child <- next_non_comment( - pd, - which(pd$token == "')'")[1] - ) - all_to_be_wrapped_ind <- seq2( closing_brace_ind + 1L, to_be_wrapped_expr_with_child ) @@ -63,6 +84,12 @@ wrap_if_multiline_curly <- function(pd, indent_by, space_after = 1) { pd } +#' Add curly braces to else +#' +#' Wrap the else part of a conditional expression into curly braces if not +#' already wraped into a such. +#' @inheritParams wrap_multiline_curly +#' @keywords internal wrap_else_multiline_curly <- function(pd, indent_by = 2, space_after = 0) { if (contains_else_expr(pd) && pd_is_multi_line(pd) && @@ -81,7 +108,7 @@ wrap_else_multiline_curly <- function(pd, indent_by = 2, space_after = 0) { #' Wrap a sub-expression in curly braces #' #' Wraps some rows of a parse table into a sub-expression. -#' @inheritParams wrap_if_else_multi_line_in_curly +#' @inheritParams wrap_multiline_curly #' @param ind_to_be_wrapped The indices of the rows that should be wrapped #' into a new expression. #' @inheritParams wrap_expr_in_curly @@ -109,7 +136,14 @@ wrap_subexpr_in_curly <- function(pd, arrange(pos_id) } -if_part_requires_braces <- function(pd) { - pd_is_multi_line(pd) && - !is_curly_expr(pd$child[[next_non_comment(pd, which(pd$token == "')'")[1])]]) +#' Check if if, for or while loop expression require a braces. +#' +#' This is the case if they are multi-line and not yet wraped into curly +#' braces. +#' @inheritParams wrap_multiline_curly +#' @keywords internal +if_for_while_part_requires_braces <- function(pd, key_token) { + pos_first_key_token <- which(pd$token == key_token)[1] + child <- pd$child[[next_non_comment(pd, pos_first_key_token)]] + pd_is_multi_line(pd) && !is_curly_expr(child) } diff --git a/man/if_for_while_part_requires_braces.Rd b/man/if_for_while_part_requires_braces.Rd new file mode 100644 index 000000000..654548ece --- /dev/null +++ b/man/if_for_while_part_requires_braces.Rd @@ -0,0 +1,20 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/rules-other.R +\name{if_for_while_part_requires_braces} +\alias{if_for_while_part_requires_braces} +\title{Check if if, for or while loop expression require a braces.} +\usage{ +if_for_while_part_requires_braces(pd, key_token) +} +\arguments{ +\item{pd}{A parse table.} + +\item{key_token}{The token that comes right before the token that contains +the expression to be wrapped (ignoring comments). For if and while loops, +this is the closing "')'", for a for-loop it's "forcond".} +} +\description{ +This is the case if they are multi-line and not yet wraped into curly +braces. +} +\keyword{internal} diff --git a/man/pd_is.Rd b/man/pd_is.Rd index d9eb0f659..4f44ae36b 100644 --- a/man/pd_is.Rd +++ b/man/pd_is.Rd @@ -3,15 +3,24 @@ \name{pd_is} \alias{pd_is} \alias{is_curly_expr} +\alias{is_cond_expr} +\alias{is_while_expr} \alias{is_function_call} \alias{is_function_dec} +\alias{is_comment} \title{Check whether a parse table corresponds to a certain expression} \usage{ is_curly_expr(pd) +is_cond_expr(pd) + +is_while_expr(pd) + is_function_call(pd) is_function_dec(pd) + +is_comment(pd) } \arguments{ \item{pd}{A parse table.} @@ -24,9 +33,15 @@ Check whether a parse table corresponds to a certain expression \item \code{is_curly_expr}: Checks whether \code{pd} contains an expression wrapped in curly brackets. +\item \code{is_cond_expr}: Checks whether \code{pd} contains is a conditional expression. + +\item \code{is_while_expr}: Checks whether \code{pd} contains is a while loop. + \item \code{is_function_call}: Checks whether \code{pd} is a function call. \item \code{is_function_dec}: Checks whether \code{pd} is a function declaration. + +\item \code{is_comment}: Checks for every token whether or not it is a comment. }} \keyword{internal} diff --git a/man/wrap_else_multiline_curly.Rd b/man/wrap_else_multiline_curly.Rd new file mode 100644 index 000000000..b050a144a --- /dev/null +++ b/man/wrap_else_multiline_curly.Rd @@ -0,0 +1,21 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/rules-other.R +\name{wrap_else_multiline_curly} +\alias{wrap_else_multiline_curly} +\title{Add curly braces to else} +\usage{ +wrap_else_multiline_curly(pd, indent_by = 2, space_after = 0) +} +\arguments{ +\item{pd}{A parse table.} + +\item{indent_by}{The amount of spaces used to indent an expression in curly +braces. Used for unindention.} + +\item{space_after}{How many spaces should be inserted after the closing brace.} +} +\description{ +Wrap the else part of a conditional expression into curly braces if not +already wraped into a such. +} +\keyword{internal} diff --git a/man/wrap_if_else_multi_line_in_curly.Rd b/man/wrap_if_else_while_for_multi_line_in_curly.Rd similarity index 50% rename from man/wrap_if_else_multi_line_in_curly.Rd rename to man/wrap_if_else_while_for_multi_line_in_curly.Rd index ec06b48db..8a584a699 100644 --- a/man/wrap_if_else_multi_line_in_curly.Rd +++ b/man/wrap_if_else_while_for_multi_line_in_curly.Rd @@ -1,10 +1,10 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/rules-other.R -\name{wrap_if_else_multi_line_in_curly} -\alias{wrap_if_else_multi_line_in_curly} -\title{Wrap if-else statement in curly braces} +\name{wrap_if_else_while_for_multi_line_in_curly} +\alias{wrap_if_else_while_for_multi_line_in_curly} +\title{Wrap if-else, while and for statements in curly braces} \usage{ -wrap_if_else_multi_line_in_curly(pd, indent_by = 2) +wrap_if_else_while_for_multi_line_in_curly(pd, indent_by = 2) } \arguments{ \item{pd}{A parse table.} @@ -13,7 +13,6 @@ wrap_if_else_multi_line_in_curly(pd, indent_by = 2) braces. Used for unindention.} } \description{ -Wrap an if-else statement in curly braces if it is not already wrapped in -a such. +Wrap statements in curly braces if it is not already wrapped in a such. } \keyword{internal} diff --git a/man/wrap_multiline_curly.Rd b/man/wrap_multiline_curly.Rd new file mode 100644 index 000000000..6543c9591 --- /dev/null +++ b/man/wrap_multiline_curly.Rd @@ -0,0 +1,24 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/rules-other.R +\name{wrap_multiline_curly} +\alias{wrap_multiline_curly} +\title{Wrap a multi-line statement in curly braces} +\usage{ +wrap_multiline_curly(pd, indent_by, space_after = 1, key_token) +} +\arguments{ +\item{pd}{A parse table.} + +\item{indent_by}{The amount of spaces used to indent an expression in curly +braces. Used for unindention.} + +\item{space_after}{How many spaces should be inserted after the closing brace.} + +\item{key_token}{The token that comes right before the token that contains +the expression to be wrapped (ignoring comments). For if and while loops, +this is the closing "')'", for a for-loop it's "forcond".} +} +\description{ +Wrap a multi-line statement in curly braces +} +\keyword{internal} diff --git a/man/wrap_subexpr_in_curly.Rd b/man/wrap_subexpr_in_curly.Rd index 5d4576353..12cdfff58 100644 --- a/man/wrap_subexpr_in_curly.Rd +++ b/man/wrap_subexpr_in_curly.Rd @@ -12,9 +12,6 @@ wrap_subexpr_in_curly(pd, ind_to_be_wrapped, indent_by, space_after) \item{ind_to_be_wrapped}{The indices of the rows that should be wrapped into a new expression.} -\item{indent_by}{The amount of spaces used to indent an expression in curly -braces. Used for unindention.} - \item{space_after}{How many spaces should be inserted after the closing brace.} } \description{ From b379b4275a21ebef058bf54849e580ac19e61e6b Mon Sep 17 00:00:00 2001 From: lorenzwalthert Date: Mon, 15 Apr 2019 00:24:18 +0200 Subject: [PATCH 06/48] move function declarations between files --- DESCRIPTION | 3 + R/set-assert-args.R | 2 - R/utils-files.R | 25 +++++++ R/utils-navigate-nest.R | 77 +++++++++++++++++++ R/utils-strings.R | 29 ++++++++ R/utils.R | 131 --------------------------------- man/add_spaces_or_newlines.Rd | 2 +- man/extend_if_comment.Rd | 2 +- man/map_filetype_to_pattern.Rd | 2 +- man/next_non_comment.Rd | 2 +- man/next_terminal.Rd | 2 +- man/rep_char.Rd | 2 +- 12 files changed, 140 insertions(+), 139 deletions(-) create mode 100644 R/utils-files.R create mode 100644 R/utils-navigate-nest.R create mode 100644 R/utils-strings.R diff --git a/DESCRIPTION b/DESCRIPTION index da6e28dd9..270a7640b 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -77,6 +77,9 @@ Collate: 'transform-files.R' 'ui.R' 'unindent.R' + 'utils-files.R' + 'utils-navigate-nest.R' + 'utils-strings.R' 'utils.R' 'vertical.R' 'visit.R' diff --git a/R/set-assert-args.R b/R/set-assert-args.R index c23df7d8d..b96563dce 100644 --- a/R/set-assert-args.R +++ b/R/set-assert-args.R @@ -46,7 +46,6 @@ assert_filetype <- function(lowercase_filetype) { } } - #' Assert text to be of positive length and replace it with the empty #' string otherwise. #' @param text The input to style. @@ -58,7 +57,6 @@ assert_text <- function(text) { text } - #' Check token validity #' #' Check whether one or more tokens exist and have a unique token-text mapping diff --git a/R/utils-files.R b/R/utils-files.R new file mode 100644 index 000000000..a86056a04 --- /dev/null +++ b/R/utils-files.R @@ -0,0 +1,25 @@ +is_plain_r_file <- function(path) { + grepl("\\.R$", path, ignore.case = TRUE) +} + +is_rmd_file <- function(path) { + grepl("\\.Rmd$", path, ignore.case = TRUE) +} + +is_rnw_file <- function(path) { + grepl("\\.Rnw$", path, ignore.case = TRUE) +} + +is_unsaved_file <- function(path) { + path == "" +} + +#' Map the file type to a corresponding regular expression +#' +#' @param filetype The file type to map to a regex. +#' @examples +#' styler:::map_filetype_to_pattern(c(".rMd", "R")) +#' @keywords internal +map_filetype_to_pattern <- function(filetype) { + paste0("(", paste(set_and_assert_arg_filetype(filetype), collapse = "|"), ")$") +} diff --git a/R/utils-navigate-nest.R b/R/utils-navigate-nest.R new file mode 100644 index 000000000..24435b2a5 --- /dev/null +++ b/R/utils-navigate-nest.R @@ -0,0 +1,77 @@ + +#' Find the index of the next or previous non-comment in a parse table. +#' @param pd A parse table. +#' @param pos The position of the token to start the search from. +#' @importFrom rlang seq2 +#' @keywords internal +next_non_comment <- function(pd, pos) { + if (length(pos) < 1 || is.na(pos) || pos >= nrow(pd)) return(integer(0)) + candidates <- seq2(pos + 1L, nrow(pd)) + if (all(candidates %in% which(pd$token == "COMMENT"))) return(integer(0)) + setdiff(candidates, which(pd$token == "COMMENT"))[1] +} + +#' @rdname next_non_comment +previous_non_comment <- function(pd, pos) { + if (length(pos) < 1 || is.na(pos) || pos >= nrow(pd)) return(integer(0)) + candidates <- seq2(1L, pos - 1L) + if (all(candidates %in% which(pd$token == "COMMENT"))) return(integer(0)) + last(setdiff(candidates, which(pd$token == "COMMENT"))) +} + +#' Tell me what the next terminal is +#' +#' If the first is a terminal, return it. If not, go inside it and search the +#' next terminal +#' @param pd A nest. +#' @param stack Whether or not to also return information on the tokens that +#' are between `pd` and the first terminal, so the returned tibble can be +#' understood as a transition path from `pd` to the next terminal, instead of +#' the information at the terminal only. The order is inside-out, +#' i.e. the first non-terminal on top, the terminal last. +#' @param vars The variables to return. +#' @param tokens_exclude A vector with tokens to exclude. This can be helpful if +#' one wants to find the next token that is not a comment for example. +#' @return +#' Returns a tibble (which is **not** a valid parse table for +#' `stack = TRUE`), with `vars` and another variable `position` that denotes +#' the index each element in the transition. This can be helpful in conjunction +#' with [purrr::pluck()] or [purrr::modify_in()] to reach the terminal in the +#' nested structure. +#' @keywords internal +#' @examples +#' pd <- compute_parse_data_nested("if (TRUE) f()") +#' styler::next_terminal(pd) +next_terminal <- function(pd, + stack = FALSE, + vars = c("pos_id", "token", "text"), + tokens_exclude = c()) { + + pd$position <- seq2(1, nrow(pd)) + pd <- pd[!(pd$token %in% tokens_exclude),] + if (pd$terminal[1]) { + pd[1, c("position", vars)] + } else { + current <- next_terminal(pd$child[[1]], stack = stack, vars = vars, tokens_exclude = tokens_exclude) + if (stack) { + bind_rows(pd[1, c("position", vars)], current) + } else { + current + } + } +} + + +#' Find the index of the last comment in the sequence of comments-only tokens +#' after the token that has position `pos` in `pd`. +#' @param pd A parse table. +#' @param pos The position of the token to start the search from. +#' @keywords internal +extend_if_comment <- function(pd, pos) { + if (pos == nrow(pd)) return(pos) + if (pd$token[pos + 1] == "COMMENT") { + extend_if_comment(pd, pos + 1L) + } else { + pos + } +} diff --git a/R/utils-strings.R b/R/utils-strings.R new file mode 100644 index 000000000..46644b65a --- /dev/null +++ b/R/utils-strings.R @@ -0,0 +1,29 @@ +#' Repeat elements of a character vector `times` times and collapse it +#' +#' @param char A character vector. +#' @param times an integer giving the number of repetitions. +#' @return A character vector. +#' @keywords internal +rep_char <- function(char, times) { + paste(rep.int(char, times), collapse = "") +} + +#' Concentrate newlines or spaces in a string +#' +#' @param n Scalar indicating how many characters should be concentrated +#' @return A string. +#' @name add_spaces_or_newlines +#' @keywords internal +NULL + +#' @rdname add_spaces_or_newlines +#' @keywords internal +add_newlines <- function(n) { + rep_char("\n", n) +} + +#' @rdname add_spaces_or_newlines +#' @keywords internal +add_spaces <- function(n) { + rep_char(" ", n) +} diff --git a/R/utils.R b/R/utils.R index 12344afb4..5db3716ac 100644 --- a/R/utils.R +++ b/R/utils.R @@ -40,35 +40,6 @@ even_index <- function(x) { seq(2L, length(x), by = 2) } -#' Repeat elements of a character vector `times` times and collapse it -#' -#' @param char A character vector. -#' @param times an integer giving the number of repetitions. -#' @return A character vector. -#' @keywords internal -rep_char <- function(char, times) { - paste(rep.int(char, times), collapse = "") -} - -#' Concentrate newlines or spaces in a string -#' -#' @param n Scalar indicating how many characters should be concentrated -#' @return A string. -#' @name add_spaces_or_newlines -#' @keywords internal -NULL - -#' @rdname add_spaces_or_newlines -#' @keywords internal -add_newlines <- function(n) { - rep_char("\n", n) -} - -#' @rdname add_spaces_or_newlines -#' @keywords internal -add_spaces <- function(n) { - rep_char(" ", n) -} #' Invoke a system command #' @@ -85,105 +56,3 @@ calls_sys <- function(sys_call, ...) { } } -is_plain_r_file <- function(path) { - grepl("\\.R$", path, ignore.case = TRUE) -} - -is_rmd_file <- function(path) { - grepl("\\.Rmd$", path, ignore.case = TRUE) -} - -is_rnw_file <- function(path) { - grepl("\\.Rnw$", path, ignore.case = TRUE) -} - -is_unsaved_file <- function(path) { - path == "" -} - -#' Find the index of the next or previous non-comment in a parse table. -#' @param pd A parse table. -#' @param pos The position of the token to start the search from. -#' @importFrom rlang seq2 -#' @keywords internal -next_non_comment <- function(pd, pos) { - if (length(pos) < 1 || is.na(pos) || pos >= nrow(pd)) return(integer(0)) - candidates <- seq2(pos + 1L, nrow(pd)) - if (all(candidates %in% which(pd$token == "COMMENT"))) return(integer(0)) - setdiff(candidates, which(pd$token == "COMMENT"))[1] -} - -#' @rdname next_non_comment -previous_non_comment <- function(pd, pos) { - if (length(pos) < 1 || is.na(pos) || pos >= nrow(pd)) return(integer(0)) - candidates <- seq2(1L, pos - 1L) - if (all(candidates %in% which(pd$token == "COMMENT"))) return(integer(0)) - last(setdiff(candidates, which(pd$token == "COMMENT"))) -} - -#' Tell me what the next terminal is -#' -#' If the first is a terminal, return it. If not, go inside it and search the -#' next terminal -#' @param pd A nest. -#' @param stack Whether or not to also return information on the tokens that -#' are between `pd` and the first terminal, so the returned tibble can be -#' understood as a transition path from `pd` to the next terminal, instead of -#' the information at the terminal only. The order is inside-out, -#' i.e. the first non-terminal on top, the terminal last. -#' @param vars The variables to return. -#' @param tokens_exclude A vector with tokens to exclude. This can be helpful if -#' one wants to find the next token that is not a comment for example. -#' @return -#' Returns a tibble (which is **not** a valid parse table for -#' `stack = TRUE`), with `vars` and another variable `position` that denotes -#' the index each element in the transition. This can be helpful in conjunction -#' with [purrr::pluck()] or [purrr::modify_in()] to reach the terminal in the -#' nested structure. -#' @keywords internal -#' @examples -#' pd <- compute_parse_data_nested("if (TRUE) f()") -#' styler::next_terminal(pd) -next_terminal <- function(pd, - stack = FALSE, - vars = c("pos_id", "token", "text"), - tokens_exclude = c()) { - - pd$position <- seq2(1, nrow(pd)) - pd <- pd[!(pd$token %in% tokens_exclude),] - if (pd$terminal[1]) { - pd[1, c("position", vars)] - } else { - current <- next_terminal(pd$child[[1]], stack = stack, vars = vars, tokens_exclude = tokens_exclude) - if (stack) { - bind_rows(pd[1, c("position", vars)], current) - } else { - current - } - } -} - - -#' Find the index of the last comment in the sequence of comments-only tokens -#' after the token that has position `pos` in `pd`. -#' @param pd A parse table. -#' @param pos The position of the token to start the search from. -#' @keywords internal -extend_if_comment <- function(pd, pos) { - if (pos == nrow(pd)) return(pos) - if (pd$token[pos + 1] == "COMMENT") { - extend_if_comment(pd, pos + 1L) - } else { - pos - } -} - -#' Map the file type to a corresponding regular expression -#' -#' @param filetype The file type to map to a regex. -#' @examples -#' styler:::map_filetype_to_pattern(c(".rMd", "R")) -#' @keywords internal -map_filetype_to_pattern <- function(filetype) { - paste0("(", paste(set_and_assert_arg_filetype(filetype), collapse = "|"), ")$") -} diff --git a/man/add_spaces_or_newlines.Rd b/man/add_spaces_or_newlines.Rd index 6aa5c1329..9499c0051 100644 --- a/man/add_spaces_or_newlines.Rd +++ b/man/add_spaces_or_newlines.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/utils.R +% Please edit documentation in R/utils-strings.R \name{add_spaces_or_newlines} \alias{add_spaces_or_newlines} \alias{add_newlines} diff --git a/man/extend_if_comment.Rd b/man/extend_if_comment.Rd index 9a4e9034f..eeaee1f99 100644 --- a/man/extend_if_comment.Rd +++ b/man/extend_if_comment.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/utils.R +% Please edit documentation in R/utils-navigate-nest.R \name{extend_if_comment} \alias{extend_if_comment} \title{Find the index of the last comment in the sequence of comments-only tokens diff --git a/man/map_filetype_to_pattern.Rd b/man/map_filetype_to_pattern.Rd index c3d107993..249ca22cd 100644 --- a/man/map_filetype_to_pattern.Rd +++ b/man/map_filetype_to_pattern.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/utils.R +% Please edit documentation in R/utils-files.R \name{map_filetype_to_pattern} \alias{map_filetype_to_pattern} \title{Map the file type to a corresponding regular expression} diff --git a/man/next_non_comment.Rd b/man/next_non_comment.Rd index dd0a1a299..a607647a7 100644 --- a/man/next_non_comment.Rd +++ b/man/next_non_comment.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/utils.R +% Please edit documentation in R/utils-navigate-nest.R \name{next_non_comment} \alias{next_non_comment} \alias{previous_non_comment} diff --git a/man/next_terminal.Rd b/man/next_terminal.Rd index 834e01ed9..615574ae2 100644 --- a/man/next_terminal.Rd +++ b/man/next_terminal.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/utils.R +% Please edit documentation in R/utils-navigate-nest.R \name{next_terminal} \alias{next_terminal} \title{Tell me what the next terminal is} diff --git a/man/rep_char.Rd b/man/rep_char.Rd index c97e332ad..bfed9b9ba 100644 --- a/man/rep_char.Rd +++ b/man/rep_char.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/utils.R +% Please edit documentation in R/utils-strings.R \name{rep_char} \alias{rep_char} \title{Repeat elements of a character vector \code{times} times and collapse it} From 8581ca4591f4dae21f12a0663e12c2bf08afbd43 Mon Sep 17 00:00:00 2001 From: lorenzwalthert Date: Mon, 15 Apr 2019 00:51:37 +0200 Subject: [PATCH 07/48] fix example --- R/utils-navigate-nest.R | 4 ++-- man/next_terminal.Rd | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/R/utils-navigate-nest.R b/R/utils-navigate-nest.R index 24435b2a5..ae31f9082 100644 --- a/R/utils-navigate-nest.R +++ b/R/utils-navigate-nest.R @@ -40,8 +40,8 @@ previous_non_comment <- function(pd, pos) { #' nested structure. #' @keywords internal #' @examples -#' pd <- compute_parse_data_nested("if (TRUE) f()") -#' styler::next_terminal(pd) +#' pd <- styler:::compute_parse_data_nested("if (TRUE) f()") +#' styler:::next_terminal(pd) next_terminal <- function(pd, stack = FALSE, vars = c("pos_id", "token", "text"), diff --git a/man/next_terminal.Rd b/man/next_terminal.Rd index 615574ae2..c4e7c10c6 100644 --- a/man/next_terminal.Rd +++ b/man/next_terminal.Rd @@ -33,7 +33,7 @@ If the first is a terminal, return it. If not, go inside it and search the next terminal } \examples{ -pd <- compute_parse_data_nested("if (TRUE) f()") -styler::next_terminal(pd) +pd <- styler:::compute_parse_data_nested("if (TRUE) f()") +styler:::next_terminal(pd) } \keyword{internal} From b24c92674806600c1a0bee59ec8aa39a436a7fb1 Mon Sep 17 00:00:00 2001 From: lorenzwalthert Date: Mon, 15 Apr 2019 01:47:18 +0200 Subject: [PATCH 08/48] increase test coverage --- tests/testthat/test-varia.R | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 tests/testthat/test-varia.R diff --git a/tests/testthat/test-varia.R b/tests/testthat/test-varia.R new file mode 100644 index 000000000..f2f7bae53 --- /dev/null +++ b/tests/testthat/test-varia.R @@ -0,0 +1,20 @@ +context("test-varia") + +test_that("ensure_last_is_empty", { + expect_equal( + ensure_last_is_empty("x"), + c("x", "") + ) + expect_equal( + ensure_last_is_empty(c("x", "")), + c("x", "") + ) +}) + +test_that("unsaved file is recognized from path", { + expect_true(is_unsaved_file("")) +}) + +test_that("inexistant levels in factor creation lead to error", { + expect_error(character_to_ordered(c("x", "Y"), levels = "x")) +}) From 57fcf7daa2db1aac51bd519e2eae2506a0da218d Mon Sep 17 00:00:00 2001 From: lorenzwalthert Date: Tue, 23 Apr 2019 22:20:47 +0200 Subject: [PATCH 09/48] add reference to ALE. --- README.Rmd | 3 +++ README.md | 3 +++ 2 files changed, 6 insertions(+) diff --git a/README.Rmd b/README.Rmd index f2e675d04..3d5325705 100644 --- a/README.Rmd +++ b/README.Rmd @@ -128,6 +128,9 @@ styler functionality is made available through other packages, most notably "styler")` at the top of your RMarkdown script. * pretty-printing of [drake](https://github.com/ropensci/drake) workflow data frames with `drake::drake_plan_source()`. +* Adding styler as a fixer to the + [ale Plug-in](https://github.com/w0rp/ale/pull/2401#issuecomment-485942966) + for VIM. ## Further resources diff --git a/README.md b/README.md index a545cd74e..c1082851a 100644 --- a/README.md +++ b/README.md @@ -125,6 +125,9 @@ notably RMarkdown script. - pretty-printing of [drake](https://github.com/ropensci/drake) workflow data frames with `drake::drake_plan_source()`. + - Adding styler as a fixer to the [ale + Plug-in](https://github.com/w0rp/ale/pull/2401#issuecomment-485942966) + for VIM. ## Further resources From fca6b723bc2cfb8f4191f27631b950446f45e456 Mon Sep 17 00:00:00 2001 From: lorenzwalthert Date: Sat, 27 Apr 2019 18:30:07 +0200 Subject: [PATCH 10/48] don't skip on windows, just test without UTF8 available. If available, test as if available and as if not. --- ...clean-reference-with-scope-tokens-non-utf8 | Bin 0 -> 183 bytes ...=> clean-reference-with-scope-tokens-utf8} | Bin ...dirty-reference-with-scope-spaces-non-utf8 | Bin 0 -> 184 bytes ...=> dirty-reference-with-scope-spaces-utf8} | Bin ...dirty-reference-with-scope-tokens-non-utf8 | Bin 0 -> 205 bytes ...=> dirty-reference-with-scope-tokens-utf8} | Bin tests/testthat/test-public_api.R | 116 ++++++++++++------ 7 files changed, 76 insertions(+), 40 deletions(-) create mode 100644 tests/testthat/public-api/xyzdir-dirty/clean-reference-with-scope-tokens-non-utf8 rename tests/testthat/public-api/xyzdir-dirty/{clean-reference-with-scope-tokens => clean-reference-with-scope-tokens-utf8} (100%) create mode 100644 tests/testthat/public-api/xyzdir-dirty/dirty-reference-with-scope-spaces-non-utf8 rename tests/testthat/public-api/xyzdir-dirty/{dirty-reference-with-scope-spaces => dirty-reference-with-scope-spaces-utf8} (100%) create mode 100644 tests/testthat/public-api/xyzdir-dirty/dirty-reference-with-scope-tokens-non-utf8 rename tests/testthat/public-api/xyzdir-dirty/{dirty-reference-with-scope-tokens => dirty-reference-with-scope-tokens-utf8} (100%) diff --git a/tests/testthat/public-api/xyzdir-dirty/clean-reference-with-scope-tokens-non-utf8 b/tests/testthat/public-api/xyzdir-dirty/clean-reference-with-scope-tokens-non-utf8 new file mode 100644 index 0000000000000000000000000000000000000000..47ce9abb493968e76c1d2c55fcc73c4ac97137fe GIT binary patch literal 183 zcmV;o07(BIiwFP!000001C@_43&JoEMq{gBoJ2Z0+~DAnVpmte$;mFRp*`DRyp$wu z_1_z@U7YmbxP$j`yt^zIV-bsI6Bfl`Wy{cWHf21_Rqmf!Q3a3zT$M(*AIJs@jgo|u z_eP`Wm9K>>OoPIk8U1{G+js3lcc lrlYL_zWcB*vVOeD_>8YD_8cFm(pj|og`ORvOYPX#!kDEKTfBgr>wa4Vpr9c#eoX4dG9rUpjeB2sDic4N@WYm zlfJD+vH5Uc%;NdJ>Yw4#QG?1NIaj&l&zAAgkn)6%9y-`@*{6EUl%q>+OuKvmfik>h HUI73Aa$;gs literal 0 HcmV?d00001 diff --git a/tests/testthat/public-api/xyzdir-dirty/dirty-reference-with-scope-tokens b/tests/testthat/public-api/xyzdir-dirty/dirty-reference-with-scope-tokens-utf8 similarity index 100% rename from tests/testthat/public-api/xyzdir-dirty/dirty-reference-with-scope-tokens rename to tests/testthat/public-api/xyzdir-dirty/dirty-reference-with-scope-tokens-utf8 diff --git a/tests/testthat/test-public_api.R b/tests/testthat/test-public_api.R index 28d57f94e..d890860e2 100644 --- a/tests/testthat/test-public_api.R +++ b/tests/testthat/test-public_api.R @@ -6,14 +6,14 @@ test_that("styler can style package", { capture_output(expect_false({ styled <- style_pkg(testthat_file("public-api", "xyzpackage")) any(styled$changed) - })) + })) }) test_that("styler can style directory", { capture_output(expect_false({ styled <- style_dir(testthat_file("public-api", "xyzdir")) any(styled$changed) - })) + })) }) test_that("styler can style files", { @@ -34,8 +34,9 @@ test_that("styler can style files", { test_that("styler does not return error when there is no file to style", { capture_output(expect_error(style_dir( - testthat_file("public-api", "xyzemptydir"), strict = FALSE), NA - )) + testthat_file("public-api", "xyzemptydir"), + strict = FALSE + ), NA)) }) context("public API - Rmd in style_file()") @@ -43,7 +44,8 @@ context("public API - Rmd in style_file()") test_that("styler can style Rmd file", { capture_output(expect_false({ out <- style_file( - testthat_file("public-api", "xyzfile_rmd", "random.Rmd"), strict = FALSE + testthat_file("public-api", "xyzfile_rmd", "random.Rmd"), + strict = FALSE ) out$changed })) @@ -67,32 +69,59 @@ test_that("styler handles malformed Rmd file and invalid R code in chunk", { context("messages are correct") test_that("messages (via cat()) of style_file are correct", { - skip_on_os("windows") - # Message if scope > line_breaks and code changes - temp_path <- copy_to_tempdir(testthat_file( - "public-api", "xyzdir-dirty", "dirty-sample-with-scope-tokens.R" - )) - expect_equal_to_reference(capture.output( - style_file(temp_path, scope = "tokens")), - testthat_file("public-api/xyzdir-dirty/dirty-reference-with-scope-tokens") - ) - unlink(dirname(temp_path)) - - # No message if scope > line_breaks and code does not change - temp_path <- copy_to_tempdir(testthat_file("public-api", "xyzdir-dirty", "clean-sample-with-scope-tokens.R")) - expect_equal_to_reference( - capture.output(style_file(temp_path, scope = "tokens")), - testthat_file("public-api/xyzdir-dirty/clean-reference-with-scope-tokens") - ) - unlink(dirname(temp_path)) - - # No message if scope <= line_breaks even if code is changed. - temp_path <- copy_to_tempdir(testthat_file("public-api", "xyzdir-dirty", "dirty-sample-with-scope-spaces.R")) - expect_equal_to_reference( - capture.output(style_file(temp_path, scope = "spaces")), - testthat_file("public-api/xyzdir-dirty/dirty-reference-with-scope-spaces") - ) - unlink(dirname(temp_path)) + if (cli::is_utf8_output()) { + # if utf8 is available test under this and test if it is not available + encodings <- list(TRUE) + } else { + # if utf8 is not available, only test under that + encodings <- list() + } + for (encoding in c(encodings, FALSE)) { + withr::with_options( + list(cli.unicode = encoding), { + # Message if scope > line_breaks and code changes + temp_path <- copy_to_tempdir(testthat_file( + "public-api", "xyzdir-dirty", "dirty-sample-with-scope-tokens.R" + )) + expect_equal_to_reference( + capture.output( + style_file(temp_path, scope = "tokens") + ), + testthat_file(paste0( + "public-api/xyzdir-dirty/dirty-reference-with-scope-tokens-", + ifelse(cli::is_utf8_output(), "utf8", "non-utf8") + )) + ) + unlink(dirname(temp_path)) + + # No message if scope > line_breaks and code does not change + temp_path <- copy_to_tempdir(testthat_file( + "public-api", "xyzdir-dirty", "clean-sample-with-scope-tokens.R" + )) + expect_equal_to_reference( + capture.output(style_file(temp_path, scope = "tokens")), + testthat_file(paste0( + "public-api/xyzdir-dirty/clean-reference-with-scope-tokens-", + ifelse(cli::is_utf8_output(), "utf8", "non-utf8") + )) + ) + unlink(dirname(temp_path)) + + # No message if scope <= line_breaks even if code is changed. + temp_path <- copy_to_tempdir(testthat_file( + "public-api", "xyzdir-dirty", "dirty-sample-with-scope-spaces.R" + )) + expect_equal_to_reference( + capture.output(style_file(temp_path, scope = "spaces")), + testthat_file(paste0( + "public-api/xyzdir-dirty/dirty-reference-with-scope-spaces-", + ifelse(cli::is_utf8_output(), "utf8", "non-utf8") + )) + ) + unlink(dirname(temp_path)) + } + ) + } }) context("public API - Rmd in style_dir()") @@ -100,7 +129,8 @@ context("public API - Rmd in style_dir()") test_that("styler can style R and Rmd files via style_dir()", { msg <- capture_output( style_dir(testthat_file("public-api", "xyz-r-and-rmd-dir"), - filetype = c("R", "Rmd")) + filetype = c("R", "Rmd") + ) ) expect_true(any(grepl("random-script-in-sub-dir.R", msg, fixed = TRUE))) expect_true(any(grepl("random-rmd-script.Rmd", msg, fixed = TRUE))) @@ -109,7 +139,8 @@ test_that("styler can style R and Rmd files via style_dir()", { test_that("styler can style Rmd files only via style_dir()", { msg <- capture_output( style_dir(testthat_file("public-api", "xyz-r-and-rmd-dir"), - filetype = "Rmd") + filetype = "Rmd" + ) ) expect_true(any(grepl("random-rmd-script.Rmd", msg, fixed = TRUE))) expect_false(any(grepl("random-script-in-sub-dir.R", msg, fixed = TRUE))) @@ -118,7 +149,8 @@ test_that("styler can style Rmd files only via style_dir()", { test_that("styler can style .r and .rmd files via style_dir()", { msg <- capture_output( style_dir(testthat_file("public-api", "xyz-r-and-rmd-dir"), - filetype = c(".r", ".rmd")) + filetype = c(".r", ".rmd") + ) ) expect_true(any(grepl("random-script-in-sub-dir.R", msg, fixed = TRUE))) expect_true(any(grepl("random-rmd-script.Rmd", msg, fixed = TRUE))) @@ -129,20 +161,21 @@ context("public API - Rmd in style_pkg()") test_that("styler can style R and Rmd files via style_pkg()", { msg <- capture_output( style_pkg(testthat_file("public-api", "xyzpackage-rmd"), - filetype = c("R", "Rmd")) + filetype = c("R", "Rmd") + ) ) expect_true(any(grepl("hello-world.R", msg, fixed = TRUE))) expect_true(any(grepl("test-package-xyz.R", msg, fixed = TRUE))) expect_true(any(grepl("random.Rmd", msg, fixed = TRUE))) expect_true(any(grepl("README.Rmd", msg, fixed = TRUE))) expect_false(any(grepl("RcppExports.R", msg, fixed = TRUE))) - }) test_that("styler can style Rmd files only via style_pkg()", { msg <- capture_output( style_pkg(testthat_file("public-api", "xyzpackage-rmd"), - filetype = "Rmd") + filetype = "Rmd" + ) ) expect_false(any(grepl("hello-world.R", msg, fixed = TRUE))) expect_false(any(grepl("test-package-xyz.R", msg, fixed = TRUE))) @@ -160,7 +193,8 @@ context("public API - Rnw in style_file()") test_that("styler can style Rnw file", { capture_output(expect_false({ out <- style_file( - testthat_file("public-api", "xyzfile-rnw", "random.Rnw"), strict = FALSE + testthat_file("public-api", "xyzfile-rnw", "random.Rnw"), + strict = FALSE ) out$changed })) @@ -186,7 +220,8 @@ context("public API - Rnw in style_pkg()") test_that("styler can style R, Rmd and Rnw files via style_pkg()", { msg <- capture_output( style_pkg(testthat_file("public-api", "xyzpackage-rnw"), - filetype = c("R", "Rmd", "Rnw")) + filetype = c("R", "Rmd", "Rnw") + ) ) expect_true(any(grepl("hello-world.R", msg, fixed = TRUE))) expect_true(any(grepl("test-package-xyz.R", msg, fixed = TRUE))) @@ -198,7 +233,8 @@ test_that("styler can style R, Rmd and Rnw files via style_pkg()", { test_that("styler can style Rnw files only via style_pkg()", { msg <- capture_output( style_pkg(testthat_file("public-api", "xyzpackage-rnw"), - filetype = "Rnw") + filetype = "Rnw" + ) ) expect_false(any(grepl("hello-world.R", msg, fixed = TRUE))) expect_false(any(grepl("test-package-xyz.R", msg, fixed = TRUE))) From 93c5a858d593e466a307facf906b25f7ad00f787 Mon Sep 17 00:00:00 2001 From: lorenzwalthert Date: Sat, 27 Apr 2019 19:38:11 +0200 Subject: [PATCH 11/48] Only support last 3 minor R versions. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 16688b2bb..692608e78 100644 --- a/.travis.yml +++ b/.travis.yml @@ -30,10 +30,10 @@ latex: false matrix: include: - - r: 3.1 - r: 3.2 - r: 3.3 - r: 3.4 + - r: 3.5 - r: release env: - BUILD_PKGDOWN: true From 21770cd5cd2b73b79292dfc77802a526a6ce6e9e Mon Sep 17 00:00:00 2001 From: lorenzwalthert Date: Thu, 2 May 2019 21:40:07 +0200 Subject: [PATCH 12/48] update parse trees as bug in R parser 3.6 got removed. Implies less inserted expressions (because pos_ids are now integer values), implying a small speed gain. --- .../logical_special_eq_sub-in_tree | 12 +- ...eq_assign_ifelse_scope_line_breaks-in_tree | 58 +- .../eq_assign_ifelse_scope_tokens-in_tree | 58 +- .../eq_assign_multiple_tokens_eq_only-in_tree | 195 ++-- .../eq_assign_multiple_tokens_mixed-in_tree | 45 +- ...-function-examples-last-proper-run-in_tree | 12 +- .../scope_argument/scope_indention-in_tree | 94 +- .../scope_argument/scope_line_breaks-in_tree | 94 +- .../scope_argument/scope_spaces-in_tree | 14 +- .../scope_argument/scope_tokens-in_tree | 94 +- tests/testthat/strict/non_strict-in_tree | 892 +++++++++--------- tests/testthat/strict/strict-in_tree | 892 +++++++++--------- .../token_adding_removing/mixed_token-in_tree | 168 ++-- 13 files changed, 1313 insertions(+), 1315 deletions(-) diff --git a/tests/testthat/indention_operators/logical_special_eq_sub-in_tree b/tests/testthat/indention_operators/logical_special_eq_sub-in_tree index 14aff20bb..0ca35a0e9 100644 --- a/tests/testthat/indention_operators/logical_special_eq_sub-in_tree +++ b/tests/testthat/indention_operators/logical_special_eq_sub-in_tree @@ -35,9 +35,9 @@ ROOT (token: short_text [lag_newlines/spaces] {pos_id}) ¦ ¦ ¦--'(': ( [0/0] {34} ¦ ¦ °--')': ) [0/0] {35} ¦ °--')': ) [1/0] {36} - °--expr: [1/0] {36.9} - ¦--expr: [0/1] {38} - ¦ °--SYMBOL: b [0/0] {37} - ¦--EQ_ASSIGN: = [0/0] {39} - °--expr: [1/0] {41} - °--NUM_CONST: 3 [0/0] {40} + °--equal_assign: [1/0] {37} + ¦--expr: [0/1] {39} + ¦ °--SYMBOL: b [0/0] {38} + ¦--EQ_ASSIGN: = [0/0] {40} + °--expr: [1/0] {42} + °--NUM_CONST: 3 [0/0] {41} diff --git a/tests/testthat/relocate_eq_assign/eq_assign_ifelse_scope_line_breaks-in_tree b/tests/testthat/relocate_eq_assign/eq_assign_ifelse_scope_line_breaks-in_tree index 1dfb6b1fd..94e72e7dc 100644 --- a/tests/testthat/relocate_eq_assign/eq_assign_ifelse_scope_line_breaks-in_tree +++ b/tests/testthat/relocate_eq_assign/eq_assign_ifelse_scope_line_breaks-in_tree @@ -1,30 +1,30 @@ ROOT (token: short_text [lag_newlines/spaces] {pos_id}) - ¦--expr: [0/0] {0.9} - ¦ ¦--expr: [0/1] {2} - ¦ ¦ °--SYMBOL: x [0/0] {1} - ¦ ¦--EQ_ASSIGN: = [0/1] {3} - ¦ °--expr: [0/0] {5} - ¦ °--NUM_CONST: 5 [0/0] {4} - °--expr: [2/0] {6} - ¦--IF: if [0/0] {7} - ¦--'(': ( [0/0] {8} - ¦--expr: [0/0] {9} - ¦ ¦--expr: [0/1] {11} - ¦ ¦ °--SYMBOL: x [0/0] {10} - ¦ ¦--GE: >= [0/1] {12} - ¦ °--expr: [0/0] {14} - ¦ °--NUM_CONST: 5 [0/0] {13} - ¦--')': ) [0/2] {15} - ¦--expr: [1/1] {15.9} - ¦ ¦--expr: [0/1] {17} - ¦ ¦ °--SYMBOL: y [0/0] {16} - ¦ ¦--EQ_ASSIGN: = [0/1] {18} - ¦ °--expr: [0/0] {20} - ¦ °--NUM_CONST: TRUE [0/0] {19} - ¦--ELSE: else [0/4] {21} - °--expr: [1/0] {21.9} - ¦--expr: [0/1] {23} - ¦ °--SYMBOL: y [0/0] {22} - ¦--EQ_ASSIGN: = [0/1] {24} - °--expr: [0/0] {26} - °--NUM_CONST: FALSE [0/0] {25} + ¦--equal_assign: [0/0] {1} + ¦ ¦--expr: [0/1] {3} + ¦ ¦ °--SYMBOL: x [0/0] {2} + ¦ ¦--EQ_ASSIGN: = [0/1] {4} + ¦ °--expr: [0/0] {6} + ¦ °--NUM_CONST: 5 [0/0] {5} + °--expr: [2/0] {7} + ¦--IF: if [0/0] {8} + ¦--'(': ( [0/0] {9} + ¦--expr: [0/0] {10} + ¦ ¦--expr: [0/1] {12} + ¦ ¦ °--SYMBOL: x [0/0] {11} + ¦ ¦--GE: >= [0/1] {13} + ¦ °--expr: [0/0] {15} + ¦ °--NUM_CONST: 5 [0/0] {14} + ¦--')': ) [0/2] {16} + ¦--equal_assign: [1/1] {17} + ¦ ¦--expr: [0/1] {19} + ¦ ¦ °--SYMBOL: y [0/0] {18} + ¦ ¦--EQ_ASSIGN: = [0/1] {20} + ¦ °--expr: [0/0] {22} + ¦ °--NUM_CONST: TRUE [0/0] {21} + ¦--ELSE: else [0/4] {23} + °--equal_assign: [1/0] {24} + ¦--expr: [0/1] {26} + ¦ °--SYMBOL: y [0/0] {25} + ¦--EQ_ASSIGN: = [0/1] {27} + °--expr: [0/0] {29} + °--NUM_CONST: FALSE [0/0] {28} diff --git a/tests/testthat/relocate_eq_assign/eq_assign_ifelse_scope_tokens-in_tree b/tests/testthat/relocate_eq_assign/eq_assign_ifelse_scope_tokens-in_tree index 1dfb6b1fd..94e72e7dc 100644 --- a/tests/testthat/relocate_eq_assign/eq_assign_ifelse_scope_tokens-in_tree +++ b/tests/testthat/relocate_eq_assign/eq_assign_ifelse_scope_tokens-in_tree @@ -1,30 +1,30 @@ ROOT (token: short_text [lag_newlines/spaces] {pos_id}) - ¦--expr: [0/0] {0.9} - ¦ ¦--expr: [0/1] {2} - ¦ ¦ °--SYMBOL: x [0/0] {1} - ¦ ¦--EQ_ASSIGN: = [0/1] {3} - ¦ °--expr: [0/0] {5} - ¦ °--NUM_CONST: 5 [0/0] {4} - °--expr: [2/0] {6} - ¦--IF: if [0/0] {7} - ¦--'(': ( [0/0] {8} - ¦--expr: [0/0] {9} - ¦ ¦--expr: [0/1] {11} - ¦ ¦ °--SYMBOL: x [0/0] {10} - ¦ ¦--GE: >= [0/1] {12} - ¦ °--expr: [0/0] {14} - ¦ °--NUM_CONST: 5 [0/0] {13} - ¦--')': ) [0/2] {15} - ¦--expr: [1/1] {15.9} - ¦ ¦--expr: [0/1] {17} - ¦ ¦ °--SYMBOL: y [0/0] {16} - ¦ ¦--EQ_ASSIGN: = [0/1] {18} - ¦ °--expr: [0/0] {20} - ¦ °--NUM_CONST: TRUE [0/0] {19} - ¦--ELSE: else [0/4] {21} - °--expr: [1/0] {21.9} - ¦--expr: [0/1] {23} - ¦ °--SYMBOL: y [0/0] {22} - ¦--EQ_ASSIGN: = [0/1] {24} - °--expr: [0/0] {26} - °--NUM_CONST: FALSE [0/0] {25} + ¦--equal_assign: [0/0] {1} + ¦ ¦--expr: [0/1] {3} + ¦ ¦ °--SYMBOL: x [0/0] {2} + ¦ ¦--EQ_ASSIGN: = [0/1] {4} + ¦ °--expr: [0/0] {6} + ¦ °--NUM_CONST: 5 [0/0] {5} + °--expr: [2/0] {7} + ¦--IF: if [0/0] {8} + ¦--'(': ( [0/0] {9} + ¦--expr: [0/0] {10} + ¦ ¦--expr: [0/1] {12} + ¦ ¦ °--SYMBOL: x [0/0] {11} + ¦ ¦--GE: >= [0/1] {13} + ¦ °--expr: [0/0] {15} + ¦ °--NUM_CONST: 5 [0/0] {14} + ¦--')': ) [0/2] {16} + ¦--equal_assign: [1/1] {17} + ¦ ¦--expr: [0/1] {19} + ¦ ¦ °--SYMBOL: y [0/0] {18} + ¦ ¦--EQ_ASSIGN: = [0/1] {20} + ¦ °--expr: [0/0] {22} + ¦ °--NUM_CONST: TRUE [0/0] {21} + ¦--ELSE: else [0/4] {23} + °--equal_assign: [1/0] {24} + ¦--expr: [0/1] {26} + ¦ °--SYMBOL: y [0/0] {25} + ¦--EQ_ASSIGN: = [0/1] {27} + °--expr: [0/0] {29} + °--NUM_CONST: FALSE [0/0] {28} diff --git a/tests/testthat/relocate_eq_assign/eq_assign_multiple_tokens_eq_only-in_tree b/tests/testthat/relocate_eq_assign/eq_assign_multiple_tokens_eq_only-in_tree index 996843229..3f4a82b66 100644 --- a/tests/testthat/relocate_eq_assign/eq_assign_multiple_tokens_eq_only-in_tree +++ b/tests/testthat/relocate_eq_assign/eq_assign_multiple_tokens_eq_only-in_tree @@ -1,104 +1,103 @@ ROOT (token: short_text [lag_newlines/spaces] {pos_id}) - ¦--expr: [0/0] {0.9} - ¦ ¦--expr: [0/1] {2} - ¦ ¦ °--SYMBOL: a [0/0] {1} - ¦ ¦--EQ_ASSIGN: = [0/1] {3} - ¦ ¦--expr: [0/1] {5} - ¦ ¦ °--SYMBOL: b [0/0] {4} - ¦ ¦--EQ_ASSIGN: = [0/1] {6} - ¦ ¦--expr: [0/1] {8} - ¦ ¦ °--SYMBOL: c [0/0] {7} - ¦ ¦--EQ_ASSIGN: = [0/1] {9} + ¦--equal_assign: [0/0] {1} + ¦ ¦--expr: [0/1] {3} + ¦ ¦ °--SYMBOL: a [0/0] {2} + ¦ ¦--EQ_ASSIGN: = [0/1] {4} + ¦ ¦--expr: [0/1] {7} + ¦ ¦ °--SYMBOL: b [0/0] {6} + ¦ ¦--EQ_ASSIGN: = [0/1] {8} ¦ ¦--expr: [0/1] {11} - ¦ ¦ °--SYMBOL: d [0/0] {10} + ¦ ¦ °--SYMBOL: c [0/0] {10} ¦ ¦--EQ_ASSIGN: = [0/1] {12} - ¦ ¦--expr: [0/1] {14} - ¦ ¦ °--SYMBOL: e [0/0] {13} - ¦ ¦--EQ_ASSIGN: = [0/1] {15} - ¦ ¦--expr: [0/7] {17} - ¦ ¦ °--SYMBOL: f [0/0] {16} - ¦ ¦--EQ_ASSIGN: = [0/1] {18} - ¦ ¦--expr: [0/1] {20} - ¦ ¦ °--SYMBOL: g [0/0] {19} - ¦ ¦--EQ_ASSIGN: = [0/1] {21} - ¦ °--expr: [0/0] {23} - ¦ °--NUM_CONST: 4 [0/0] {22} - ¦--expr: [1/0] {24} - ¦ ¦--expr: [0/1] {26} - ¦ ¦ °--SYMBOL: a [0/0] {25} - ¦ ¦--LEFT_ASSIGN: <- [0/1] {27} - ¦ °--expr: [0/0] {29} - ¦ °--NUM_CONST: 3 [0/0] {28} - ¦--';': ; [0/1] {30} - ¦--expr: [0/0] {30.9} - ¦ ¦--expr: [0/1] {32} - ¦ ¦ °--SYMBOL: b [0/0] {31} - ¦ ¦--EQ_ASSIGN: = [0/1] {33} - ¦ ¦--expr: [0/1] {35} - ¦ ¦ °--SYMBOL: c [0/0] {34} - ¦ ¦--EQ_ASSIGN: = [0/1] {36} - ¦ ¦--expr: [0/1] {38} - ¦ ¦ °--SYMBOL: d [0/0] {37} - ¦ ¦--EQ_ASSIGN: = [0/1] {39} - ¦ °--expr: [0/0] {40} - ¦ ¦--expr: [0/1] {42} - ¦ ¦ °--SYMBOL: ey [0/0] {41} - ¦ ¦--LEFT_ASSIGN: <- [0/1] {43} - ¦ °--expr: [0/0] {45} - ¦ °--NUM_CONST: 4 [0/0] {44} - ¦--expr: [1/0] {46} + ¦ ¦--expr: [0/1] {15} + ¦ ¦ °--SYMBOL: d [0/0] {14} + ¦ ¦--EQ_ASSIGN: = [0/1] {16} + ¦ ¦--expr: [0/1] {19} + ¦ ¦ °--SYMBOL: e [0/0] {18} + ¦ ¦--EQ_ASSIGN: = [0/1] {20} + ¦ ¦--expr: [0/7] {23} + ¦ ¦ °--SYMBOL: f [0/0] {22} + ¦ ¦--EQ_ASSIGN: = [0/1] {24} + ¦ ¦--expr: [0/1] {27} + ¦ ¦ °--SYMBOL: g [0/0] {26} + ¦ ¦--EQ_ASSIGN: = [0/1] {28} + ¦ °--expr: [0/0] {30} + ¦ °--NUM_CONST: 4 [0/0] {29} + ¦--expr: [1/0] {31} + ¦ ¦--expr: [0/1] {33} + ¦ ¦ °--SYMBOL: a [0/0] {32} + ¦ ¦--LEFT_ASSIGN: <- [0/1] {34} + ¦ °--expr: [0/0] {36} + ¦ °--NUM_CONST: 3 [0/0] {35} + ¦--';': ; [0/1] {37} + ¦--equal_assign: [0/0] {38} + ¦ ¦--expr: [0/1] {40} + ¦ ¦ °--SYMBOL: b [0/0] {39} + ¦ ¦--EQ_ASSIGN: = [0/1] {41} + ¦ ¦--expr: [0/1] {44} + ¦ ¦ °--SYMBOL: c [0/0] {43} + ¦ ¦--EQ_ASSIGN: = [0/1] {45} ¦ ¦--expr: [0/1] {48} - ¦ ¦ °--SYMBOL: a [0/0] {47} - ¦ ¦--LEFT_ASSIGN: <- [0/1] {49} - ¦ °--expr: [0/0] {51} - ¦ °--NUM_CONST: 3 [0/0] {50} - ¦--';': ; [0/1] {52} - ¦--expr: [0/0] {52.9} - ¦ ¦--expr: [0/1] {54} - ¦ ¦ °--SYMBOL: b [0/0] {53} - ¦ ¦--EQ_ASSIGN: = [0/1] {55} - ¦ ¦--expr: [0/1] {57} - ¦ ¦ °--SYMBOL: c [0/0] {56} - ¦ ¦--EQ_ASSIGN: = [0/1] {58} - ¦ ¦--expr: [0/1] {59} - ¦ ¦ ¦--expr: [0/1] {61} - ¦ ¦ ¦ °--SYMBOL: d [0/0] {60} - ¦ ¦ ¦--LEFT_ASSIGN: <- [0/1] {62} - ¦ ¦ °--expr: [0/0] {64} - ¦ ¦ °--SYMBOL: ey [0/0] {63} - ¦ ¦--EQ_ASSIGN: = [0/1] {65} - ¦ °--expr: [0/0] {67} - ¦ °--NUM_CONST: 4 [0/0] {66} - ¦--expr: [1/0] {67.9} + ¦ ¦ °--SYMBOL: d [0/0] {47} + ¦ ¦--EQ_ASSIGN: = [0/1] {49} + ¦ ¦--expr: [0/1] {52} + ¦ ¦ °--SYMBOL: ey [0/0] {51} + ¦ ¦--LEFT_ASSIGN: <- [0/1] {53} + ¦ °--expr: [0/0] {55} + ¦ °--NUM_CONST: 4 [0/0] {54} + ¦--expr: [1/0] {56} + ¦ ¦--expr: [0/1] {58} + ¦ ¦ °--SYMBOL: a [0/0] {57} + ¦ ¦--LEFT_ASSIGN: <- [0/1] {59} + ¦ °--expr: [0/0] {61} + ¦ °--NUM_CONST: 3 [0/0] {60} + ¦--';': ; [0/1] {62} + ¦--equal_assign: [0/0] {63} + ¦ ¦--expr: [0/1] {65} + ¦ ¦ °--SYMBOL: b [0/0] {64} + ¦ ¦--EQ_ASSIGN: = [0/1] {66} ¦ ¦--expr: [0/1] {69} - ¦ ¦ °--SYMBOL: ff [0/0] {68} + ¦ ¦ °--SYMBOL: c [0/0] {68} ¦ ¦--EQ_ASSIGN: = [0/1] {70} - ¦ °--expr: [0/0] {72} - ¦ °--NUM_CONST: 3 [0/0] {71} - ¦--';': ; [0/1] {73} - ¦--expr: [0/1] {73.9} - ¦ ¦--expr: [0/1] {75} - ¦ ¦ °--SYMBOL: b [0/0] {74} - ¦ ¦--EQ_ASSIGN: = [0/1] {76} - ¦ ¦--expr: [0/1] {78} - ¦ ¦ °--SYMBOL: c [0/0] {77} - ¦ ¦--EQ_ASSIGN: = [0/1] {79} - ¦ ¦--expr: [0/1] {81} - ¦ ¦ °--SYMBOL: d [0/0] {80} - ¦ ¦--EQ_ASSIGN: = [0/1] {82} - ¦ °--expr: [0/0] {84} - ¦ °--NUM_CONST: 3 [0/0] {83} - ¦--';': ; [0/1] {85} - ¦--expr: [0/0] {85.9} - ¦ ¦--expr: [0/1] {87} - ¦ ¦ °--SYMBOL: g [0/0] {86} - ¦ ¦--EQ_ASSIGN: = [0/1] {88} - ¦ °--expr: [0/0] {90} - ¦ °--NUM_CONST: 4 [0/0] {89} - ¦--';': ; [0/1] {91} - °--expr: [0/0] {91.9} - ¦--expr: [0/1] {93} - ¦ °--SYMBOL: ge [0/0] {92} - ¦--EQ_ASSIGN: = [0/1] {94} - °--expr: [0/0] {96} - °--NUM_CONST: 5 [0/0] {95} + ¦ ¦--expr: [0/1] {72} + ¦ ¦ ¦--expr: [0/1] {74} + ¦ ¦ ¦ °--SYMBOL: d [0/0] {73} + ¦ ¦ ¦--LEFT_ASSIGN: <- [0/1] {75} + ¦ ¦ °--expr: [0/0] {77} + ¦ ¦ °--SYMBOL: ey [0/0] {76} + ¦ ¦--EQ_ASSIGN: = [0/1] {78} + ¦ °--expr: [0/0] {80} + ¦ °--NUM_CONST: 4 [0/0] {79} + ¦--equal_assign: [1/0] {81} + ¦ ¦--expr: [0/1] {83} + ¦ ¦ °--SYMBOL: ff [0/0] {82} + ¦ ¦--EQ_ASSIGN: = [0/1] {84} + ¦ °--expr: [0/0] {86} + ¦ °--NUM_CONST: 3 [0/0] {85} + ¦--';': ; [0/1] {87} + ¦--equal_assign: [0/1] {88} + ¦ ¦--expr: [0/1] {90} + ¦ ¦ °--SYMBOL: b [0/0] {89} + ¦ ¦--EQ_ASSIGN: = [0/1] {91} + ¦ ¦--expr: [0/1] {94} + ¦ ¦ °--SYMBOL: c [0/0] {93} + ¦ ¦--EQ_ASSIGN: = [0/1] {95} + ¦ ¦--expr: [0/1] {98} + ¦ ¦ °--SYMBOL: d [0/0] {97} + ¦ ¦--EQ_ASSIGN: = [0/1] {99} + ¦ °--expr: [0/0] {101} + ¦ °--NUM_CONST: 3 [0/0] {100} + ¦--';': ; [0/1] {102} + ¦--equal_assign: [0/0] {103} + ¦ ¦--expr: [0/1] {105} + ¦ ¦ °--SYMBOL: g [0/0] {104} + ¦ ¦--EQ_ASSIGN: = [0/1] {106} + ¦ °--expr: [0/0] {108} + ¦ °--NUM_CONST: 4 [0/0] {107} + ¦--';': ; [0/1] {109} + °--equal_assign: [0/0] {110} + ¦--expr: [0/1] {112} + ¦ °--SYMBOL: ge [0/0] {111} + ¦--EQ_ASSIGN: = [0/1] {113} + °--expr: [0/0] {115} + °--NUM_CONST: 5 [0/0] {114} diff --git a/tests/testthat/relocate_eq_assign/eq_assign_multiple_tokens_mixed-in_tree b/tests/testthat/relocate_eq_assign/eq_assign_multiple_tokens_mixed-in_tree index 7229e2d75..4eb77d4a0 100644 --- a/tests/testthat/relocate_eq_assign/eq_assign_multiple_tokens_mixed-in_tree +++ b/tests/testthat/relocate_eq_assign/eq_assign_multiple_tokens_mixed-in_tree @@ -1,26 +1,25 @@ ROOT (token: short_text [lag_newlines/spaces] {pos_id}) - °--expr: [0/0] {0.9} - ¦--expr: [0/1] {2} - ¦ °--SYMBOL: a [0/0] {1} - ¦--EQ_ASSIGN: = [0/1] {3} - ¦--expr: [0/1] {5} - ¦ °--SYMBOL: b [0/0] {4} - ¦--EQ_ASSIGN: = [0/1] {6} - ¦--expr: [0/1] {8} - ¦ °--SYMBOL: c [0/0] {7} - ¦--EQ_ASSIGN: = [0/1] {9} + °--equal_assign: [0/0] {1} + ¦--expr: [0/1] {3} + ¦ °--SYMBOL: a [0/0] {2} + ¦--EQ_ASSIGN: = [0/1] {4} + ¦--expr: [0/1] {7} + ¦ °--SYMBOL: b [0/0] {6} + ¦--EQ_ASSIGN: = [0/1] {8} ¦--expr: [0/1] {11} - ¦ °--SYMBOL: d [0/0] {10} + ¦ °--SYMBOL: c [0/0] {10} ¦--EQ_ASSIGN: = [0/1] {12} - ¦--expr: [0/1] {14} - ¦ °--SYMBOL: e [0/0] {13} - ¦--EQ_ASSIGN: = [0/1] {15} - ¦--expr: [0/7] {17} - ¦ °--SYMBOL: f [0/0] {16} - ¦--EQ_ASSIGN: = [0/1] {18} - °--expr: [0/0] {19} - ¦--expr: [0/1] {21} - ¦ °--SYMBOL: g [0/0] {20} - ¦--LEFT_ASSIGN: <- [0/1] {22} - °--expr: [0/0] {24} - °--NUM_CONST: 4 [0/0] {23} + ¦--expr: [0/1] {15} + ¦ °--SYMBOL: d [0/0] {14} + ¦--EQ_ASSIGN: = [0/1] {16} + ¦--expr: [0/1] {19} + ¦ °--SYMBOL: e [0/0] {18} + ¦--EQ_ASSIGN: = [0/1] {20} + ¦--expr: [0/7] {23} + ¦ °--SYMBOL: f [0/0] {22} + ¦--EQ_ASSIGN: = [0/1] {24} + ¦--expr: [0/1] {27} + ¦ °--SYMBOL: g [0/0] {26} + ¦--LEFT_ASSIGN: <- [0/1] {28} + °--expr: [0/0] {30} + °--NUM_CONST: 4 [0/0] {29} diff --git a/tests/testthat/roxygen-examples-complete/2-one-function-examples-last-proper-run-in_tree b/tests/testthat/roxygen-examples-complete/2-one-function-examples-last-proper-run-in_tree index 1c39fca04..1d5b94938 100644 --- a/tests/testthat/roxygen-examples-complete/2-one-function-examples-last-proper-run-in_tree +++ b/tests/testthat/roxygen-examples-complete/2-one-function-examples-last-proper-run-in_tree @@ -10,9 +10,9 @@ ROOT (token: short_text [lag_newlines/spaces] {pos_id}) ¦--COMMENT: #' [1/0] {9} ¦--COMMENT: #' [1/0] {10} ¦--COMMENT: #' ) [1/0] {11} - °--expr: [1/0] {11.9} - ¦--expr: [0/1] {13} - ¦ °--SYMBOL: a [0/0] {12} - ¦--EQ_ASSIGN: = [0/1] {14} - °--expr: [0/0] {16} - °--SYMBOL: call [0/0] {15} + °--equal_assign: [1/0] {12} + ¦--expr: [0/1] {14} + ¦ °--SYMBOL: a [0/0] {13} + ¦--EQ_ASSIGN: = [0/1] {15} + °--expr: [0/0] {17} + °--SYMBOL: call [0/0] {16} diff --git a/tests/testthat/scope_argument/scope_indention-in_tree b/tests/testthat/scope_argument/scope_indention-in_tree index ec4bddcb1..352a89b73 100644 --- a/tests/testthat/scope_argument/scope_indention-in_tree +++ b/tests/testthat/scope_argument/scope_indention-in_tree @@ -47,50 +47,50 @@ ROOT (token: short_text [lag_newlines/spaces] {pos_id}) ¦ ¦ °--'}': } [1/0] {47} ¦ °--')': ) [0/0] {48} ¦--COMMENT: # do [2/0] {49} - ¦--expr: [1/0] {49.9} - ¦ ¦--expr: [0/1] {51} - ¦ ¦ °--SYMBOL: a [0/0] {50} - ¦ ¦--EQ_ASSIGN: = [0/1] {52} - ¦ °--expr: [0/0] {54} - ¦ °--NUM_CONST: 3 [0/0] {53} - ¦--expr: [1/0] {55} - ¦ ¦--expr: [0/0] {57} - ¦ ¦ °--SYMBOL_FUNCTION_CALL: data_ [0/0] {56} - ¦ ¦--'(': ( [0/0] {58} - ¦ ¦--SYMBOL_SUB: a [0/1] {59} - ¦ ¦--EQ_SUB: = [0/1] {60} - ¦ ¦--expr: [0/0] {62} - ¦ ¦ °--NUM_CONST: 3 [0/0] {61} - ¦ °--')': ) [0/0] {63} - ¦--COMMENT: # do [2/0] {64} - ¦--expr: [1/0] {65} - ¦ ¦--expr: [0/1] {67} - ¦ ¦ °--SYMBOL: a [0/0] {66} - ¦ ¦--LEFT_ASSIGN: <- [0/1] {68} - ¦ °--expr: [0/0] {69} - ¦ ¦--FUNCTION: funct [0/0] {70} - ¦ ¦--'(': ( [0/0] {71} - ¦ ¦--SYMBOL_FORMALS: x [0/0] {72} - ¦ ¦--')': ) [0/1] {73} - ¦ °--expr: [0/0] {74} - ¦ ¦--expr: [0/1] {76} - ¦ ¦ °--SYMBOL: x [0/0] {75} - ¦ ¦--'+': + [0/1] {77} - ¦ °--expr: [0/0] {79} - ¦ °--NUM_CONST: 1 [0/0] {78} - ¦--';': ; [0/0] {80} - ¦--expr: [0/0] {82} - ¦ °--SYMBOL: b [0/0] {81} - ¦--';': ; [0/0] {83} - ¦--expr: [0/0] {85} - ¦ °--SYMBOL: c [0/0] {84} - ¦--COMMENT: # don [2/0] {86} - °--expr: [1/0] {87} - ¦--expr: [0/1] {90} - ¦ °--SYMBOL: a [0/0] {89} - ¦--SPECIAL-PIPE: %>% [0/2] {91} - ¦--expr: [1/1] {93} - ¦ °--SYMBOL: b [0/0] {92} - ¦--SPECIAL-PIPE: %>% [0/2] {94} - °--expr: [1/0] {96} - °--SYMBOL: c [0/0] {95} + ¦--equal_assign: [1/0] {50} + ¦ ¦--expr: [0/1] {52} + ¦ ¦ °--SYMBOL: a [0/0] {51} + ¦ ¦--EQ_ASSIGN: = [0/1] {53} + ¦ °--expr: [0/0] {55} + ¦ °--NUM_CONST: 3 [0/0] {54} + ¦--expr: [1/0] {56} + ¦ ¦--expr: [0/0] {58} + ¦ ¦ °--SYMBOL_FUNCTION_CALL: data_ [0/0] {57} + ¦ ¦--'(': ( [0/0] {59} + ¦ ¦--SYMBOL_SUB: a [0/1] {60} + ¦ ¦--EQ_SUB: = [0/1] {61} + ¦ ¦--expr: [0/0] {63} + ¦ ¦ °--NUM_CONST: 3 [0/0] {62} + ¦ °--')': ) [0/0] {64} + ¦--COMMENT: # do [2/0] {65} + ¦--expr: [1/0] {66} + ¦ ¦--expr: [0/1] {68} + ¦ ¦ °--SYMBOL: a [0/0] {67} + ¦ ¦--LEFT_ASSIGN: <- [0/1] {69} + ¦ °--expr: [0/0] {70} + ¦ ¦--FUNCTION: funct [0/0] {71} + ¦ ¦--'(': ( [0/0] {72} + ¦ ¦--SYMBOL_FORMALS: x [0/0] {73} + ¦ ¦--')': ) [0/1] {74} + ¦ °--expr: [0/0] {75} + ¦ ¦--expr: [0/1] {77} + ¦ ¦ °--SYMBOL: x [0/0] {76} + ¦ ¦--'+': + [0/1] {78} + ¦ °--expr: [0/0] {80} + ¦ °--NUM_CONST: 1 [0/0] {79} + ¦--';': ; [0/0] {81} + ¦--expr: [0/0] {83} + ¦ °--SYMBOL: b [0/0] {82} + ¦--';': ; [0/0] {84} + ¦--expr: [0/0] {86} + ¦ °--SYMBOL: c [0/0] {85} + ¦--COMMENT: # don [2/0] {87} + °--expr: [1/0] {88} + ¦--expr: [0/1] {91} + ¦ °--SYMBOL: a [0/0] {90} + ¦--SPECIAL-PIPE: %>% [0/2] {92} + ¦--expr: [1/1] {94} + ¦ °--SYMBOL: b [0/0] {93} + ¦--SPECIAL-PIPE: %>% [0/2] {95} + °--expr: [1/0] {97} + °--SYMBOL: c [0/0] {96} diff --git a/tests/testthat/scope_argument/scope_line_breaks-in_tree b/tests/testthat/scope_argument/scope_line_breaks-in_tree index ec702355a..6672b318f 100644 --- a/tests/testthat/scope_argument/scope_line_breaks-in_tree +++ b/tests/testthat/scope_argument/scope_line_breaks-in_tree @@ -46,50 +46,50 @@ ROOT (token: short_text [lag_newlines/spaces] {pos_id}) ¦ ¦ °--'}': } [1/0] {46} ¦ °--')': ) [0/0] {47} ¦--COMMENT: # do [3/0] {48} - ¦--expr: [1/0] {48.9} - ¦ ¦--expr: [0/1] {50} - ¦ ¦ °--SYMBOL: a [0/0] {49} - ¦ ¦--EQ_ASSIGN: = [0/1] {51} - ¦ °--expr: [0/0] {53} - ¦ °--NUM_CONST: 3 [0/0] {52} - ¦--expr: [1/0] {54} - ¦ ¦--expr: [0/0] {56} - ¦ ¦ °--SYMBOL_FUNCTION_CALL: data_ [0/0] {55} - ¦ ¦--'(': ( [0/0] {57} - ¦ ¦--SYMBOL_SUB: a [0/1] {58} - ¦ ¦--EQ_SUB: = [0/1] {59} - ¦ ¦--expr: [0/0] {61} - ¦ ¦ °--NUM_CONST: 3 [0/0] {60} - ¦ °--')': ) [0/0] {62} - ¦--COMMENT: # do [2/0] {63} - ¦--expr: [1/0] {64} - ¦ ¦--expr: [0/1] {66} - ¦ ¦ °--SYMBOL: a [0/0] {65} - ¦ ¦--LEFT_ASSIGN: <- [0/1] {67} - ¦ °--expr: [0/0] {68} - ¦ ¦--FUNCTION: funct [0/0] {69} - ¦ ¦--'(': ( [0/0] {70} - ¦ ¦--SYMBOL_FORMALS: x [0/0] {71} - ¦ ¦--')': ) [0/1] {72} - ¦ °--expr: [0/0] {73} - ¦ ¦--expr: [0/1] {75} - ¦ ¦ °--SYMBOL: x [0/0] {74} - ¦ ¦--'+': + [0/1] {76} - ¦ °--expr: [0/0] {78} - ¦ °--NUM_CONST: 1 [0/0] {77} - ¦--';': ; [0/0] {79} - ¦--expr: [0/0] {81} - ¦ °--SYMBOL: b [0/0] {80} - ¦--';': ; [0/0] {82} - ¦--expr: [0/0] {84} - ¦ °--SYMBOL: c [0/0] {83} - ¦--COMMENT: # don [2/0] {85} - °--expr: [1/0] {86} - ¦--expr: [0/1] {89} - ¦ °--SYMBOL: a [0/0] {88} - ¦--SPECIAL-PIPE: %>% [0/2] {90} - ¦--expr: [1/1] {92} - ¦ °--SYMBOL: b [0/0] {91} - ¦--SPECIAL-PIPE: %>% [0/2] {93} - °--expr: [1/0] {95} - °--SYMBOL: c [0/0] {94} + ¦--equal_assign: [1/0] {49} + ¦ ¦--expr: [0/1] {51} + ¦ ¦ °--SYMBOL: a [0/0] {50} + ¦ ¦--EQ_ASSIGN: = [0/1] {52} + ¦ °--expr: [0/0] {54} + ¦ °--NUM_CONST: 3 [0/0] {53} + ¦--expr: [1/0] {55} + ¦ ¦--expr: [0/0] {57} + ¦ ¦ °--SYMBOL_FUNCTION_CALL: data_ [0/0] {56} + ¦ ¦--'(': ( [0/0] {58} + ¦ ¦--SYMBOL_SUB: a [0/1] {59} + ¦ ¦--EQ_SUB: = [0/1] {60} + ¦ ¦--expr: [0/0] {62} + ¦ ¦ °--NUM_CONST: 3 [0/0] {61} + ¦ °--')': ) [0/0] {63} + ¦--COMMENT: # do [2/0] {64} + ¦--expr: [1/0] {65} + ¦ ¦--expr: [0/1] {67} + ¦ ¦ °--SYMBOL: a [0/0] {66} + ¦ ¦--LEFT_ASSIGN: <- [0/1] {68} + ¦ °--expr: [0/0] {69} + ¦ ¦--FUNCTION: funct [0/0] {70} + ¦ ¦--'(': ( [0/0] {71} + ¦ ¦--SYMBOL_FORMALS: x [0/0] {72} + ¦ ¦--')': ) [0/1] {73} + ¦ °--expr: [0/0] {74} + ¦ ¦--expr: [0/1] {76} + ¦ ¦ °--SYMBOL: x [0/0] {75} + ¦ ¦--'+': + [0/1] {77} + ¦ °--expr: [0/0] {79} + ¦ °--NUM_CONST: 1 [0/0] {78} + ¦--';': ; [0/0] {80} + ¦--expr: [0/0] {82} + ¦ °--SYMBOL: b [0/0] {81} + ¦--';': ; [0/0] {83} + ¦--expr: [0/0] {85} + ¦ °--SYMBOL: c [0/0] {84} + ¦--COMMENT: # don [2/0] {86} + °--expr: [1/0] {87} + ¦--expr: [0/1] {90} + ¦ °--SYMBOL: a [0/0] {89} + ¦--SPECIAL-PIPE: %>% [0/2] {91} + ¦--expr: [1/1] {93} + ¦ °--SYMBOL: b [0/0] {92} + ¦--SPECIAL-PIPE: %>% [0/2] {94} + °--expr: [1/0] {96} + °--SYMBOL: c [0/0] {95} diff --git a/tests/testthat/scope_argument/scope_spaces-in_tree b/tests/testthat/scope_argument/scope_spaces-in_tree index 346d236fa..676dbcaf3 100644 --- a/tests/testthat/scope_argument/scope_spaces-in_tree +++ b/tests/testthat/scope_argument/scope_spaces-in_tree @@ -15,10 +15,10 @@ ROOT (token: short_text [lag_newlines/spaces] {pos_id}) ¦ ¦--'+': + [0/0] {14} ¦ °--expr: [0/0] {16} ¦ °--NUM_CONST: 1 [0/0] {15} - ¦--expr: [1/4] {16.9} - ¦ ¦--expr: [0/0] {18} - ¦ ¦ °--SYMBOL: d [0/0] {17} - ¦ ¦--EQ_ASSIGN: = [0/0] {19} - ¦ °--expr: [0/0] {21} - ¦ °--NUM_CONST: 3 [0/0] {20} - °--'}': } [1/0] {22} + ¦--equal_assign: [1/4] {17} + ¦ ¦--expr: [0/0] {19} + ¦ ¦ °--SYMBOL: d [0/0] {18} + ¦ ¦--EQ_ASSIGN: = [0/0] {20} + ¦ °--expr: [0/0] {22} + ¦ °--NUM_CONST: 3 [0/0] {21} + °--'}': } [1/0] {23} diff --git a/tests/testthat/scope_argument/scope_tokens-in_tree b/tests/testthat/scope_argument/scope_tokens-in_tree index ec702355a..6672b318f 100644 --- a/tests/testthat/scope_argument/scope_tokens-in_tree +++ b/tests/testthat/scope_argument/scope_tokens-in_tree @@ -46,50 +46,50 @@ ROOT (token: short_text [lag_newlines/spaces] {pos_id}) ¦ ¦ °--'}': } [1/0] {46} ¦ °--')': ) [0/0] {47} ¦--COMMENT: # do [3/0] {48} - ¦--expr: [1/0] {48.9} - ¦ ¦--expr: [0/1] {50} - ¦ ¦ °--SYMBOL: a [0/0] {49} - ¦ ¦--EQ_ASSIGN: = [0/1] {51} - ¦ °--expr: [0/0] {53} - ¦ °--NUM_CONST: 3 [0/0] {52} - ¦--expr: [1/0] {54} - ¦ ¦--expr: [0/0] {56} - ¦ ¦ °--SYMBOL_FUNCTION_CALL: data_ [0/0] {55} - ¦ ¦--'(': ( [0/0] {57} - ¦ ¦--SYMBOL_SUB: a [0/1] {58} - ¦ ¦--EQ_SUB: = [0/1] {59} - ¦ ¦--expr: [0/0] {61} - ¦ ¦ °--NUM_CONST: 3 [0/0] {60} - ¦ °--')': ) [0/0] {62} - ¦--COMMENT: # do [2/0] {63} - ¦--expr: [1/0] {64} - ¦ ¦--expr: [0/1] {66} - ¦ ¦ °--SYMBOL: a [0/0] {65} - ¦ ¦--LEFT_ASSIGN: <- [0/1] {67} - ¦ °--expr: [0/0] {68} - ¦ ¦--FUNCTION: funct [0/0] {69} - ¦ ¦--'(': ( [0/0] {70} - ¦ ¦--SYMBOL_FORMALS: x [0/0] {71} - ¦ ¦--')': ) [0/1] {72} - ¦ °--expr: [0/0] {73} - ¦ ¦--expr: [0/1] {75} - ¦ ¦ °--SYMBOL: x [0/0] {74} - ¦ ¦--'+': + [0/1] {76} - ¦ °--expr: [0/0] {78} - ¦ °--NUM_CONST: 1 [0/0] {77} - ¦--';': ; [0/0] {79} - ¦--expr: [0/0] {81} - ¦ °--SYMBOL: b [0/0] {80} - ¦--';': ; [0/0] {82} - ¦--expr: [0/0] {84} - ¦ °--SYMBOL: c [0/0] {83} - ¦--COMMENT: # don [2/0] {85} - °--expr: [1/0] {86} - ¦--expr: [0/1] {89} - ¦ °--SYMBOL: a [0/0] {88} - ¦--SPECIAL-PIPE: %>% [0/2] {90} - ¦--expr: [1/1] {92} - ¦ °--SYMBOL: b [0/0] {91} - ¦--SPECIAL-PIPE: %>% [0/2] {93} - °--expr: [1/0] {95} - °--SYMBOL: c [0/0] {94} + ¦--equal_assign: [1/0] {49} + ¦ ¦--expr: [0/1] {51} + ¦ ¦ °--SYMBOL: a [0/0] {50} + ¦ ¦--EQ_ASSIGN: = [0/1] {52} + ¦ °--expr: [0/0] {54} + ¦ °--NUM_CONST: 3 [0/0] {53} + ¦--expr: [1/0] {55} + ¦ ¦--expr: [0/0] {57} + ¦ ¦ °--SYMBOL_FUNCTION_CALL: data_ [0/0] {56} + ¦ ¦--'(': ( [0/0] {58} + ¦ ¦--SYMBOL_SUB: a [0/1] {59} + ¦ ¦--EQ_SUB: = [0/1] {60} + ¦ ¦--expr: [0/0] {62} + ¦ ¦ °--NUM_CONST: 3 [0/0] {61} + ¦ °--')': ) [0/0] {63} + ¦--COMMENT: # do [2/0] {64} + ¦--expr: [1/0] {65} + ¦ ¦--expr: [0/1] {67} + ¦ ¦ °--SYMBOL: a [0/0] {66} + ¦ ¦--LEFT_ASSIGN: <- [0/1] {68} + ¦ °--expr: [0/0] {69} + ¦ ¦--FUNCTION: funct [0/0] {70} + ¦ ¦--'(': ( [0/0] {71} + ¦ ¦--SYMBOL_FORMALS: x [0/0] {72} + ¦ ¦--')': ) [0/1] {73} + ¦ °--expr: [0/0] {74} + ¦ ¦--expr: [0/1] {76} + ¦ ¦ °--SYMBOL: x [0/0] {75} + ¦ ¦--'+': + [0/1] {77} + ¦ °--expr: [0/0] {79} + ¦ °--NUM_CONST: 1 [0/0] {78} + ¦--';': ; [0/0] {80} + ¦--expr: [0/0] {82} + ¦ °--SYMBOL: b [0/0] {81} + ¦--';': ; [0/0] {83} + ¦--expr: [0/0] {85} + ¦ °--SYMBOL: c [0/0] {84} + ¦--COMMENT: # don [2/0] {86} + °--expr: [1/0] {87} + ¦--expr: [0/1] {90} + ¦ °--SYMBOL: a [0/0] {89} + ¦--SPECIAL-PIPE: %>% [0/2] {91} + ¦--expr: [1/1] {93} + ¦ °--SYMBOL: b [0/0] {92} + ¦--SPECIAL-PIPE: %>% [0/2] {94} + °--expr: [1/0] {96} + °--SYMBOL: c [0/0] {95} diff --git a/tests/testthat/strict/non_strict-in_tree b/tests/testthat/strict/non_strict-in_tree index f28411194..76fd9cca5 100644 --- a/tests/testthat/strict/non_strict-in_tree +++ b/tests/testthat/strict/non_strict-in_tree @@ -294,449 +294,449 @@ ROOT (token: short_text [lag_newlines/spaces] {pos_id}) ¦ ¦ ¦--RIGHT_ASSIGN: -> [0/0] {293} ¦ ¦ °--expr: [0/0] {295} ¦ ¦ °--SYMBOL: b [0/0] {294} - ¦ ¦--expr: [1/2] {295.9} - ¦ ¦ ¦--expr: [0/0] {297} - ¦ ¦ ¦ °--SYMBOL: a [0/0] {296} - ¦ ¦ ¦--EQ_ASSIGN: = [0/0] {298} - ¦ ¦ °--expr: [0/0] {300} - ¦ ¦ °--SYMBOL: b [0/0] {299} - ¦ ¦--expr: [1/2] {301} - ¦ ¦ ¦--expr: [0/0] {303} - ¦ ¦ ¦ °--SYMBOL: a [0/0] {302} - ¦ ¦ ¦--LT: < [0/0] {304} - ¦ ¦ °--expr: [0/0] {306} - ¦ ¦ °--SYMBOL: b [0/0] {305} - ¦ ¦--expr: [1/2] {307} - ¦ ¦ ¦--expr: [0/0] {309} - ¦ ¦ ¦ °--SYMBOL: a [0/0] {308} - ¦ ¦ ¦--GT: > [0/0] {310} - ¦ ¦ °--expr: [0/0] {312} - ¦ ¦ °--SYMBOL: b [0/0] {311} - ¦ ¦--expr: [1/2] {313} - ¦ ¦ ¦--expr: [0/0] {315} - ¦ ¦ ¦ °--SYMBOL: a [0/0] {314} - ¦ ¦ ¦--'*': * [0/0] {316} - ¦ ¦ °--expr: [0/0] {318} - ¦ ¦ °--SYMBOL: b [0/0] {317} - ¦ ¦--expr: [1/2] {319} - ¦ ¦ ¦--expr: [0/0] {321} - ¦ ¦ ¦ °--SYMBOL: a [0/0] {320} - ¦ ¦ ¦--'/': / [0/0] {322} - ¦ ¦ °--expr: [0/0] {324} - ¦ ¦ °--SYMBOL: b [0/0] {323} - ¦ ¦--expr: [1/2] {325} - ¦ ¦ ¦--expr: [0/0] {327} - ¦ ¦ ¦ °--SYMBOL: a [0/0] {326} - ¦ ¦ ¦--'^': ^ [0/0] {328} - ¦ ¦ °--expr: [0/0] {330} - ¦ ¦ °--SYMBOL: b [0/0] {329} - ¦ ¦--expr: [1/2] {331} - ¦ ¦ ¦--expr: [0/0] {333} - ¦ ¦ ¦ °--SYMBOL: a [0/0] {332} - ¦ ¦ ¦--AND: & [0/0] {334} - ¦ ¦ °--expr: [0/0] {336} - ¦ ¦ °--SYMBOL: b [0/0] {335} - ¦ ¦--expr: [1/2] {337} - ¦ ¦ ¦--expr: [0/0] {339} - ¦ ¦ ¦ °--SYMBOL: a [0/0] {338} - ¦ ¦ ¦--OR: | [0/0] {340} - ¦ ¦ °--expr: [0/0] {342} - ¦ ¦ °--SYMBOL: b [0/0] {341} - ¦ ¦--expr: [1/2] {343} - ¦ ¦ ¦--expr: [0/0] {345} - ¦ ¦ ¦ °--SYMBOL: a [0/0] {344} - ¦ ¦ ¦--LEFT_ASSIGN: := [0/0] {346} - ¦ ¦ °--expr: [0/0] {348} - ¦ ¦ °--SYMBOL: b [0/0] {347} - ¦ ¦--expr: [2/2] {349} - ¦ ¦ ¦--expr: [0/0] {351} - ¦ ¦ ¦ °--SYMBOL: a [0/0] {350} - ¦ ¦ ¦--'+': + [0/0] {352} - ¦ ¦ °--expr: [0/0] {354} - ¦ ¦ °--SYMBOL: b [0/0] {353} - ¦ ¦--expr: [1/2] {355} - ¦ ¦ ¦--expr: [0/0] {357} - ¦ ¦ ¦ °--SYMBOL: a [0/0] {356} - ¦ ¦ ¦--'-': - [0/0] {358} - ¦ ¦ °--expr: [0/0] {360} - ¦ ¦ °--SYMBOL: b [0/0] {359} - ¦ ¦--expr: [1/2] {361} - ¦ ¦ ¦--expr: [0/0] {363} - ¦ ¦ ¦ °--SYMBOL: a [0/0] {362} - ¦ ¦ ¦--'+': + [0/0] {364} - ¦ ¦ °--expr: [0/0] {365} - ¦ ¦ ¦--'+': + [0/0] {366} - ¦ ¦ °--expr: [0/0] {368} - ¦ ¦ °--SYMBOL: b [0/0] {367} - ¦ ¦--expr: [1/2] {369} - ¦ ¦ ¦--expr: [0/0] {371} - ¦ ¦ ¦ °--SYMBOL: a [0/0] {370} - ¦ ¦ ¦--'+': + [0/0] {372} - ¦ ¦ °--expr: [0/0] {373} - ¦ ¦ ¦--'-': - [0/0] {374} - ¦ ¦ °--expr: [0/0] {376} - ¦ ¦ °--SYMBOL: b [0/0] {375} - ¦ ¦--expr: [1/2] {377} - ¦ ¦ ¦--expr: [0/0] {379} - ¦ ¦ ¦ °--SYMBOL: a [0/0] {378} - ¦ ¦ ¦--'+': + [0/0] {380} - ¦ ¦ °--expr: [0/0] {381} - ¦ ¦ ¦--'+': + [0/0] {382} - ¦ ¦ °--expr: [0/0] {384} - ¦ ¦ °--SYMBOL: b [0/0] {383} - ¦ ¦--expr: [1/2] {385} - ¦ ¦ ¦--expr: [0/0] {387} - ¦ ¦ ¦ °--SYMBOL: a [0/0] {386} - ¦ ¦ ¦--'-': - [0/0] {388} - ¦ ¦ °--expr: [0/0] {389} - ¦ ¦ ¦--'+': + [0/0] {390} - ¦ ¦ °--expr: [0/0] {392} - ¦ ¦ °--SYMBOL: b [0/0] {391} - ¦ ¦--expr: [1/2] {393} - ¦ ¦ ¦--expr: [0/0] {395} - ¦ ¦ ¦ °--SYMBOL: a [0/0] {394} - ¦ ¦ ¦--'-': - [0/0] {396} - ¦ ¦ °--expr: [0/0] {397} - ¦ ¦ ¦--'-': - [0/0] {398} - ¦ ¦ °--expr: [0/0] {400} - ¦ ¦ °--SYMBOL: b [0/0] {399} - ¦ ¦--expr: [1/2] {401} - ¦ ¦ ¦--expr: [0/0] {403} - ¦ ¦ ¦ °--SYMBOL: a [0/0] {402} - ¦ ¦ ¦--'+': + [0/0] {404} - ¦ ¦ °--expr: [0/0] {405} - ¦ ¦ ¦--'-': - [0/0] {406} - ¦ ¦ °--expr: [0/0] {407} - ¦ ¦ ¦--'-': - [0/0] {408} - ¦ ¦ °--expr: [0/0] {410} - ¦ ¦ °--SYMBOL: b [0/0] {409} - ¦ ¦--expr: [1/2] {411} - ¦ ¦ ¦--expr: [0/0] {413} - ¦ ¦ ¦ °--SYMBOL: a [0/0] {412} - ¦ ¦ ¦--'-': - [0/0] {414} - ¦ ¦ °--expr: [0/0] {415} - ¦ ¦ ¦--'-': - [0/0] {416} - ¦ ¦ °--expr: [0/0] {417} - ¦ ¦ ¦--'+': + [0/0] {418} - ¦ ¦ °--expr: [0/0] {420} - ¦ ¦ °--SYMBOL: b [0/0] {419} - ¦ ¦--expr: [1/2] {421} - ¦ ¦ ¦--expr: [0/0] {423} - ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: call [0/0] {422} - ¦ ¦ ¦--'(': ( [0/1] {424} - ¦ ¦ ¦--expr: [0/0] {425} - ¦ ¦ ¦ ¦--'+': + [0/1] {426} - ¦ ¦ ¦ °--expr: [0/0] {428} - ¦ ¦ ¦ °--SYMBOL: a [0/0] {427} - ¦ ¦ °--')': ) [0/0] {429} - ¦ ¦--expr: [1/2] {430} - ¦ ¦ ¦--expr: [0/0] {432} - ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: call [0/0] {431} - ¦ ¦ ¦--'(': ( [0/1] {433} - ¦ ¦ ¦--expr: [0/0] {434} - ¦ ¦ ¦ ¦--'-': - [0/1] {435} - ¦ ¦ ¦ °--expr: [0/0] {437} - ¦ ¦ ¦ °--SYMBOL: a [0/0] {436} - ¦ ¦ °--')': ) [0/0] {438} - ¦ ¦--expr: [1/2] {439} - ¦ ¦ ¦--expr: [0/0] {441} - ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: call [0/0] {440} - ¦ ¦ ¦--'(': ( [0/0] {442} - ¦ ¦ ¦--expr: [0/0] {444} - ¦ ¦ ¦ °--NUM_CONST: 5 [0/0] {443} - ¦ ¦ ¦--',': , [0/1] {445} - ¦ ¦ ¦--expr: [0/0] {446} - ¦ ¦ ¦ ¦--'+': + [0/1] {447} - ¦ ¦ ¦ °--expr: [0/0] {449} - ¦ ¦ ¦ °--SYMBOL: a [0/0] {448} - ¦ ¦ °--')': ) [0/0] {450} - ¦ ¦--expr: [1/2] {451} - ¦ ¦ ¦--expr: [0/0] {453} - ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: call [0/0] {452} - ¦ ¦ ¦--'(': ( [0/0] {454} - ¦ ¦ ¦--expr: [0/0] {456} - ¦ ¦ ¦ °--NUM_CONST: 5 [0/0] {455} - ¦ ¦ ¦--',': , [0/1] {457} - ¦ ¦ ¦--expr: [0/0] {458} - ¦ ¦ ¦ ¦--'-': - [0/1] {459} - ¦ ¦ ¦ °--expr: [0/0] {461} - ¦ ¦ ¦ °--SYMBOL: a [0/0] {460} - ¦ ¦ °--')': ) [0/0] {462} - ¦ ¦--COMMENT: # Onl [2/2] {463} - ¦ ¦--expr: [1/2] {464} - ¦ ¦ ¦--expr: [0/0] {466} - ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: call [0/0] {465} - ¦ ¦ ¦--'(': ( [0/4] {467} - ¦ ¦ ¦--expr: [1/0] {469} - ¦ ¦ ¦ °--SYMBOL: prese [0/0] {468} - ¦ ¦ ¦--',': , [0/1] {470} - ¦ ¦ ¦--expr: [0/0] {472} - ¦ ¦ ¦ °--SYMBOL: dista [0/0] {471} - ¦ ¦ ¦--',': , [0/4] {473} - ¦ ¦ ¦--expr: [1/0] {475} - ¦ ¦ ¦ °--SYMBOL: after [0/0] {474} - ¦ ¦ ¦--',': , [0/5] {476} - ¦ ¦ ¦--expr: [0/0] {478} - ¦ ¦ ¦ °--SYMBOL: comma [0/0] {477} - ¦ ¦ ¦--',': , [0/4] {479} - ¦ ¦ ¦--expr: [1/0] {481} - ¦ ¦ ¦ °--SYMBOL: given [0/0] {480} - ¦ ¦ ¦--',': , [0/0] {482} - ¦ ¦ ¦--expr: [0/2] {484} - ¦ ¦ ¦ °--SYMBOL: one [0/0] {483} - ¦ ¦ °--')': ) [1/0] {485} - ¦ ¦--expr: [2/2] {486} - ¦ ¦ ¦--IF: if [0/0] {487} - ¦ ¦ ¦--'(': ( [0/0] {488} - ¦ ¦ ¦--expr: [0/0] {490} - ¦ ¦ ¦ °--NUM_CONST: TRUE [0/0] {489} - ¦ ¦ ¦--')': ) [0/0] {491} - ¦ ¦ °--expr: [0/0] {492} - ¦ ¦ ¦--'{': { [0/4] {493} - ¦ ¦ ¦--expr: [1/2] {495} - ¦ ¦ ¦ °--NUM_CONST: FALSE [0/0] {494} - ¦ ¦ °--'}': } [1/0] {496} - ¦ ¦--expr: [2/2] {497} - ¦ ¦ ¦--IF: if [0/0] {498} - ¦ ¦ ¦--'(': ( [0/0] {499} - ¦ ¦ ¦--expr: [0/0] {501} - ¦ ¦ ¦ °--NUM_CONST: TRUE [0/0] {500} - ¦ ¦ ¦--')': ) [0/0] {502} - ¦ ¦ ¦--expr: [0/0] {503} - ¦ ¦ ¦ ¦--'{': { [0/4] {504} - ¦ ¦ ¦ ¦--expr: [1/2] {506} - ¦ ¦ ¦ ¦ °--NUM_CONST: FALSE [0/0] {505} - ¦ ¦ ¦ °--'}': } [1/0] {507} - ¦ ¦ ¦--ELSE: else [0/0] {508} - ¦ ¦ °--expr: [0/0] {509} - ¦ ¦ ¦--'{': { [0/4] {510} - ¦ ¦ ¦--expr: [1/2] {512} - ¦ ¦ ¦ °--NUM_CONST: TRUE [0/0] {511} - ¦ ¦ °--'}': } [1/0] {513} - ¦ ¦--expr: [2/2] {514} - ¦ ¦ ¦--WHILE: while [0/0] {515} - ¦ ¦ ¦--'(': ( [0/0] {516} - ¦ ¦ ¦--expr: [0/0] {518} - ¦ ¦ ¦ °--NUM_CONST: TRUE [0/0] {517} - ¦ ¦ ¦--')': ) [0/0] {519} - ¦ ¦ °--expr: [0/0] {520} - ¦ ¦ ¦--'{': { [0/4] {521} - ¦ ¦ ¦--expr: [1/2] {523} - ¦ ¦ ¦ °--NUM_CONST: FALSE [0/0] {522} - ¦ ¦ °--'}': } [1/0] {524} - ¦ ¦--expr: [2/2] {525} - ¦ ¦ ¦--expr: [0/1] {527} - ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: singl [0/0] {526} - ¦ ¦ ¦--'(': ( [0/1] {528} - ¦ ¦ ¦--expr: [0/1] {530} - ¦ ¦ ¦ °--STR_CONST: "func [0/0] {529} - ¦ ¦ ¦--',': , [0/0] {531} - ¦ ¦ ¦--expr: [0/1] {533} - ¦ ¦ ¦ °--SYMBOL: call [0/0] {532} - ¦ ¦ °--')': ) [0/0] {534} - ¦ ¦--expr: [2/2] {535} - ¦ ¦ ¦--expr: [0/1] {537} - ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: multi [0/0] {536} - ¦ ¦ ¦--'(': ( [0/2] {538} - ¦ ¦ ¦--expr: [1/0] {540} - ¦ ¦ ¦ °--STR_CONST: "func [0/0] {539} - ¦ ¦ ¦--',': , [0/1] {541} - ¦ ¦ ¦--expr: [0/1] {543} - ¦ ¦ ¦ °--SYMBOL: call [0/0] {542} - ¦ ¦ °--')': ) [0/0] {544} - ¦ ¦--expr: [2/2] {545} - ¦ ¦ ¦--expr: [0/1] {547} - ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: neste [0/0] {546} - ¦ ¦ ¦--'(': ( [0/1] {548} - ¦ ¦ ¦--expr: [0/1] {549} - ¦ ¦ ¦ ¦--expr: [0/1] {551} - ¦ ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: funct [0/0] {550} - ¦ ¦ ¦ ¦--'(': ( [0/1] {552} - ¦ ¦ ¦ ¦--expr: [0/1] {554} - ¦ ¦ ¦ ¦ °--STR_CONST: "in" [0/0] {553} - ¦ ¦ ¦ ¦--',': , [0/0] {555} - ¦ ¦ ¦ ¦--expr: [0/1] {557} - ¦ ¦ ¦ ¦ °--SYMBOL: one [0/0] {556} - ¦ ¦ ¦ ¦--',': , [0/0] {558} - ¦ ¦ ¦ ¦--expr: [0/1] {560} - ¦ ¦ ¦ ¦ °--SYMBOL: line [0/0] {559} - ¦ ¦ ¦ °--')': ) [0/0] {561} - ¦ ¦ °--')': ) [0/0] {562} - ¦ ¦--expr: [2/2] {563} - ¦ ¦ ¦--expr: [0/1] {565} - ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: neste [0/0] {564} - ¦ ¦ ¦--'(': ( [0/1] {566} - ¦ ¦ ¦--expr: [0/1] {567} - ¦ ¦ ¦ ¦--expr: [0/1] {569} - ¦ ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: funct [0/0] {568} - ¦ ¦ ¦ ¦--'(': ( [0/2] {570} - ¦ ¦ ¦ ¦--expr: [1/0] {572} - ¦ ¦ ¦ ¦ °--STR_CONST: "in" [0/0] {571} - ¦ ¦ ¦ ¦--',': , [0/6] {573} - ¦ ¦ ¦ ¦--expr: [1/0] {575} - ¦ ¦ ¦ ¦ °--SYMBOL: multi [0/0] {574} - ¦ ¦ ¦ ¦--',': , [0/0] {576} - ¦ ¦ ¦ ¦--expr: [0/1] {578} - ¦ ¦ ¦ ¦ °--SYMBOL: lines [0/0] {577} - ¦ ¦ ¦ °--')': ) [0/0] {579} - ¦ ¦ °--')': ) [0/0] {580} - ¦ ¦--expr: [2/2] {581} - ¦ ¦ ¦--expr: [0/0] {583} - ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: neste [0/0] {582} - ¦ ¦ ¦--'(': ( [0/2] {584} - ¦ ¦ ¦--expr: [1/0] {585} - ¦ ¦ ¦ ¦--expr: [0/1] {587} - ¦ ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: funct [0/0] {586} - ¦ ¦ ¦ ¦--'(': ( [0/1] {588} - ¦ ¦ ¦ ¦--expr: [0/1] {590} - ¦ ¦ ¦ ¦ °--SYMBOL: with [0/0] {589} - ¦ ¦ ¦ °--')': ) [0/0] {591} - ¦ ¦ ¦--',': , [0/6] {592} - ¦ ¦ ¦--expr: [1/2] {594} - ¦ ¦ ¦ °--SYMBOL: many [0/0] {593} - ¦ ¦ ¦--',': , [1/5] {595} - ¦ ¦ ¦--expr: [0/2] {597} - ¦ ¦ ¦ °--SYMBOL: first [0/0] {596} - ¦ ¦ °--')': ) [0/0] {598} - ¦ ¦--expr: [2/2] {599} - ¦ ¦ ¦--expr: [0/0] {601} - ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: neste [0/0] {600} - ¦ ¦ ¦--'(': ( [0/4] {602} - ¦ ¦ ¦--expr: [1/0] {603} - ¦ ¦ ¦ ¦--expr: [0/1] {605} - ¦ ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: funct [0/0] {604} - ¦ ¦ ¦ ¦--'(': ( [0/1] {606} - ¦ ¦ ¦ ¦--expr: [0/1] {608} - ¦ ¦ ¦ ¦ °--SYMBOL: with [0/0] {607} - ¦ ¦ ¦ °--')': ) [0/0] {609} - ¦ ¦ ¦--',': , [0/2] {610} - ¦ ¦ ¦--COMMENT: # a c [0/4] {611} - ¦ ¦ ¦--expr: [1/1] {613} - ¦ ¦ ¦ °--SYMBOL: many [0/0] {612} - ¦ ¦ ¦--COMMENT: #more [0/4] {614} - ¦ ¦ ¦--',': , [1/5] {615} - ¦ ¦ ¦--expr: [0/2] {617} - ¦ ¦ ¦ °--SYMBOL: first [0/0] {616} - ¦ ¦ °--')': ) [0/0] {618} - ¦ ¦--expr: [2/0] {619} - ¦ ¦ ¦--expr: [0/0] {621} - ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: diffi [0/0] {620} - ¦ ¦ ¦--'(': ( [0/0] {622} - ¦ ¦ ¦--expr: [0/0] {623} - ¦ ¦ ¦ ¦--expr: [0/0] {625} - ¦ ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: neste [0/0] {624} - ¦ ¦ ¦ ¦--'(': ( [0/4] {626} - ¦ ¦ ¦ ¦--expr: [1/0] {628} - ¦ ¦ ¦ ¦ °--STR_CONST: "func [0/0] {627} - ¦ ¦ ¦ ¦--',': , [0/1] {629} - ¦ ¦ ¦ ¦--expr: [0/2] {631} - ¦ ¦ ¦ ¦ °--SYMBOL: call [0/0] {630} - ¦ ¦ ¦ °--')': ) [1/0] {632} - ¦ ¦ ¦--',': , [0/4] {633} - ¦ ¦ ¦--expr: [1/0] {635} - ¦ ¦ ¦ °--SYMBOL: with [0/0] {634} - ¦ ¦ ¦--',': , [0/1] {636} - ¦ ¦ ¦--expr: [0/0] {638} - ¦ ¦ ¦ °--SYMBOL: more [0/0] {637} - ¦ ¦ ¦--',': , [0/1] {639} - ¦ ¦ ¦--expr: [0/2] {641} - ¦ ¦ ¦ °--SYMBOL: args [0/0] {640} - ¦ ¦ °--')': ) [1/0] {642} - ¦ °--'}': } [1/0] {643} - ¦--COMMENT: # for [3/0] {644} - ¦--expr: [1/0] {645} - ¦ ¦--expr: [0/0] {647} - ¦ ¦ °--SYMBOL_FUNCTION_CALL: lm [0/0] {646} - ¦ ¦--'(': ( [0/0] {648} - ¦ ¦--expr: [0/0] {649} - ¦ ¦ ¦--expr: [0/0] {651} - ¦ ¦ ¦ °--SYMBOL: a [0/0] {650} - ¦ ¦ ¦--'~': ~ [0/0] {652} - ¦ ¦ °--expr: [0/0] {653} - ¦ ¦ ¦--expr: [0/0] {655} - ¦ ¦ ¦ °--SYMBOL: b [0/0] {654} - ¦ ¦ ¦--'+': + [0/0] {656} - ¦ ¦ °--expr: [0/0] {658} - ¦ ¦ °--SYMBOL: c [0/0] {657} - ¦ ¦--',': , [0/0] {659} - ¦ ¦--SYMBOL_SUB: data [0/0] {660} - ¦ ¦--EQ_SUB: = [0/0] {661} - ¦ ¦--expr: [0/0] {663} - ¦ ¦ °--NUM_CONST: NA [0/0] {662} - ¦ °--')': ) [0/0] {664} - ¦--expr: [1/0] {665} - ¦ ¦--expr: [0/0] {667} - ¦ ¦ °--SYMBOL_FUNCTION_CALL: lm [0/0] {666} - ¦ ¦--'(': ( [0/0] {668} - ¦ ¦--expr: [0/0] {669} - ¦ ¦ ¦--expr: [0/0] {671} - ¦ ¦ ¦ °--SYMBOL: a [0/0] {670} - ¦ ¦ ¦--'~': ~ [0/0] {672} - ¦ ¦ °--expr: [0/0] {673} - ¦ ¦ ¦--expr: [0/0] {675} - ¦ ¦ ¦ °--SYMBOL: . [0/0] {674} - ¦ ¦ ¦--'-': - [0/0] {676} - ¦ ¦ °--expr: [0/0] {678} - ¦ ¦ °--NUM_CONST: 1 [0/0] {677} - ¦ ¦--',': , [0/0] {679} - ¦ ¦--SYMBOL_SUB: data [0/0] {680} - ¦ ¦--EQ_SUB: = [0/0] {681} - ¦ ¦--expr: [0/0] {683} - ¦ ¦ °--NUM_CONST: NA [0/0] {682} - ¦ °--')': ) [0/0] {684} - ¦--expr: [1/0] {685} - ¦ ¦--expr: [0/0] {687} - ¦ ¦ °--SYMBOL: a [0/0] {686} - ¦ ¦--'~': ~ [0/0] {688} - ¦ °--expr: [0/0] {689} - ¦ ¦--expr: [0/0] {691} - ¦ ¦ °--SYMBOL: b [0/0] {690} - ¦ ¦--':': : [0/0] {692} - ¦ °--expr: [0/0] {694} - ¦ °--SYMBOL: c [0/0] {693} - ¦--expr: [1/0] {695} - ¦ ¦--expr: [0/0] {697} - ¦ ¦ °--SYMBOL: a [0/0] {696} - ¦ ¦--'~': ~ [0/0] {698} - ¦ °--expr: [0/0] {699} - ¦ ¦--expr: [0/1] {701} - ¦ ¦ °--SYMBOL: b [0/0] {700} - ¦ ¦--':': : [0/0] {702} - ¦ °--expr: [0/0] {704} - ¦ °--SYMBOL: c [0/0] {703} - ¦--expr: [1/0] {705} - ¦ ¦--expr: [0/3] {707} - ¦ ¦ °--SYMBOL: a [0/0] {706} - ¦ ¦--'~': ~ [0/3] {708} - ¦ °--expr: [0/0] {709} - ¦ ¦--expr: [0/2] {711} - ¦ ¦ °--SYMBOL: b [0/0] {710} - ¦ ¦--':': : [0/1] {712} - ¦ °--expr: [0/0] {714} - ¦ °--SYMBOL: c [0/0] {713} - ¦--expr: [2/0] {715} - ¦ ¦--'~': ~ [0/3] {716} - ¦ °--expr: [0/0] {718} - ¦ °--SYMBOL: a [0/0] {717} - ¦--expr: [1/0] {719} - ¦ ¦--'~': ~ [0/0] {720} - ¦ °--expr: [0/0] {722} - ¦ °--SYMBOL: gg [0/0] {721} - ¦--expr: [1/0] {723} - ¦ ¦--expr: [0/0] {725} - ¦ ¦ °--SYMBOL: b [0/0] {724} - ¦ ¦--'~': ~ [0/3] {726} - ¦ °--expr: [0/0] {728} - ¦ °--SYMBOL: k [0/0] {727} - °--expr: [1/0] {729} - ¦--expr: [0/0] {731} - ¦ °--SYMBOL_FUNCTION_CALL: call [0/0] {730} - ¦--'(': ( [0/0] {732} - ¦--expr: [0/0] {734} - ¦ °--NUM_CONST: 1 [0/0] {733} - ¦--',': , [0/0] {735} - ¦--expr: [0/0] {736} - ¦ ¦--'~': ~ [0/1] {737} - ¦ °--expr: [0/0] {739} - ¦ °--SYMBOL: qq [0/0] {738} - °--')': ) [0/0] {740} + ¦ ¦--equal_assign: [1/2] {296} + ¦ ¦ ¦--expr: [0/0] {298} + ¦ ¦ ¦ °--SYMBOL: a [0/0] {297} + ¦ ¦ ¦--EQ_ASSIGN: = [0/0] {299} + ¦ ¦ °--expr: [0/0] {301} + ¦ ¦ °--SYMBOL: b [0/0] {300} + ¦ ¦--expr: [1/2] {302} + ¦ ¦ ¦--expr: [0/0] {304} + ¦ ¦ ¦ °--SYMBOL: a [0/0] {303} + ¦ ¦ ¦--LT: < [0/0] {305} + ¦ ¦ °--expr: [0/0] {307} + ¦ ¦ °--SYMBOL: b [0/0] {306} + ¦ ¦--expr: [1/2] {308} + ¦ ¦ ¦--expr: [0/0] {310} + ¦ ¦ ¦ °--SYMBOL: a [0/0] {309} + ¦ ¦ ¦--GT: > [0/0] {311} + ¦ ¦ °--expr: [0/0] {313} + ¦ ¦ °--SYMBOL: b [0/0] {312} + ¦ ¦--expr: [1/2] {314} + ¦ ¦ ¦--expr: [0/0] {316} + ¦ ¦ ¦ °--SYMBOL: a [0/0] {315} + ¦ ¦ ¦--'*': * [0/0] {317} + ¦ ¦ °--expr: [0/0] {319} + ¦ ¦ °--SYMBOL: b [0/0] {318} + ¦ ¦--expr: [1/2] {320} + ¦ ¦ ¦--expr: [0/0] {322} + ¦ ¦ ¦ °--SYMBOL: a [0/0] {321} + ¦ ¦ ¦--'/': / [0/0] {323} + ¦ ¦ °--expr: [0/0] {325} + ¦ ¦ °--SYMBOL: b [0/0] {324} + ¦ ¦--expr: [1/2] {326} + ¦ ¦ ¦--expr: [0/0] {328} + ¦ ¦ ¦ °--SYMBOL: a [0/0] {327} + ¦ ¦ ¦--'^': ^ [0/0] {329} + ¦ ¦ °--expr: [0/0] {331} + ¦ ¦ °--SYMBOL: b [0/0] {330} + ¦ ¦--expr: [1/2] {332} + ¦ ¦ ¦--expr: [0/0] {334} + ¦ ¦ ¦ °--SYMBOL: a [0/0] {333} + ¦ ¦ ¦--AND: & [0/0] {335} + ¦ ¦ °--expr: [0/0] {337} + ¦ ¦ °--SYMBOL: b [0/0] {336} + ¦ ¦--expr: [1/2] {338} + ¦ ¦ ¦--expr: [0/0] {340} + ¦ ¦ ¦ °--SYMBOL: a [0/0] {339} + ¦ ¦ ¦--OR: | [0/0] {341} + ¦ ¦ °--expr: [0/0] {343} + ¦ ¦ °--SYMBOL: b [0/0] {342} + ¦ ¦--expr: [1/2] {344} + ¦ ¦ ¦--expr: [0/0] {346} + ¦ ¦ ¦ °--SYMBOL: a [0/0] {345} + ¦ ¦ ¦--LEFT_ASSIGN: := [0/0] {347} + ¦ ¦ °--expr: [0/0] {349} + ¦ ¦ °--SYMBOL: b [0/0] {348} + ¦ ¦--expr: [2/2] {350} + ¦ ¦ ¦--expr: [0/0] {352} + ¦ ¦ ¦ °--SYMBOL: a [0/0] {351} + ¦ ¦ ¦--'+': + [0/0] {353} + ¦ ¦ °--expr: [0/0] {355} + ¦ ¦ °--SYMBOL: b [0/0] {354} + ¦ ¦--expr: [1/2] {356} + ¦ ¦ ¦--expr: [0/0] {358} + ¦ ¦ ¦ °--SYMBOL: a [0/0] {357} + ¦ ¦ ¦--'-': - [0/0] {359} + ¦ ¦ °--expr: [0/0] {361} + ¦ ¦ °--SYMBOL: b [0/0] {360} + ¦ ¦--expr: [1/2] {362} + ¦ ¦ ¦--expr: [0/0] {364} + ¦ ¦ ¦ °--SYMBOL: a [0/0] {363} + ¦ ¦ ¦--'+': + [0/0] {365} + ¦ ¦ °--expr: [0/0] {366} + ¦ ¦ ¦--'+': + [0/0] {367} + ¦ ¦ °--expr: [0/0] {369} + ¦ ¦ °--SYMBOL: b [0/0] {368} + ¦ ¦--expr: [1/2] {370} + ¦ ¦ ¦--expr: [0/0] {372} + ¦ ¦ ¦ °--SYMBOL: a [0/0] {371} + ¦ ¦ ¦--'+': + [0/0] {373} + ¦ ¦ °--expr: [0/0] {374} + ¦ ¦ ¦--'-': - [0/0] {375} + ¦ ¦ °--expr: [0/0] {377} + ¦ ¦ °--SYMBOL: b [0/0] {376} + ¦ ¦--expr: [1/2] {378} + ¦ ¦ ¦--expr: [0/0] {380} + ¦ ¦ ¦ °--SYMBOL: a [0/0] {379} + ¦ ¦ ¦--'+': + [0/0] {381} + ¦ ¦ °--expr: [0/0] {382} + ¦ ¦ ¦--'+': + [0/0] {383} + ¦ ¦ °--expr: [0/0] {385} + ¦ ¦ °--SYMBOL: b [0/0] {384} + ¦ ¦--expr: [1/2] {386} + ¦ ¦ ¦--expr: [0/0] {388} + ¦ ¦ ¦ °--SYMBOL: a [0/0] {387} + ¦ ¦ ¦--'-': - [0/0] {389} + ¦ ¦ °--expr: [0/0] {390} + ¦ ¦ ¦--'+': + [0/0] {391} + ¦ ¦ °--expr: [0/0] {393} + ¦ ¦ °--SYMBOL: b [0/0] {392} + ¦ ¦--expr: [1/2] {394} + ¦ ¦ ¦--expr: [0/0] {396} + ¦ ¦ ¦ °--SYMBOL: a [0/0] {395} + ¦ ¦ ¦--'-': - [0/0] {397} + ¦ ¦ °--expr: [0/0] {398} + ¦ ¦ ¦--'-': - [0/0] {399} + ¦ ¦ °--expr: [0/0] {401} + ¦ ¦ °--SYMBOL: b [0/0] {400} + ¦ ¦--expr: [1/2] {402} + ¦ ¦ ¦--expr: [0/0] {404} + ¦ ¦ ¦ °--SYMBOL: a [0/0] {403} + ¦ ¦ ¦--'+': + [0/0] {405} + ¦ ¦ °--expr: [0/0] {406} + ¦ ¦ ¦--'-': - [0/0] {407} + ¦ ¦ °--expr: [0/0] {408} + ¦ ¦ ¦--'-': - [0/0] {409} + ¦ ¦ °--expr: [0/0] {411} + ¦ ¦ °--SYMBOL: b [0/0] {410} + ¦ ¦--expr: [1/2] {412} + ¦ ¦ ¦--expr: [0/0] {414} + ¦ ¦ ¦ °--SYMBOL: a [0/0] {413} + ¦ ¦ ¦--'-': - [0/0] {415} + ¦ ¦ °--expr: [0/0] {416} + ¦ ¦ ¦--'-': - [0/0] {417} + ¦ ¦ °--expr: [0/0] {418} + ¦ ¦ ¦--'+': + [0/0] {419} + ¦ ¦ °--expr: [0/0] {421} + ¦ ¦ °--SYMBOL: b [0/0] {420} + ¦ ¦--expr: [1/2] {422} + ¦ ¦ ¦--expr: [0/0] {424} + ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: call [0/0] {423} + ¦ ¦ ¦--'(': ( [0/1] {425} + ¦ ¦ ¦--expr: [0/0] {426} + ¦ ¦ ¦ ¦--'+': + [0/1] {427} + ¦ ¦ ¦ °--expr: [0/0] {429} + ¦ ¦ ¦ °--SYMBOL: a [0/0] {428} + ¦ ¦ °--')': ) [0/0] {430} + ¦ ¦--expr: [1/2] {431} + ¦ ¦ ¦--expr: [0/0] {433} + ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: call [0/0] {432} + ¦ ¦ ¦--'(': ( [0/1] {434} + ¦ ¦ ¦--expr: [0/0] {435} + ¦ ¦ ¦ ¦--'-': - [0/1] {436} + ¦ ¦ ¦ °--expr: [0/0] {438} + ¦ ¦ ¦ °--SYMBOL: a [0/0] {437} + ¦ ¦ °--')': ) [0/0] {439} + ¦ ¦--expr: [1/2] {440} + ¦ ¦ ¦--expr: [0/0] {442} + ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: call [0/0] {441} + ¦ ¦ ¦--'(': ( [0/0] {443} + ¦ ¦ ¦--expr: [0/0] {445} + ¦ ¦ ¦ °--NUM_CONST: 5 [0/0] {444} + ¦ ¦ ¦--',': , [0/1] {446} + ¦ ¦ ¦--expr: [0/0] {447} + ¦ ¦ ¦ ¦--'+': + [0/1] {448} + ¦ ¦ ¦ °--expr: [0/0] {450} + ¦ ¦ ¦ °--SYMBOL: a [0/0] {449} + ¦ ¦ °--')': ) [0/0] {451} + ¦ ¦--expr: [1/2] {452} + ¦ ¦ ¦--expr: [0/0] {454} + ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: call [0/0] {453} + ¦ ¦ ¦--'(': ( [0/0] {455} + ¦ ¦ ¦--expr: [0/0] {457} + ¦ ¦ ¦ °--NUM_CONST: 5 [0/0] {456} + ¦ ¦ ¦--',': , [0/1] {458} + ¦ ¦ ¦--expr: [0/0] {459} + ¦ ¦ ¦ ¦--'-': - [0/1] {460} + ¦ ¦ ¦ °--expr: [0/0] {462} + ¦ ¦ ¦ °--SYMBOL: a [0/0] {461} + ¦ ¦ °--')': ) [0/0] {463} + ¦ ¦--COMMENT: # Onl [2/2] {464} + ¦ ¦--expr: [1/2] {465} + ¦ ¦ ¦--expr: [0/0] {467} + ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: call [0/0] {466} + ¦ ¦ ¦--'(': ( [0/4] {468} + ¦ ¦ ¦--expr: [1/0] {470} + ¦ ¦ ¦ °--SYMBOL: prese [0/0] {469} + ¦ ¦ ¦--',': , [0/1] {471} + ¦ ¦ ¦--expr: [0/0] {473} + ¦ ¦ ¦ °--SYMBOL: dista [0/0] {472} + ¦ ¦ ¦--',': , [0/4] {474} + ¦ ¦ ¦--expr: [1/0] {476} + ¦ ¦ ¦ °--SYMBOL: after [0/0] {475} + ¦ ¦ ¦--',': , [0/5] {477} + ¦ ¦ ¦--expr: [0/0] {479} + ¦ ¦ ¦ °--SYMBOL: comma [0/0] {478} + ¦ ¦ ¦--',': , [0/4] {480} + ¦ ¦ ¦--expr: [1/0] {482} + ¦ ¦ ¦ °--SYMBOL: given [0/0] {481} + ¦ ¦ ¦--',': , [0/0] {483} + ¦ ¦ ¦--expr: [0/2] {485} + ¦ ¦ ¦ °--SYMBOL: one [0/0] {484} + ¦ ¦ °--')': ) [1/0] {486} + ¦ ¦--expr: [2/2] {487} + ¦ ¦ ¦--IF: if [0/0] {488} + ¦ ¦ ¦--'(': ( [0/0] {489} + ¦ ¦ ¦--expr: [0/0] {491} + ¦ ¦ ¦ °--NUM_CONST: TRUE [0/0] {490} + ¦ ¦ ¦--')': ) [0/0] {492} + ¦ ¦ °--expr: [0/0] {493} + ¦ ¦ ¦--'{': { [0/4] {494} + ¦ ¦ ¦--expr: [1/2] {496} + ¦ ¦ ¦ °--NUM_CONST: FALSE [0/0] {495} + ¦ ¦ °--'}': } [1/0] {497} + ¦ ¦--expr: [2/2] {498} + ¦ ¦ ¦--IF: if [0/0] {499} + ¦ ¦ ¦--'(': ( [0/0] {500} + ¦ ¦ ¦--expr: [0/0] {502} + ¦ ¦ ¦ °--NUM_CONST: TRUE [0/0] {501} + ¦ ¦ ¦--')': ) [0/0] {503} + ¦ ¦ ¦--expr: [0/0] {504} + ¦ ¦ ¦ ¦--'{': { [0/4] {505} + ¦ ¦ ¦ ¦--expr: [1/2] {507} + ¦ ¦ ¦ ¦ °--NUM_CONST: FALSE [0/0] {506} + ¦ ¦ ¦ °--'}': } [1/0] {508} + ¦ ¦ ¦--ELSE: else [0/0] {509} + ¦ ¦ °--expr: [0/0] {510} + ¦ ¦ ¦--'{': { [0/4] {511} + ¦ ¦ ¦--expr: [1/2] {513} + ¦ ¦ ¦ °--NUM_CONST: TRUE [0/0] {512} + ¦ ¦ °--'}': } [1/0] {514} + ¦ ¦--expr: [2/2] {515} + ¦ ¦ ¦--WHILE: while [0/0] {516} + ¦ ¦ ¦--'(': ( [0/0] {517} + ¦ ¦ ¦--expr: [0/0] {519} + ¦ ¦ ¦ °--NUM_CONST: TRUE [0/0] {518} + ¦ ¦ ¦--')': ) [0/0] {520} + ¦ ¦ °--expr: [0/0] {521} + ¦ ¦ ¦--'{': { [0/4] {522} + ¦ ¦ ¦--expr: [1/2] {524} + ¦ ¦ ¦ °--NUM_CONST: FALSE [0/0] {523} + ¦ ¦ °--'}': } [1/0] {525} + ¦ ¦--expr: [2/2] {526} + ¦ ¦ ¦--expr: [0/1] {528} + ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: singl [0/0] {527} + ¦ ¦ ¦--'(': ( [0/1] {529} + ¦ ¦ ¦--expr: [0/1] {531} + ¦ ¦ ¦ °--STR_CONST: "func [0/0] {530} + ¦ ¦ ¦--',': , [0/0] {532} + ¦ ¦ ¦--expr: [0/1] {534} + ¦ ¦ ¦ °--SYMBOL: call [0/0] {533} + ¦ ¦ °--')': ) [0/0] {535} + ¦ ¦--expr: [2/2] {536} + ¦ ¦ ¦--expr: [0/1] {538} + ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: multi [0/0] {537} + ¦ ¦ ¦--'(': ( [0/2] {539} + ¦ ¦ ¦--expr: [1/0] {541} + ¦ ¦ ¦ °--STR_CONST: "func [0/0] {540} + ¦ ¦ ¦--',': , [0/1] {542} + ¦ ¦ ¦--expr: [0/1] {544} + ¦ ¦ ¦ °--SYMBOL: call [0/0] {543} + ¦ ¦ °--')': ) [0/0] {545} + ¦ ¦--expr: [2/2] {546} + ¦ ¦ ¦--expr: [0/1] {548} + ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: neste [0/0] {547} + ¦ ¦ ¦--'(': ( [0/1] {549} + ¦ ¦ ¦--expr: [0/1] {550} + ¦ ¦ ¦ ¦--expr: [0/1] {552} + ¦ ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: funct [0/0] {551} + ¦ ¦ ¦ ¦--'(': ( [0/1] {553} + ¦ ¦ ¦ ¦--expr: [0/1] {555} + ¦ ¦ ¦ ¦ °--STR_CONST: "in" [0/0] {554} + ¦ ¦ ¦ ¦--',': , [0/0] {556} + ¦ ¦ ¦ ¦--expr: [0/1] {558} + ¦ ¦ ¦ ¦ °--SYMBOL: one [0/0] {557} + ¦ ¦ ¦ ¦--',': , [0/0] {559} + ¦ ¦ ¦ ¦--expr: [0/1] {561} + ¦ ¦ ¦ ¦ °--SYMBOL: line [0/0] {560} + ¦ ¦ ¦ °--')': ) [0/0] {562} + ¦ ¦ °--')': ) [0/0] {563} + ¦ ¦--expr: [2/2] {564} + ¦ ¦ ¦--expr: [0/1] {566} + ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: neste [0/0] {565} + ¦ ¦ ¦--'(': ( [0/1] {567} + ¦ ¦ ¦--expr: [0/1] {568} + ¦ ¦ ¦ ¦--expr: [0/1] {570} + ¦ ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: funct [0/0] {569} + ¦ ¦ ¦ ¦--'(': ( [0/2] {571} + ¦ ¦ ¦ ¦--expr: [1/0] {573} + ¦ ¦ ¦ ¦ °--STR_CONST: "in" [0/0] {572} + ¦ ¦ ¦ ¦--',': , [0/6] {574} + ¦ ¦ ¦ ¦--expr: [1/0] {576} + ¦ ¦ ¦ ¦ °--SYMBOL: multi [0/0] {575} + ¦ ¦ ¦ ¦--',': , [0/0] {577} + ¦ ¦ ¦ ¦--expr: [0/1] {579} + ¦ ¦ ¦ ¦ °--SYMBOL: lines [0/0] {578} + ¦ ¦ ¦ °--')': ) [0/0] {580} + ¦ ¦ °--')': ) [0/0] {581} + ¦ ¦--expr: [2/2] {582} + ¦ ¦ ¦--expr: [0/0] {584} + ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: neste [0/0] {583} + ¦ ¦ ¦--'(': ( [0/2] {585} + ¦ ¦ ¦--expr: [1/0] {586} + ¦ ¦ ¦ ¦--expr: [0/1] {588} + ¦ ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: funct [0/0] {587} + ¦ ¦ ¦ ¦--'(': ( [0/1] {589} + ¦ ¦ ¦ ¦--expr: [0/1] {591} + ¦ ¦ ¦ ¦ °--SYMBOL: with [0/0] {590} + ¦ ¦ ¦ °--')': ) [0/0] {592} + ¦ ¦ ¦--',': , [0/6] {593} + ¦ ¦ ¦--expr: [1/2] {595} + ¦ ¦ ¦ °--SYMBOL: many [0/0] {594} + ¦ ¦ ¦--',': , [1/5] {596} + ¦ ¦ ¦--expr: [0/2] {598} + ¦ ¦ ¦ °--SYMBOL: first [0/0] {597} + ¦ ¦ °--')': ) [0/0] {599} + ¦ ¦--expr: [2/2] {600} + ¦ ¦ ¦--expr: [0/0] {602} + ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: neste [0/0] {601} + ¦ ¦ ¦--'(': ( [0/4] {603} + ¦ ¦ ¦--expr: [1/0] {604} + ¦ ¦ ¦ ¦--expr: [0/1] {606} + ¦ ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: funct [0/0] {605} + ¦ ¦ ¦ ¦--'(': ( [0/1] {607} + ¦ ¦ ¦ ¦--expr: [0/1] {609} + ¦ ¦ ¦ ¦ °--SYMBOL: with [0/0] {608} + ¦ ¦ ¦ °--')': ) [0/0] {610} + ¦ ¦ ¦--',': , [0/2] {611} + ¦ ¦ ¦--COMMENT: # a c [0/4] {612} + ¦ ¦ ¦--expr: [1/1] {614} + ¦ ¦ ¦ °--SYMBOL: many [0/0] {613} + ¦ ¦ ¦--COMMENT: #more [0/4] {615} + ¦ ¦ ¦--',': , [1/5] {616} + ¦ ¦ ¦--expr: [0/2] {618} + ¦ ¦ ¦ °--SYMBOL: first [0/0] {617} + ¦ ¦ °--')': ) [0/0] {619} + ¦ ¦--expr: [2/0] {620} + ¦ ¦ ¦--expr: [0/0] {622} + ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: diffi [0/0] {621} + ¦ ¦ ¦--'(': ( [0/0] {623} + ¦ ¦ ¦--expr: [0/0] {624} + ¦ ¦ ¦ ¦--expr: [0/0] {626} + ¦ ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: neste [0/0] {625} + ¦ ¦ ¦ ¦--'(': ( [0/4] {627} + ¦ ¦ ¦ ¦--expr: [1/0] {629} + ¦ ¦ ¦ ¦ °--STR_CONST: "func [0/0] {628} + ¦ ¦ ¦ ¦--',': , [0/1] {630} + ¦ ¦ ¦ ¦--expr: [0/2] {632} + ¦ ¦ ¦ ¦ °--SYMBOL: call [0/0] {631} + ¦ ¦ ¦ °--')': ) [1/0] {633} + ¦ ¦ ¦--',': , [0/4] {634} + ¦ ¦ ¦--expr: [1/0] {636} + ¦ ¦ ¦ °--SYMBOL: with [0/0] {635} + ¦ ¦ ¦--',': , [0/1] {637} + ¦ ¦ ¦--expr: [0/0] {639} + ¦ ¦ ¦ °--SYMBOL: more [0/0] {638} + ¦ ¦ ¦--',': , [0/1] {640} + ¦ ¦ ¦--expr: [0/2] {642} + ¦ ¦ ¦ °--SYMBOL: args [0/0] {641} + ¦ ¦ °--')': ) [1/0] {643} + ¦ °--'}': } [1/0] {644} + ¦--COMMENT: # for [3/0] {645} + ¦--expr: [1/0] {646} + ¦ ¦--expr: [0/0] {648} + ¦ ¦ °--SYMBOL_FUNCTION_CALL: lm [0/0] {647} + ¦ ¦--'(': ( [0/0] {649} + ¦ ¦--expr: [0/0] {650} + ¦ ¦ ¦--expr: [0/0] {652} + ¦ ¦ ¦ °--SYMBOL: a [0/0] {651} + ¦ ¦ ¦--'~': ~ [0/0] {653} + ¦ ¦ °--expr: [0/0] {654} + ¦ ¦ ¦--expr: [0/0] {656} + ¦ ¦ ¦ °--SYMBOL: b [0/0] {655} + ¦ ¦ ¦--'+': + [0/0] {657} + ¦ ¦ °--expr: [0/0] {659} + ¦ ¦ °--SYMBOL: c [0/0] {658} + ¦ ¦--',': , [0/0] {660} + ¦ ¦--SYMBOL_SUB: data [0/0] {661} + ¦ ¦--EQ_SUB: = [0/0] {662} + ¦ ¦--expr: [0/0] {664} + ¦ ¦ °--NUM_CONST: NA [0/0] {663} + ¦ °--')': ) [0/0] {665} + ¦--expr: [1/0] {666} + ¦ ¦--expr: [0/0] {668} + ¦ ¦ °--SYMBOL_FUNCTION_CALL: lm [0/0] {667} + ¦ ¦--'(': ( [0/0] {669} + ¦ ¦--expr: [0/0] {670} + ¦ ¦ ¦--expr: [0/0] {672} + ¦ ¦ ¦ °--SYMBOL: a [0/0] {671} + ¦ ¦ ¦--'~': ~ [0/0] {673} + ¦ ¦ °--expr: [0/0] {674} + ¦ ¦ ¦--expr: [0/0] {676} + ¦ ¦ ¦ °--SYMBOL: . [0/0] {675} + ¦ ¦ ¦--'-': - [0/0] {677} + ¦ ¦ °--expr: [0/0] {679} + ¦ ¦ °--NUM_CONST: 1 [0/0] {678} + ¦ ¦--',': , [0/0] {680} + ¦ ¦--SYMBOL_SUB: data [0/0] {681} + ¦ ¦--EQ_SUB: = [0/0] {682} + ¦ ¦--expr: [0/0] {684} + ¦ ¦ °--NUM_CONST: NA [0/0] {683} + ¦ °--')': ) [0/0] {685} + ¦--expr: [1/0] {686} + ¦ ¦--expr: [0/0] {688} + ¦ ¦ °--SYMBOL: a [0/0] {687} + ¦ ¦--'~': ~ [0/0] {689} + ¦ °--expr: [0/0] {690} + ¦ ¦--expr: [0/0] {692} + ¦ ¦ °--SYMBOL: b [0/0] {691} + ¦ ¦--':': : [0/0] {693} + ¦ °--expr: [0/0] {695} + ¦ °--SYMBOL: c [0/0] {694} + ¦--expr: [1/0] {696} + ¦ ¦--expr: [0/0] {698} + ¦ ¦ °--SYMBOL: a [0/0] {697} + ¦ ¦--'~': ~ [0/0] {699} + ¦ °--expr: [0/0] {700} + ¦ ¦--expr: [0/1] {702} + ¦ ¦ °--SYMBOL: b [0/0] {701} + ¦ ¦--':': : [0/0] {703} + ¦ °--expr: [0/0] {705} + ¦ °--SYMBOL: c [0/0] {704} + ¦--expr: [1/0] {706} + ¦ ¦--expr: [0/3] {708} + ¦ ¦ °--SYMBOL: a [0/0] {707} + ¦ ¦--'~': ~ [0/3] {709} + ¦ °--expr: [0/0] {710} + ¦ ¦--expr: [0/2] {712} + ¦ ¦ °--SYMBOL: b [0/0] {711} + ¦ ¦--':': : [0/1] {713} + ¦ °--expr: [0/0] {715} + ¦ °--SYMBOL: c [0/0] {714} + ¦--expr: [2/0] {716} + ¦ ¦--'~': ~ [0/3] {717} + ¦ °--expr: [0/0] {719} + ¦ °--SYMBOL: a [0/0] {718} + ¦--expr: [1/0] {720} + ¦ ¦--'~': ~ [0/0] {721} + ¦ °--expr: [0/0] {723} + ¦ °--SYMBOL: gg [0/0] {722} + ¦--expr: [1/0] {724} + ¦ ¦--expr: [0/0] {726} + ¦ ¦ °--SYMBOL: b [0/0] {725} + ¦ ¦--'~': ~ [0/3] {727} + ¦ °--expr: [0/0] {729} + ¦ °--SYMBOL: k [0/0] {728} + °--expr: [1/0] {730} + ¦--expr: [0/0] {732} + ¦ °--SYMBOL_FUNCTION_CALL: call [0/0] {731} + ¦--'(': ( [0/0] {733} + ¦--expr: [0/0] {735} + ¦ °--NUM_CONST: 1 [0/0] {734} + ¦--',': , [0/0] {736} + ¦--expr: [0/0] {737} + ¦ ¦--'~': ~ [0/1] {738} + ¦ °--expr: [0/0] {740} + ¦ °--SYMBOL: qq [0/0] {739} + °--')': ) [0/0] {741} diff --git a/tests/testthat/strict/strict-in_tree b/tests/testthat/strict/strict-in_tree index 45fc55a24..a76ffbd44 100644 --- a/tests/testthat/strict/strict-in_tree +++ b/tests/testthat/strict/strict-in_tree @@ -288,449 +288,449 @@ ROOT (token: short_text [lag_newlines/spaces] {pos_id}) ¦ ¦ ¦--RIGHT_ASSIGN: -> [0/0] {287} ¦ ¦ °--expr: [0/0] {289} ¦ ¦ °--SYMBOL: b [0/0] {288} - ¦ ¦--expr: [1/2] {289.9} - ¦ ¦ ¦--expr: [0/0] {291} - ¦ ¦ ¦ °--SYMBOL: a [0/0] {290} - ¦ ¦ ¦--EQ_ASSIGN: = [0/0] {292} - ¦ ¦ °--expr: [0/0] {294} - ¦ ¦ °--SYMBOL: b [0/0] {293} - ¦ ¦--expr: [1/2] {295} - ¦ ¦ ¦--expr: [0/0] {297} - ¦ ¦ ¦ °--SYMBOL: a [0/0] {296} - ¦ ¦ ¦--LT: < [0/0] {298} - ¦ ¦ °--expr: [0/0] {300} - ¦ ¦ °--SYMBOL: b [0/0] {299} - ¦ ¦--expr: [1/2] {301} - ¦ ¦ ¦--expr: [0/0] {303} - ¦ ¦ ¦ °--SYMBOL: a [0/0] {302} - ¦ ¦ ¦--GT: > [0/0] {304} - ¦ ¦ °--expr: [0/0] {306} - ¦ ¦ °--SYMBOL: b [0/0] {305} - ¦ ¦--expr: [1/2] {307} - ¦ ¦ ¦--expr: [0/0] {309} - ¦ ¦ ¦ °--SYMBOL: a [0/0] {308} - ¦ ¦ ¦--'*': * [0/0] {310} - ¦ ¦ °--expr: [0/0] {312} - ¦ ¦ °--SYMBOL: b [0/0] {311} - ¦ ¦--expr: [1/2] {313} - ¦ ¦ ¦--expr: [0/0] {315} - ¦ ¦ ¦ °--SYMBOL: a [0/0] {314} - ¦ ¦ ¦--'/': / [0/0] {316} - ¦ ¦ °--expr: [0/0] {318} - ¦ ¦ °--SYMBOL: b [0/0] {317} - ¦ ¦--expr: [1/2] {319} - ¦ ¦ ¦--expr: [0/0] {321} - ¦ ¦ ¦ °--SYMBOL: a [0/0] {320} - ¦ ¦ ¦--'^': ^ [0/0] {322} - ¦ ¦ °--expr: [0/0] {324} - ¦ ¦ °--SYMBOL: b [0/0] {323} - ¦ ¦--expr: [1/2] {325} - ¦ ¦ ¦--expr: [0/0] {327} - ¦ ¦ ¦ °--SYMBOL: a [0/0] {326} - ¦ ¦ ¦--AND: & [0/0] {328} - ¦ ¦ °--expr: [0/0] {330} - ¦ ¦ °--SYMBOL: b [0/0] {329} - ¦ ¦--expr: [1/2] {331} - ¦ ¦ ¦--expr: [0/0] {333} - ¦ ¦ ¦ °--SYMBOL: a [0/0] {332} - ¦ ¦ ¦--OR: | [0/0] {334} - ¦ ¦ °--expr: [0/0] {336} - ¦ ¦ °--SYMBOL: b [0/0] {335} - ¦ ¦--expr: [1/2] {337} - ¦ ¦ ¦--expr: [0/0] {339} - ¦ ¦ ¦ °--SYMBOL: a [0/0] {338} - ¦ ¦ ¦--LEFT_ASSIGN: := [0/0] {340} - ¦ ¦ °--expr: [0/0] {342} - ¦ ¦ °--SYMBOL: b [0/0] {341} - ¦ ¦--expr: [2/2] {343} - ¦ ¦ ¦--expr: [0/0] {345} - ¦ ¦ ¦ °--SYMBOL: a [0/0] {344} - ¦ ¦ ¦--'+': + [0/0] {346} - ¦ ¦ °--expr: [0/0] {348} - ¦ ¦ °--SYMBOL: b [0/0] {347} - ¦ ¦--expr: [1/2] {349} - ¦ ¦ ¦--expr: [0/0] {351} - ¦ ¦ ¦ °--SYMBOL: a [0/0] {350} - ¦ ¦ ¦--'-': - [0/0] {352} - ¦ ¦ °--expr: [0/0] {354} - ¦ ¦ °--SYMBOL: b [0/0] {353} - ¦ ¦--expr: [1/2] {355} - ¦ ¦ ¦--expr: [0/0] {357} - ¦ ¦ ¦ °--SYMBOL: a [0/0] {356} - ¦ ¦ ¦--'+': + [0/0] {358} - ¦ ¦ °--expr: [0/0] {359} - ¦ ¦ ¦--'+': + [0/0] {360} - ¦ ¦ °--expr: [0/0] {362} - ¦ ¦ °--SYMBOL: b [0/0] {361} - ¦ ¦--expr: [1/2] {363} - ¦ ¦ ¦--expr: [0/0] {365} - ¦ ¦ ¦ °--SYMBOL: a [0/0] {364} - ¦ ¦ ¦--'+': + [0/0] {366} - ¦ ¦ °--expr: [0/0] {367} - ¦ ¦ ¦--'-': - [0/0] {368} - ¦ ¦ °--expr: [0/0] {370} - ¦ ¦ °--SYMBOL: b [0/0] {369} - ¦ ¦--expr: [1/2] {371} - ¦ ¦ ¦--expr: [0/0] {373} - ¦ ¦ ¦ °--SYMBOL: a [0/0] {372} - ¦ ¦ ¦--'+': + [0/0] {374} - ¦ ¦ °--expr: [0/0] {375} - ¦ ¦ ¦--'+': + [0/0] {376} - ¦ ¦ °--expr: [0/0] {378} - ¦ ¦ °--SYMBOL: b [0/0] {377} - ¦ ¦--expr: [1/2] {379} - ¦ ¦ ¦--expr: [0/0] {381} - ¦ ¦ ¦ °--SYMBOL: a [0/0] {380} - ¦ ¦ ¦--'-': - [0/0] {382} - ¦ ¦ °--expr: [0/0] {383} - ¦ ¦ ¦--'+': + [0/0] {384} - ¦ ¦ °--expr: [0/0] {386} - ¦ ¦ °--SYMBOL: b [0/0] {385} - ¦ ¦--expr: [1/2] {387} - ¦ ¦ ¦--expr: [0/0] {389} - ¦ ¦ ¦ °--SYMBOL: a [0/0] {388} - ¦ ¦ ¦--'-': - [0/0] {390} - ¦ ¦ °--expr: [0/0] {391} - ¦ ¦ ¦--'-': - [0/0] {392} - ¦ ¦ °--expr: [0/0] {394} - ¦ ¦ °--SYMBOL: b [0/0] {393} - ¦ ¦--expr: [1/2] {395} - ¦ ¦ ¦--expr: [0/0] {397} - ¦ ¦ ¦ °--SYMBOL: a [0/0] {396} - ¦ ¦ ¦--'+': + [0/0] {398} - ¦ ¦ °--expr: [0/0] {399} - ¦ ¦ ¦--'-': - [0/0] {400} - ¦ ¦ °--expr: [0/0] {401} - ¦ ¦ ¦--'-': - [0/0] {402} - ¦ ¦ °--expr: [0/0] {404} - ¦ ¦ °--SYMBOL: b [0/0] {403} - ¦ ¦--expr: [1/2] {405} - ¦ ¦ ¦--expr: [0/0] {407} - ¦ ¦ ¦ °--SYMBOL: a [0/0] {406} - ¦ ¦ ¦--'-': - [0/0] {408} - ¦ ¦ °--expr: [0/0] {409} - ¦ ¦ ¦--'-': - [0/0] {410} - ¦ ¦ °--expr: [0/0] {411} - ¦ ¦ ¦--'+': + [0/0] {412} - ¦ ¦ °--expr: [0/0] {414} - ¦ ¦ °--SYMBOL: b [0/0] {413} - ¦ ¦--expr: [1/2] {415} - ¦ ¦ ¦--expr: [0/0] {417} - ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: call [0/0] {416} - ¦ ¦ ¦--'(': ( [0/1] {418} - ¦ ¦ ¦--expr: [0/0] {419} - ¦ ¦ ¦ ¦--'+': + [0/1] {420} - ¦ ¦ ¦ °--expr: [0/0] {422} - ¦ ¦ ¦ °--SYMBOL: a [0/0] {421} - ¦ ¦ °--')': ) [0/0] {423} - ¦ ¦--expr: [1/2] {424} - ¦ ¦ ¦--expr: [0/0] {426} - ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: call [0/0] {425} - ¦ ¦ ¦--'(': ( [0/1] {427} - ¦ ¦ ¦--expr: [0/0] {428} - ¦ ¦ ¦ ¦--'-': - [0/1] {429} - ¦ ¦ ¦ °--expr: [0/0] {431} - ¦ ¦ ¦ °--SYMBOL: a [0/0] {430} - ¦ ¦ °--')': ) [0/0] {432} - ¦ ¦--expr: [1/2] {433} - ¦ ¦ ¦--expr: [0/0] {435} - ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: call [0/0] {434} - ¦ ¦ ¦--'(': ( [0/0] {436} - ¦ ¦ ¦--expr: [0/0] {438} - ¦ ¦ ¦ °--NUM_CONST: 5 [0/0] {437} - ¦ ¦ ¦--',': , [0/1] {439} - ¦ ¦ ¦--expr: [0/0] {440} - ¦ ¦ ¦ ¦--'+': + [0/1] {441} - ¦ ¦ ¦ °--expr: [0/0] {443} - ¦ ¦ ¦ °--SYMBOL: a [0/0] {442} - ¦ ¦ °--')': ) [0/0] {444} - ¦ ¦--expr: [1/2] {445} - ¦ ¦ ¦--expr: [0/0] {447} - ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: call [0/0] {446} - ¦ ¦ ¦--'(': ( [0/0] {448} - ¦ ¦ ¦--expr: [0/0] {450} - ¦ ¦ ¦ °--NUM_CONST: 5 [0/0] {449} - ¦ ¦ ¦--',': , [0/1] {451} - ¦ ¦ ¦--expr: [0/0] {452} - ¦ ¦ ¦ ¦--'-': - [0/1] {453} - ¦ ¦ ¦ °--expr: [0/0] {455} - ¦ ¦ ¦ °--SYMBOL: a [0/0] {454} - ¦ ¦ °--')': ) [0/0] {456} - ¦ ¦--COMMENT: # Onl [2/2] {457} - ¦ ¦--expr: [1/2] {458} - ¦ ¦ ¦--expr: [0/0] {460} - ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: call [0/0] {459} - ¦ ¦ ¦--'(': ( [0/4] {461} - ¦ ¦ ¦--expr: [1/0] {463} - ¦ ¦ ¦ °--SYMBOL: prese [0/0] {462} - ¦ ¦ ¦--',': , [0/1] {464} - ¦ ¦ ¦--expr: [0/0] {466} - ¦ ¦ ¦ °--SYMBOL: dista [0/0] {465} - ¦ ¦ ¦--',': , [0/4] {467} - ¦ ¦ ¦--expr: [1/0] {469} - ¦ ¦ ¦ °--SYMBOL: after [0/0] {468} - ¦ ¦ ¦--',': , [0/5] {470} - ¦ ¦ ¦--expr: [0/0] {472} - ¦ ¦ ¦ °--SYMBOL: comma [0/0] {471} - ¦ ¦ ¦--',': , [0/4] {473} - ¦ ¦ ¦--expr: [1/0] {475} - ¦ ¦ ¦ °--SYMBOL: given [0/0] {474} - ¦ ¦ ¦--',': , [0/0] {476} - ¦ ¦ ¦--expr: [0/2] {478} - ¦ ¦ ¦ °--SYMBOL: one [0/0] {477} - ¦ ¦ °--')': ) [1/0] {479} - ¦ ¦--expr: [2/2] {480} - ¦ ¦ ¦--IF: if [0/0] {481} - ¦ ¦ ¦--'(': ( [0/0] {482} - ¦ ¦ ¦--expr: [0/0] {484} - ¦ ¦ ¦ °--NUM_CONST: TRUE [0/0] {483} - ¦ ¦ ¦--')': ) [0/0] {485} - ¦ ¦ °--expr: [0/0] {486} - ¦ ¦ ¦--'{': { [0/4] {487} - ¦ ¦ ¦--expr: [1/2] {489} - ¦ ¦ ¦ °--NUM_CONST: FALSE [0/0] {488} - ¦ ¦ °--'}': } [1/0] {490} - ¦ ¦--expr: [2/2] {491} - ¦ ¦ ¦--IF: if [0/0] {492} - ¦ ¦ ¦--'(': ( [0/0] {493} - ¦ ¦ ¦--expr: [0/0] {495} - ¦ ¦ ¦ °--NUM_CONST: TRUE [0/0] {494} - ¦ ¦ ¦--')': ) [0/0] {496} - ¦ ¦ ¦--expr: [0/0] {497} - ¦ ¦ ¦ ¦--'{': { [0/4] {498} - ¦ ¦ ¦ ¦--expr: [1/2] {500} - ¦ ¦ ¦ ¦ °--NUM_CONST: FALSE [0/0] {499} - ¦ ¦ ¦ °--'}': } [1/0] {501} - ¦ ¦ ¦--ELSE: else [0/0] {502} - ¦ ¦ °--expr: [0/0] {503} - ¦ ¦ ¦--'{': { [0/4] {504} - ¦ ¦ ¦--expr: [1/2] {506} - ¦ ¦ ¦ °--NUM_CONST: TRUE [0/0] {505} - ¦ ¦ °--'}': } [1/0] {507} - ¦ ¦--expr: [2/2] {508} - ¦ ¦ ¦--WHILE: while [0/0] {509} - ¦ ¦ ¦--'(': ( [0/0] {510} - ¦ ¦ ¦--expr: [0/0] {512} - ¦ ¦ ¦ °--NUM_CONST: TRUE [0/0] {511} - ¦ ¦ ¦--')': ) [0/0] {513} - ¦ ¦ °--expr: [0/0] {514} - ¦ ¦ ¦--'{': { [0/4] {515} - ¦ ¦ ¦--expr: [1/2] {517} - ¦ ¦ ¦ °--NUM_CONST: FALSE [0/0] {516} - ¦ ¦ °--'}': } [1/0] {518} - ¦ ¦--expr: [2/2] {519} - ¦ ¦ ¦--expr: [0/1] {521} - ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: singl [0/0] {520} - ¦ ¦ ¦--'(': ( [0/1] {522} - ¦ ¦ ¦--expr: [0/1] {524} - ¦ ¦ ¦ °--STR_CONST: "func [0/0] {523} - ¦ ¦ ¦--',': , [0/0] {525} - ¦ ¦ ¦--expr: [0/1] {527} - ¦ ¦ ¦ °--SYMBOL: call [0/0] {526} - ¦ ¦ °--')': ) [0/0] {528} - ¦ ¦--expr: [2/2] {529} - ¦ ¦ ¦--expr: [0/1] {531} - ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: multi [0/0] {530} - ¦ ¦ ¦--'(': ( [0/2] {532} - ¦ ¦ ¦--expr: [1/0] {534} - ¦ ¦ ¦ °--STR_CONST: "func [0/0] {533} - ¦ ¦ ¦--',': , [0/1] {535} - ¦ ¦ ¦--expr: [0/1] {537} - ¦ ¦ ¦ °--SYMBOL: call [0/0] {536} - ¦ ¦ °--')': ) [0/0] {538} - ¦ ¦--expr: [2/2] {539} - ¦ ¦ ¦--expr: [0/1] {541} - ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: neste [0/0] {540} - ¦ ¦ ¦--'(': ( [0/1] {542} - ¦ ¦ ¦--expr: [0/1] {543} - ¦ ¦ ¦ ¦--expr: [0/1] {545} - ¦ ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: funct [0/0] {544} - ¦ ¦ ¦ ¦--'(': ( [0/1] {546} - ¦ ¦ ¦ ¦--expr: [0/1] {548} - ¦ ¦ ¦ ¦ °--STR_CONST: "in" [0/0] {547} - ¦ ¦ ¦ ¦--',': , [0/0] {549} - ¦ ¦ ¦ ¦--expr: [0/1] {551} - ¦ ¦ ¦ ¦ °--SYMBOL: one [0/0] {550} - ¦ ¦ ¦ ¦--',': , [0/0] {552} - ¦ ¦ ¦ ¦--expr: [0/1] {554} - ¦ ¦ ¦ ¦ °--SYMBOL: line [0/0] {553} - ¦ ¦ ¦ °--')': ) [0/0] {555} - ¦ ¦ °--')': ) [0/0] {556} - ¦ ¦--expr: [2/2] {557} - ¦ ¦ ¦--expr: [0/1] {559} - ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: neste [0/0] {558} - ¦ ¦ ¦--'(': ( [0/1] {560} - ¦ ¦ ¦--expr: [0/1] {561} - ¦ ¦ ¦ ¦--expr: [0/1] {563} - ¦ ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: funct [0/0] {562} - ¦ ¦ ¦ ¦--'(': ( [0/2] {564} - ¦ ¦ ¦ ¦--expr: [1/0] {566} - ¦ ¦ ¦ ¦ °--STR_CONST: "in" [0/0] {565} - ¦ ¦ ¦ ¦--',': , [0/6] {567} - ¦ ¦ ¦ ¦--expr: [1/0] {569} - ¦ ¦ ¦ ¦ °--SYMBOL: multi [0/0] {568} - ¦ ¦ ¦ ¦--',': , [0/0] {570} - ¦ ¦ ¦ ¦--expr: [0/1] {572} - ¦ ¦ ¦ ¦ °--SYMBOL: lines [0/0] {571} - ¦ ¦ ¦ °--')': ) [0/0] {573} - ¦ ¦ °--')': ) [0/0] {574} - ¦ ¦--expr: [2/2] {575} - ¦ ¦ ¦--expr: [0/0] {577} - ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: neste [0/0] {576} - ¦ ¦ ¦--'(': ( [0/2] {578} - ¦ ¦ ¦--expr: [1/0] {579} - ¦ ¦ ¦ ¦--expr: [0/1] {581} - ¦ ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: funct [0/0] {580} - ¦ ¦ ¦ ¦--'(': ( [0/1] {582} - ¦ ¦ ¦ ¦--expr: [0/1] {584} - ¦ ¦ ¦ ¦ °--SYMBOL: with [0/0] {583} - ¦ ¦ ¦ °--')': ) [0/0] {585} - ¦ ¦ ¦--',': , [0/6] {586} - ¦ ¦ ¦--expr: [1/2] {588} - ¦ ¦ ¦ °--SYMBOL: many [0/0] {587} - ¦ ¦ ¦--',': , [1/5] {589} - ¦ ¦ ¦--expr: [0/2] {591} - ¦ ¦ ¦ °--SYMBOL: first [0/0] {590} - ¦ ¦ °--')': ) [0/0] {592} - ¦ ¦--expr: [2/2] {593} - ¦ ¦ ¦--expr: [0/0] {595} - ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: neste [0/0] {594} - ¦ ¦ ¦--'(': ( [0/4] {596} - ¦ ¦ ¦--expr: [1/0] {597} - ¦ ¦ ¦ ¦--expr: [0/1] {599} - ¦ ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: funct [0/0] {598} - ¦ ¦ ¦ ¦--'(': ( [0/1] {600} - ¦ ¦ ¦ ¦--expr: [0/1] {602} - ¦ ¦ ¦ ¦ °--SYMBOL: with [0/0] {601} - ¦ ¦ ¦ °--')': ) [0/0] {603} - ¦ ¦ ¦--',': , [0/2] {604} - ¦ ¦ ¦--COMMENT: # a c [0/4] {605} - ¦ ¦ ¦--expr: [1/1] {607} - ¦ ¦ ¦ °--SYMBOL: many [0/0] {606} - ¦ ¦ ¦--COMMENT: #more [0/4] {608} - ¦ ¦ ¦--',': , [1/5] {609} - ¦ ¦ ¦--expr: [0/2] {611} - ¦ ¦ ¦ °--SYMBOL: first [0/0] {610} - ¦ ¦ °--')': ) [0/0] {612} - ¦ ¦--expr: [2/0] {613} - ¦ ¦ ¦--expr: [0/0] {615} - ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: diffi [0/0] {614} - ¦ ¦ ¦--'(': ( [0/0] {616} - ¦ ¦ ¦--expr: [0/0] {617} - ¦ ¦ ¦ ¦--expr: [0/0] {619} - ¦ ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: neste [0/0] {618} - ¦ ¦ ¦ ¦--'(': ( [0/4] {620} - ¦ ¦ ¦ ¦--expr: [1/0] {622} - ¦ ¦ ¦ ¦ °--STR_CONST: "func [0/0] {621} - ¦ ¦ ¦ ¦--',': , [0/1] {623} - ¦ ¦ ¦ ¦--expr: [0/2] {625} - ¦ ¦ ¦ ¦ °--SYMBOL: call [0/0] {624} - ¦ ¦ ¦ °--')': ) [1/0] {626} - ¦ ¦ ¦--',': , [0/4] {627} - ¦ ¦ ¦--expr: [1/0] {629} - ¦ ¦ ¦ °--SYMBOL: with [0/0] {628} - ¦ ¦ ¦--',': , [0/1] {630} - ¦ ¦ ¦--expr: [0/0] {632} - ¦ ¦ ¦ °--SYMBOL: more [0/0] {631} - ¦ ¦ ¦--',': , [0/1] {633} - ¦ ¦ ¦--expr: [0/2] {635} - ¦ ¦ ¦ °--SYMBOL: args [0/0] {634} - ¦ ¦ °--')': ) [1/0] {636} - ¦ °--'}': } [1/0] {637} - ¦--COMMENT: # for [3/0] {638} - ¦--expr: [1/0] {639} - ¦ ¦--expr: [0/0] {641} - ¦ ¦ °--SYMBOL_FUNCTION_CALL: lm [0/0] {640} - ¦ ¦--'(': ( [0/0] {642} - ¦ ¦--expr: [0/0] {643} - ¦ ¦ ¦--expr: [0/0] {645} - ¦ ¦ ¦ °--SYMBOL: a [0/0] {644} - ¦ ¦ ¦--'~': ~ [0/0] {646} - ¦ ¦ °--expr: [0/0] {647} - ¦ ¦ ¦--expr: [0/0] {649} - ¦ ¦ ¦ °--SYMBOL: b [0/0] {648} - ¦ ¦ ¦--'+': + [0/0] {650} - ¦ ¦ °--expr: [0/0] {652} - ¦ ¦ °--SYMBOL: c [0/0] {651} - ¦ ¦--',': , [0/0] {653} - ¦ ¦--SYMBOL_SUB: data [0/0] {654} - ¦ ¦--EQ_SUB: = [0/0] {655} - ¦ ¦--expr: [0/0] {657} - ¦ ¦ °--NUM_CONST: NA [0/0] {656} - ¦ °--')': ) [0/0] {658} - ¦--expr: [1/0] {659} - ¦ ¦--expr: [0/0] {661} - ¦ ¦ °--SYMBOL_FUNCTION_CALL: lm [0/0] {660} - ¦ ¦--'(': ( [0/0] {662} - ¦ ¦--expr: [0/0] {663} - ¦ ¦ ¦--expr: [0/0] {665} - ¦ ¦ ¦ °--SYMBOL: a [0/0] {664} - ¦ ¦ ¦--'~': ~ [0/0] {666} - ¦ ¦ °--expr: [0/0] {667} - ¦ ¦ ¦--expr: [0/0] {669} - ¦ ¦ ¦ °--SYMBOL: . [0/0] {668} - ¦ ¦ ¦--'-': - [0/0] {670} - ¦ ¦ °--expr: [0/0] {672} - ¦ ¦ °--NUM_CONST: 1 [0/0] {671} - ¦ ¦--',': , [0/0] {673} - ¦ ¦--SYMBOL_SUB: data [0/0] {674} - ¦ ¦--EQ_SUB: = [0/0] {675} - ¦ ¦--expr: [0/0] {677} - ¦ ¦ °--NUM_CONST: NA [0/0] {676} - ¦ °--')': ) [0/0] {678} - ¦--expr: [1/0] {679} - ¦ ¦--expr: [0/0] {681} - ¦ ¦ °--SYMBOL: a [0/0] {680} - ¦ ¦--'~': ~ [0/0] {682} - ¦ °--expr: [0/0] {683} - ¦ ¦--expr: [0/0] {685} - ¦ ¦ °--SYMBOL: b [0/0] {684} - ¦ ¦--':': : [0/0] {686} - ¦ °--expr: [0/0] {688} - ¦ °--SYMBOL: c [0/0] {687} - ¦--expr: [1/0] {689} - ¦ ¦--expr: [0/3] {691} - ¦ ¦ °--SYMBOL: a [0/0] {690} - ¦ ¦--'~': ~ [0/3] {692} - ¦ °--expr: [0/0] {693} - ¦ ¦--expr: [0/2] {695} - ¦ ¦ °--SYMBOL: b [0/0] {694} - ¦ ¦--':': : [0/1] {696} - ¦ °--expr: [0/0] {698} - ¦ °--SYMBOL: c [0/0] {697} - ¦--expr: [1/0] {699} - ¦ ¦--expr: [0/0] {701} - ¦ ¦ °--SYMBOL: a [0/0] {700} - ¦ ¦--'~': ~ [0/0] {702} - ¦ °--expr: [0/0] {703} - ¦ ¦--expr: [0/1] {705} - ¦ ¦ °--SYMBOL: b [0/0] {704} - ¦ ¦--':': : [0/0] {706} - ¦ °--expr: [0/0] {708} - ¦ °--SYMBOL: c [0/0] {707} - ¦--expr: [1/0] {709} - ¦ ¦--'~': ~ [0/4] {710} - ¦ °--expr: [0/0] {712} - ¦ °--SYMBOL: a [0/0] {711} - ¦--expr: [1/0] {713} - ¦ ¦--'~': ~ [0/0] {714} - ¦ °--expr: [0/0] {716} - ¦ °--SYMBOL: gg [0/0] {715} - ¦--expr: [1/0] {717} - ¦ ¦--expr: [0/0] {719} - ¦ ¦ °--SYMBOL: b [0/0] {718} - ¦ ¦--'~': ~ [0/0] {720} - ¦ °--expr: [0/0] {722} - ¦ °--SYMBOL: k [0/0] {721} - °--expr: [1/0] {723} - ¦--expr: [0/0] {725} - ¦ °--SYMBOL_FUNCTION_CALL: call [0/0] {724} - ¦--'(': ( [0/0] {726} - ¦--expr: [0/0] {728} - ¦ °--NUM_CONST: 1 [0/0] {727} - ¦--',': , [0/1] {729} - ¦--expr: [0/0] {730} - ¦ ¦--'~': ~ [0/1] {731} - ¦ °--expr: [0/0] {733} - ¦ °--SYMBOL: qq [0/0] {732} - °--')': ) [0/0] {734} + ¦ ¦--equal_assign: [1/2] {290} + ¦ ¦ ¦--expr: [0/0] {292} + ¦ ¦ ¦ °--SYMBOL: a [0/0] {291} + ¦ ¦ ¦--EQ_ASSIGN: = [0/0] {293} + ¦ ¦ °--expr: [0/0] {295} + ¦ ¦ °--SYMBOL: b [0/0] {294} + ¦ ¦--expr: [1/2] {296} + ¦ ¦ ¦--expr: [0/0] {298} + ¦ ¦ ¦ °--SYMBOL: a [0/0] {297} + ¦ ¦ ¦--LT: < [0/0] {299} + ¦ ¦ °--expr: [0/0] {301} + ¦ ¦ °--SYMBOL: b [0/0] {300} + ¦ ¦--expr: [1/2] {302} + ¦ ¦ ¦--expr: [0/0] {304} + ¦ ¦ ¦ °--SYMBOL: a [0/0] {303} + ¦ ¦ ¦--GT: > [0/0] {305} + ¦ ¦ °--expr: [0/0] {307} + ¦ ¦ °--SYMBOL: b [0/0] {306} + ¦ ¦--expr: [1/2] {308} + ¦ ¦ ¦--expr: [0/0] {310} + ¦ ¦ ¦ °--SYMBOL: a [0/0] {309} + ¦ ¦ ¦--'*': * [0/0] {311} + ¦ ¦ °--expr: [0/0] {313} + ¦ ¦ °--SYMBOL: b [0/0] {312} + ¦ ¦--expr: [1/2] {314} + ¦ ¦ ¦--expr: [0/0] {316} + ¦ ¦ ¦ °--SYMBOL: a [0/0] {315} + ¦ ¦ ¦--'/': / [0/0] {317} + ¦ ¦ °--expr: [0/0] {319} + ¦ ¦ °--SYMBOL: b [0/0] {318} + ¦ ¦--expr: [1/2] {320} + ¦ ¦ ¦--expr: [0/0] {322} + ¦ ¦ ¦ °--SYMBOL: a [0/0] {321} + ¦ ¦ ¦--'^': ^ [0/0] {323} + ¦ ¦ °--expr: [0/0] {325} + ¦ ¦ °--SYMBOL: b [0/0] {324} + ¦ ¦--expr: [1/2] {326} + ¦ ¦ ¦--expr: [0/0] {328} + ¦ ¦ ¦ °--SYMBOL: a [0/0] {327} + ¦ ¦ ¦--AND: & [0/0] {329} + ¦ ¦ °--expr: [0/0] {331} + ¦ ¦ °--SYMBOL: b [0/0] {330} + ¦ ¦--expr: [1/2] {332} + ¦ ¦ ¦--expr: [0/0] {334} + ¦ ¦ ¦ °--SYMBOL: a [0/0] {333} + ¦ ¦ ¦--OR: | [0/0] {335} + ¦ ¦ °--expr: [0/0] {337} + ¦ ¦ °--SYMBOL: b [0/0] {336} + ¦ ¦--expr: [1/2] {338} + ¦ ¦ ¦--expr: [0/0] {340} + ¦ ¦ ¦ °--SYMBOL: a [0/0] {339} + ¦ ¦ ¦--LEFT_ASSIGN: := [0/0] {341} + ¦ ¦ °--expr: [0/0] {343} + ¦ ¦ °--SYMBOL: b [0/0] {342} + ¦ ¦--expr: [2/2] {344} + ¦ ¦ ¦--expr: [0/0] {346} + ¦ ¦ ¦ °--SYMBOL: a [0/0] {345} + ¦ ¦ ¦--'+': + [0/0] {347} + ¦ ¦ °--expr: [0/0] {349} + ¦ ¦ °--SYMBOL: b [0/0] {348} + ¦ ¦--expr: [1/2] {350} + ¦ ¦ ¦--expr: [0/0] {352} + ¦ ¦ ¦ °--SYMBOL: a [0/0] {351} + ¦ ¦ ¦--'-': - [0/0] {353} + ¦ ¦ °--expr: [0/0] {355} + ¦ ¦ °--SYMBOL: b [0/0] {354} + ¦ ¦--expr: [1/2] {356} + ¦ ¦ ¦--expr: [0/0] {358} + ¦ ¦ ¦ °--SYMBOL: a [0/0] {357} + ¦ ¦ ¦--'+': + [0/0] {359} + ¦ ¦ °--expr: [0/0] {360} + ¦ ¦ ¦--'+': + [0/0] {361} + ¦ ¦ °--expr: [0/0] {363} + ¦ ¦ °--SYMBOL: b [0/0] {362} + ¦ ¦--expr: [1/2] {364} + ¦ ¦ ¦--expr: [0/0] {366} + ¦ ¦ ¦ °--SYMBOL: a [0/0] {365} + ¦ ¦ ¦--'+': + [0/0] {367} + ¦ ¦ °--expr: [0/0] {368} + ¦ ¦ ¦--'-': - [0/0] {369} + ¦ ¦ °--expr: [0/0] {371} + ¦ ¦ °--SYMBOL: b [0/0] {370} + ¦ ¦--expr: [1/2] {372} + ¦ ¦ ¦--expr: [0/0] {374} + ¦ ¦ ¦ °--SYMBOL: a [0/0] {373} + ¦ ¦ ¦--'+': + [0/0] {375} + ¦ ¦ °--expr: [0/0] {376} + ¦ ¦ ¦--'+': + [0/0] {377} + ¦ ¦ °--expr: [0/0] {379} + ¦ ¦ °--SYMBOL: b [0/0] {378} + ¦ ¦--expr: [1/2] {380} + ¦ ¦ ¦--expr: [0/0] {382} + ¦ ¦ ¦ °--SYMBOL: a [0/0] {381} + ¦ ¦ ¦--'-': - [0/0] {383} + ¦ ¦ °--expr: [0/0] {384} + ¦ ¦ ¦--'+': + [0/0] {385} + ¦ ¦ °--expr: [0/0] {387} + ¦ ¦ °--SYMBOL: b [0/0] {386} + ¦ ¦--expr: [1/2] {388} + ¦ ¦ ¦--expr: [0/0] {390} + ¦ ¦ ¦ °--SYMBOL: a [0/0] {389} + ¦ ¦ ¦--'-': - [0/0] {391} + ¦ ¦ °--expr: [0/0] {392} + ¦ ¦ ¦--'-': - [0/0] {393} + ¦ ¦ °--expr: [0/0] {395} + ¦ ¦ °--SYMBOL: b [0/0] {394} + ¦ ¦--expr: [1/2] {396} + ¦ ¦ ¦--expr: [0/0] {398} + ¦ ¦ ¦ °--SYMBOL: a [0/0] {397} + ¦ ¦ ¦--'+': + [0/0] {399} + ¦ ¦ °--expr: [0/0] {400} + ¦ ¦ ¦--'-': - [0/0] {401} + ¦ ¦ °--expr: [0/0] {402} + ¦ ¦ ¦--'-': - [0/0] {403} + ¦ ¦ °--expr: [0/0] {405} + ¦ ¦ °--SYMBOL: b [0/0] {404} + ¦ ¦--expr: [1/2] {406} + ¦ ¦ ¦--expr: [0/0] {408} + ¦ ¦ ¦ °--SYMBOL: a [0/0] {407} + ¦ ¦ ¦--'-': - [0/0] {409} + ¦ ¦ °--expr: [0/0] {410} + ¦ ¦ ¦--'-': - [0/0] {411} + ¦ ¦ °--expr: [0/0] {412} + ¦ ¦ ¦--'+': + [0/0] {413} + ¦ ¦ °--expr: [0/0] {415} + ¦ ¦ °--SYMBOL: b [0/0] {414} + ¦ ¦--expr: [1/2] {416} + ¦ ¦ ¦--expr: [0/0] {418} + ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: call [0/0] {417} + ¦ ¦ ¦--'(': ( [0/1] {419} + ¦ ¦ ¦--expr: [0/0] {420} + ¦ ¦ ¦ ¦--'+': + [0/1] {421} + ¦ ¦ ¦ °--expr: [0/0] {423} + ¦ ¦ ¦ °--SYMBOL: a [0/0] {422} + ¦ ¦ °--')': ) [0/0] {424} + ¦ ¦--expr: [1/2] {425} + ¦ ¦ ¦--expr: [0/0] {427} + ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: call [0/0] {426} + ¦ ¦ ¦--'(': ( [0/1] {428} + ¦ ¦ ¦--expr: [0/0] {429} + ¦ ¦ ¦ ¦--'-': - [0/1] {430} + ¦ ¦ ¦ °--expr: [0/0] {432} + ¦ ¦ ¦ °--SYMBOL: a [0/0] {431} + ¦ ¦ °--')': ) [0/0] {433} + ¦ ¦--expr: [1/2] {434} + ¦ ¦ ¦--expr: [0/0] {436} + ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: call [0/0] {435} + ¦ ¦ ¦--'(': ( [0/0] {437} + ¦ ¦ ¦--expr: [0/0] {439} + ¦ ¦ ¦ °--NUM_CONST: 5 [0/0] {438} + ¦ ¦ ¦--',': , [0/1] {440} + ¦ ¦ ¦--expr: [0/0] {441} + ¦ ¦ ¦ ¦--'+': + [0/1] {442} + ¦ ¦ ¦ °--expr: [0/0] {444} + ¦ ¦ ¦ °--SYMBOL: a [0/0] {443} + ¦ ¦ °--')': ) [0/0] {445} + ¦ ¦--expr: [1/2] {446} + ¦ ¦ ¦--expr: [0/0] {448} + ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: call [0/0] {447} + ¦ ¦ ¦--'(': ( [0/0] {449} + ¦ ¦ ¦--expr: [0/0] {451} + ¦ ¦ ¦ °--NUM_CONST: 5 [0/0] {450} + ¦ ¦ ¦--',': , [0/1] {452} + ¦ ¦ ¦--expr: [0/0] {453} + ¦ ¦ ¦ ¦--'-': - [0/1] {454} + ¦ ¦ ¦ °--expr: [0/0] {456} + ¦ ¦ ¦ °--SYMBOL: a [0/0] {455} + ¦ ¦ °--')': ) [0/0] {457} + ¦ ¦--COMMENT: # Onl [2/2] {458} + ¦ ¦--expr: [1/2] {459} + ¦ ¦ ¦--expr: [0/0] {461} + ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: call [0/0] {460} + ¦ ¦ ¦--'(': ( [0/4] {462} + ¦ ¦ ¦--expr: [1/0] {464} + ¦ ¦ ¦ °--SYMBOL: prese [0/0] {463} + ¦ ¦ ¦--',': , [0/1] {465} + ¦ ¦ ¦--expr: [0/0] {467} + ¦ ¦ ¦ °--SYMBOL: dista [0/0] {466} + ¦ ¦ ¦--',': , [0/4] {468} + ¦ ¦ ¦--expr: [1/0] {470} + ¦ ¦ ¦ °--SYMBOL: after [0/0] {469} + ¦ ¦ ¦--',': , [0/5] {471} + ¦ ¦ ¦--expr: [0/0] {473} + ¦ ¦ ¦ °--SYMBOL: comma [0/0] {472} + ¦ ¦ ¦--',': , [0/4] {474} + ¦ ¦ ¦--expr: [1/0] {476} + ¦ ¦ ¦ °--SYMBOL: given [0/0] {475} + ¦ ¦ ¦--',': , [0/0] {477} + ¦ ¦ ¦--expr: [0/2] {479} + ¦ ¦ ¦ °--SYMBOL: one [0/0] {478} + ¦ ¦ °--')': ) [1/0] {480} + ¦ ¦--expr: [2/2] {481} + ¦ ¦ ¦--IF: if [0/0] {482} + ¦ ¦ ¦--'(': ( [0/0] {483} + ¦ ¦ ¦--expr: [0/0] {485} + ¦ ¦ ¦ °--NUM_CONST: TRUE [0/0] {484} + ¦ ¦ ¦--')': ) [0/0] {486} + ¦ ¦ °--expr: [0/0] {487} + ¦ ¦ ¦--'{': { [0/4] {488} + ¦ ¦ ¦--expr: [1/2] {490} + ¦ ¦ ¦ °--NUM_CONST: FALSE [0/0] {489} + ¦ ¦ °--'}': } [1/0] {491} + ¦ ¦--expr: [2/2] {492} + ¦ ¦ ¦--IF: if [0/0] {493} + ¦ ¦ ¦--'(': ( [0/0] {494} + ¦ ¦ ¦--expr: [0/0] {496} + ¦ ¦ ¦ °--NUM_CONST: TRUE [0/0] {495} + ¦ ¦ ¦--')': ) [0/0] {497} + ¦ ¦ ¦--expr: [0/0] {498} + ¦ ¦ ¦ ¦--'{': { [0/4] {499} + ¦ ¦ ¦ ¦--expr: [1/2] {501} + ¦ ¦ ¦ ¦ °--NUM_CONST: FALSE [0/0] {500} + ¦ ¦ ¦ °--'}': } [1/0] {502} + ¦ ¦ ¦--ELSE: else [0/0] {503} + ¦ ¦ °--expr: [0/0] {504} + ¦ ¦ ¦--'{': { [0/4] {505} + ¦ ¦ ¦--expr: [1/2] {507} + ¦ ¦ ¦ °--NUM_CONST: TRUE [0/0] {506} + ¦ ¦ °--'}': } [1/0] {508} + ¦ ¦--expr: [2/2] {509} + ¦ ¦ ¦--WHILE: while [0/0] {510} + ¦ ¦ ¦--'(': ( [0/0] {511} + ¦ ¦ ¦--expr: [0/0] {513} + ¦ ¦ ¦ °--NUM_CONST: TRUE [0/0] {512} + ¦ ¦ ¦--')': ) [0/0] {514} + ¦ ¦ °--expr: [0/0] {515} + ¦ ¦ ¦--'{': { [0/4] {516} + ¦ ¦ ¦--expr: [1/2] {518} + ¦ ¦ ¦ °--NUM_CONST: FALSE [0/0] {517} + ¦ ¦ °--'}': } [1/0] {519} + ¦ ¦--expr: [2/2] {520} + ¦ ¦ ¦--expr: [0/1] {522} + ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: singl [0/0] {521} + ¦ ¦ ¦--'(': ( [0/1] {523} + ¦ ¦ ¦--expr: [0/1] {525} + ¦ ¦ ¦ °--STR_CONST: "func [0/0] {524} + ¦ ¦ ¦--',': , [0/0] {526} + ¦ ¦ ¦--expr: [0/1] {528} + ¦ ¦ ¦ °--SYMBOL: call [0/0] {527} + ¦ ¦ °--')': ) [0/0] {529} + ¦ ¦--expr: [2/2] {530} + ¦ ¦ ¦--expr: [0/1] {532} + ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: multi [0/0] {531} + ¦ ¦ ¦--'(': ( [0/2] {533} + ¦ ¦ ¦--expr: [1/0] {535} + ¦ ¦ ¦ °--STR_CONST: "func [0/0] {534} + ¦ ¦ ¦--',': , [0/1] {536} + ¦ ¦ ¦--expr: [0/1] {538} + ¦ ¦ ¦ °--SYMBOL: call [0/0] {537} + ¦ ¦ °--')': ) [0/0] {539} + ¦ ¦--expr: [2/2] {540} + ¦ ¦ ¦--expr: [0/1] {542} + ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: neste [0/0] {541} + ¦ ¦ ¦--'(': ( [0/1] {543} + ¦ ¦ ¦--expr: [0/1] {544} + ¦ ¦ ¦ ¦--expr: [0/1] {546} + ¦ ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: funct [0/0] {545} + ¦ ¦ ¦ ¦--'(': ( [0/1] {547} + ¦ ¦ ¦ ¦--expr: [0/1] {549} + ¦ ¦ ¦ ¦ °--STR_CONST: "in" [0/0] {548} + ¦ ¦ ¦ ¦--',': , [0/0] {550} + ¦ ¦ ¦ ¦--expr: [0/1] {552} + ¦ ¦ ¦ ¦ °--SYMBOL: one [0/0] {551} + ¦ ¦ ¦ ¦--',': , [0/0] {553} + ¦ ¦ ¦ ¦--expr: [0/1] {555} + ¦ ¦ ¦ ¦ °--SYMBOL: line [0/0] {554} + ¦ ¦ ¦ °--')': ) [0/0] {556} + ¦ ¦ °--')': ) [0/0] {557} + ¦ ¦--expr: [2/2] {558} + ¦ ¦ ¦--expr: [0/1] {560} + ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: neste [0/0] {559} + ¦ ¦ ¦--'(': ( [0/1] {561} + ¦ ¦ ¦--expr: [0/1] {562} + ¦ ¦ ¦ ¦--expr: [0/1] {564} + ¦ ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: funct [0/0] {563} + ¦ ¦ ¦ ¦--'(': ( [0/2] {565} + ¦ ¦ ¦ ¦--expr: [1/0] {567} + ¦ ¦ ¦ ¦ °--STR_CONST: "in" [0/0] {566} + ¦ ¦ ¦ ¦--',': , [0/6] {568} + ¦ ¦ ¦ ¦--expr: [1/0] {570} + ¦ ¦ ¦ ¦ °--SYMBOL: multi [0/0] {569} + ¦ ¦ ¦ ¦--',': , [0/0] {571} + ¦ ¦ ¦ ¦--expr: [0/1] {573} + ¦ ¦ ¦ ¦ °--SYMBOL: lines [0/0] {572} + ¦ ¦ ¦ °--')': ) [0/0] {574} + ¦ ¦ °--')': ) [0/0] {575} + ¦ ¦--expr: [2/2] {576} + ¦ ¦ ¦--expr: [0/0] {578} + ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: neste [0/0] {577} + ¦ ¦ ¦--'(': ( [0/2] {579} + ¦ ¦ ¦--expr: [1/0] {580} + ¦ ¦ ¦ ¦--expr: [0/1] {582} + ¦ ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: funct [0/0] {581} + ¦ ¦ ¦ ¦--'(': ( [0/1] {583} + ¦ ¦ ¦ ¦--expr: [0/1] {585} + ¦ ¦ ¦ ¦ °--SYMBOL: with [0/0] {584} + ¦ ¦ ¦ °--')': ) [0/0] {586} + ¦ ¦ ¦--',': , [0/6] {587} + ¦ ¦ ¦--expr: [1/2] {589} + ¦ ¦ ¦ °--SYMBOL: many [0/0] {588} + ¦ ¦ ¦--',': , [1/5] {590} + ¦ ¦ ¦--expr: [0/2] {592} + ¦ ¦ ¦ °--SYMBOL: first [0/0] {591} + ¦ ¦ °--')': ) [0/0] {593} + ¦ ¦--expr: [2/2] {594} + ¦ ¦ ¦--expr: [0/0] {596} + ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: neste [0/0] {595} + ¦ ¦ ¦--'(': ( [0/4] {597} + ¦ ¦ ¦--expr: [1/0] {598} + ¦ ¦ ¦ ¦--expr: [0/1] {600} + ¦ ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: funct [0/0] {599} + ¦ ¦ ¦ ¦--'(': ( [0/1] {601} + ¦ ¦ ¦ ¦--expr: [0/1] {603} + ¦ ¦ ¦ ¦ °--SYMBOL: with [0/0] {602} + ¦ ¦ ¦ °--')': ) [0/0] {604} + ¦ ¦ ¦--',': , [0/2] {605} + ¦ ¦ ¦--COMMENT: # a c [0/4] {606} + ¦ ¦ ¦--expr: [1/1] {608} + ¦ ¦ ¦ °--SYMBOL: many [0/0] {607} + ¦ ¦ ¦--COMMENT: #more [0/4] {609} + ¦ ¦ ¦--',': , [1/5] {610} + ¦ ¦ ¦--expr: [0/2] {612} + ¦ ¦ ¦ °--SYMBOL: first [0/0] {611} + ¦ ¦ °--')': ) [0/0] {613} + ¦ ¦--expr: [2/0] {614} + ¦ ¦ ¦--expr: [0/0] {616} + ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: diffi [0/0] {615} + ¦ ¦ ¦--'(': ( [0/0] {617} + ¦ ¦ ¦--expr: [0/0] {618} + ¦ ¦ ¦ ¦--expr: [0/0] {620} + ¦ ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: neste [0/0] {619} + ¦ ¦ ¦ ¦--'(': ( [0/4] {621} + ¦ ¦ ¦ ¦--expr: [1/0] {623} + ¦ ¦ ¦ ¦ °--STR_CONST: "func [0/0] {622} + ¦ ¦ ¦ ¦--',': , [0/1] {624} + ¦ ¦ ¦ ¦--expr: [0/2] {626} + ¦ ¦ ¦ ¦ °--SYMBOL: call [0/0] {625} + ¦ ¦ ¦ °--')': ) [1/0] {627} + ¦ ¦ ¦--',': , [0/4] {628} + ¦ ¦ ¦--expr: [1/0] {630} + ¦ ¦ ¦ °--SYMBOL: with [0/0] {629} + ¦ ¦ ¦--',': , [0/1] {631} + ¦ ¦ ¦--expr: [0/0] {633} + ¦ ¦ ¦ °--SYMBOL: more [0/0] {632} + ¦ ¦ ¦--',': , [0/1] {634} + ¦ ¦ ¦--expr: [0/2] {636} + ¦ ¦ ¦ °--SYMBOL: args [0/0] {635} + ¦ ¦ °--')': ) [1/0] {637} + ¦ °--'}': } [1/0] {638} + ¦--COMMENT: # for [3/0] {639} + ¦--expr: [1/0] {640} + ¦ ¦--expr: [0/0] {642} + ¦ ¦ °--SYMBOL_FUNCTION_CALL: lm [0/0] {641} + ¦ ¦--'(': ( [0/0] {643} + ¦ ¦--expr: [0/0] {644} + ¦ ¦ ¦--expr: [0/0] {646} + ¦ ¦ ¦ °--SYMBOL: a [0/0] {645} + ¦ ¦ ¦--'~': ~ [0/0] {647} + ¦ ¦ °--expr: [0/0] {648} + ¦ ¦ ¦--expr: [0/0] {650} + ¦ ¦ ¦ °--SYMBOL: b [0/0] {649} + ¦ ¦ ¦--'+': + [0/0] {651} + ¦ ¦ °--expr: [0/0] {653} + ¦ ¦ °--SYMBOL: c [0/0] {652} + ¦ ¦--',': , [0/0] {654} + ¦ ¦--SYMBOL_SUB: data [0/0] {655} + ¦ ¦--EQ_SUB: = [0/0] {656} + ¦ ¦--expr: [0/0] {658} + ¦ ¦ °--NUM_CONST: NA [0/0] {657} + ¦ °--')': ) [0/0] {659} + ¦--expr: [1/0] {660} + ¦ ¦--expr: [0/0] {662} + ¦ ¦ °--SYMBOL_FUNCTION_CALL: lm [0/0] {661} + ¦ ¦--'(': ( [0/0] {663} + ¦ ¦--expr: [0/0] {664} + ¦ ¦ ¦--expr: [0/0] {666} + ¦ ¦ ¦ °--SYMBOL: a [0/0] {665} + ¦ ¦ ¦--'~': ~ [0/0] {667} + ¦ ¦ °--expr: [0/0] {668} + ¦ ¦ ¦--expr: [0/0] {670} + ¦ ¦ ¦ °--SYMBOL: . [0/0] {669} + ¦ ¦ ¦--'-': - [0/0] {671} + ¦ ¦ °--expr: [0/0] {673} + ¦ ¦ °--NUM_CONST: 1 [0/0] {672} + ¦ ¦--',': , [0/0] {674} + ¦ ¦--SYMBOL_SUB: data [0/0] {675} + ¦ ¦--EQ_SUB: = [0/0] {676} + ¦ ¦--expr: [0/0] {678} + ¦ ¦ °--NUM_CONST: NA [0/0] {677} + ¦ °--')': ) [0/0] {679} + ¦--expr: [1/0] {680} + ¦ ¦--expr: [0/0] {682} + ¦ ¦ °--SYMBOL: a [0/0] {681} + ¦ ¦--'~': ~ [0/0] {683} + ¦ °--expr: [0/0] {684} + ¦ ¦--expr: [0/0] {686} + ¦ ¦ °--SYMBOL: b [0/0] {685} + ¦ ¦--':': : [0/0] {687} + ¦ °--expr: [0/0] {689} + ¦ °--SYMBOL: c [0/0] {688} + ¦--expr: [1/0] {690} + ¦ ¦--expr: [0/3] {692} + ¦ ¦ °--SYMBOL: a [0/0] {691} + ¦ ¦--'~': ~ [0/3] {693} + ¦ °--expr: [0/0] {694} + ¦ ¦--expr: [0/2] {696} + ¦ ¦ °--SYMBOL: b [0/0] {695} + ¦ ¦--':': : [0/1] {697} + ¦ °--expr: [0/0] {699} + ¦ °--SYMBOL: c [0/0] {698} + ¦--expr: [1/0] {700} + ¦ ¦--expr: [0/0] {702} + ¦ ¦ °--SYMBOL: a [0/0] {701} + ¦ ¦--'~': ~ [0/0] {703} + ¦ °--expr: [0/0] {704} + ¦ ¦--expr: [0/1] {706} + ¦ ¦ °--SYMBOL: b [0/0] {705} + ¦ ¦--':': : [0/0] {707} + ¦ °--expr: [0/0] {709} + ¦ °--SYMBOL: c [0/0] {708} + ¦--expr: [1/0] {710} + ¦ ¦--'~': ~ [0/4] {711} + ¦ °--expr: [0/0] {713} + ¦ °--SYMBOL: a [0/0] {712} + ¦--expr: [1/0] {714} + ¦ ¦--'~': ~ [0/0] {715} + ¦ °--expr: [0/0] {717} + ¦ °--SYMBOL: gg [0/0] {716} + ¦--expr: [1/0] {718} + ¦ ¦--expr: [0/0] {720} + ¦ ¦ °--SYMBOL: b [0/0] {719} + ¦ ¦--'~': ~ [0/0] {721} + ¦ °--expr: [0/0] {723} + ¦ °--SYMBOL: k [0/0] {722} + °--expr: [1/0] {724} + ¦--expr: [0/0] {726} + ¦ °--SYMBOL_FUNCTION_CALL: call [0/0] {725} + ¦--'(': ( [0/0] {727} + ¦--expr: [0/0] {729} + ¦ °--NUM_CONST: 1 [0/0] {728} + ¦--',': , [0/1] {730} + ¦--expr: [0/0] {731} + ¦ ¦--'~': ~ [0/1] {732} + ¦ °--expr: [0/0] {734} + ¦ °--SYMBOL: qq [0/0] {733} + °--')': ) [0/0] {735} diff --git a/tests/testthat/token_adding_removing/mixed_token-in_tree b/tests/testthat/token_adding_removing/mixed_token-in_tree index 8f7efb769..ab05ca364 100644 --- a/tests/testthat/token_adding_removing/mixed_token-in_tree +++ b/tests/testthat/token_adding_removing/mixed_token-in_tree @@ -1,86 +1,86 @@ ROOT (token: short_text [lag_newlines/spaces] {pos_id}) ¦--COMMENT: # = r [0/0] {1} - ¦--expr: [1/0] {1.9} - ¦ ¦--expr: [0/1] {3} - ¦ ¦ °--SYMBOL: a [0/0] {2} - ¦ ¦--EQ_ASSIGN: = [0/1] {4} - ¦ °--expr: [0/0] {6} - ¦ °--NUM_CONST: 3 [0/0] {5} - ¦--expr: [1/0] {7} - ¦ ¦--expr: [0/0] {9} - ¦ ¦ °--SYMBOL_FUNCTION_CALL: data_ [0/0] {8} - ¦ ¦--'(': ( [0/0] {10} - ¦ ¦--SYMBOL_SUB: a [0/1] {11} - ¦ ¦--EQ_SUB: = [0/1] {12} - ¦ ¦--expr: [0/0] {14} - ¦ ¦ °--NUM_CONST: 3 [0/0] {13} - ¦ °--')': ) [0/0] {15} - ¦--COMMENT: # sem [2/0] {16} - ¦--expr: [1/0] {18} - ¦ °--SYMBOL: a [0/0] {17} - ¦--';': ; [0/1] {19} - ¦--expr: [0/1] {21} - ¦ °--SYMBOL: b [0/0] {20} - ¦--';': ; [0/0] {22} - ¦--expr: [0/0] {24} - ¦ °--SYMBOL: c [0/0] {23} - ¦--';': ; [0/0] {25} - ¦--expr: [0/0] {27} - ¦ °--SYMBOL: d [0/0] {26} - ¦--COMMENT: # quo [3/0] {28} - ¦--expr: [1/0] {30} - ¦ °--STR_CONST: "text [0/0] {29} - ¦--expr: [1/0] {32} - ¦ °--STR_CONST: 'text [0/0] {31} - ¦--COMMENT: # no [3/0] {33} - ¦--expr: [1/0] {34} - ¦ ¦--expr: [0/1] {37} - ¦ ¦ °--SYMBOL: a [0/0] {36} - ¦ ¦--SPECIAL-PIPE: %>% [0/1] {38} - ¦ ¦--expr: [0/1] {39} - ¦ ¦ ¦--expr: [0/0] {41} - ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: b [0/0] {40} - ¦ ¦ ¦--'(': ( [0/0] {42} - ¦ ¦ °--')': ) [0/0] {43} - ¦ ¦--SPECIAL-PIPE: %>% [0/0] {44} - ¦ °--expr: [0/0] {45} - ¦ ¦--expr: [0/0] {47} - ¦ ¦ °--SYMBOL_FUNCTION_CALL: c [0/0] {46} - ¦ ¦--'(': ( [0/0] {48} - ¦ °--')': ) [0/0] {49} - ¦--COMMENT: # lin [2/0] {50} - ¦--expr: [1/0] {51} - ¦ ¦--expr: [0/1] {54} - ¦ ¦ °--SYMBOL: a [0/0] {53} - ¦ ¦--SPECIAL-PIPE: %>% [0/2] {55} - ¦ ¦--expr: [1/1] {56} - ¦ ¦ ¦--expr: [0/0] {58} - ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: b [0/0] {57} - ¦ ¦ ¦--'(': ( [0/0] {59} - ¦ ¦ °--')': ) [0/0] {60} - ¦ ¦--SPECIAL-PIPE: %>% [0/0] {61} - ¦ °--expr: [0/0] {62} - ¦ ¦--expr: [0/0] {64} - ¦ ¦ °--SYMBOL_FUNCTION_CALL: c [0/0] {63} - ¦ ¦--'(': ( [0/0] {65} - ¦ °--')': ) [0/0] {66} - ¦--COMMENT: # add [2/0] {67} - ¦--expr: [1/0] {68} - ¦ ¦--expr: [0/1] {71} - ¦ ¦ °--SYMBOL: a [0/0] {70} - ¦ ¦--SPECIAL-PIPE: %>% [0/2] {72} - ¦ ¦--expr: [1/1] {74} - ¦ ¦ °--SYMBOL: b [0/0] {73} - ¦ ¦--SPECIAL-PIPE: %>% [0/2] {75} - ¦ °--expr: [1/0] {77} - ¦ °--SYMBOL: c [0/0] {76} - ¦--COMMENT: # add [2/0] {78} - °--expr: [1/0] {79} - ¦--expr: [0/1] {82} - ¦ °--SYMBOL: a [0/0] {81} - ¦--SPECIAL-PIPE: %>% [0/1] {83} - ¦--expr: [0/1] {85} - ¦ °--SYMBOL: b [0/0] {84} - ¦--SPECIAL-PIPE: %>% [0/2] {86} - °--expr: [1/0] {88} - °--SYMBOL: c [0/0] {87} + ¦--equal_assign: [1/0] {2} + ¦ ¦--expr: [0/1] {4} + ¦ ¦ °--SYMBOL: a [0/0] {3} + ¦ ¦--EQ_ASSIGN: = [0/1] {5} + ¦ °--expr: [0/0] {7} + ¦ °--NUM_CONST: 3 [0/0] {6} + ¦--expr: [1/0] {8} + ¦ ¦--expr: [0/0] {10} + ¦ ¦ °--SYMBOL_FUNCTION_CALL: data_ [0/0] {9} + ¦ ¦--'(': ( [0/0] {11} + ¦ ¦--SYMBOL_SUB: a [0/1] {12} + ¦ ¦--EQ_SUB: = [0/1] {13} + ¦ ¦--expr: [0/0] {15} + ¦ ¦ °--NUM_CONST: 3 [0/0] {14} + ¦ °--')': ) [0/0] {16} + ¦--COMMENT: # sem [2/0] {17} + ¦--expr: [1/0] {19} + ¦ °--SYMBOL: a [0/0] {18} + ¦--';': ; [0/1] {20} + ¦--expr: [0/1] {22} + ¦ °--SYMBOL: b [0/0] {21} + ¦--';': ; [0/0] {23} + ¦--expr: [0/0] {25} + ¦ °--SYMBOL: c [0/0] {24} + ¦--';': ; [0/0] {26} + ¦--expr: [0/0] {28} + ¦ °--SYMBOL: d [0/0] {27} + ¦--COMMENT: # quo [3/0] {29} + ¦--expr: [1/0] {31} + ¦ °--STR_CONST: "text [0/0] {30} + ¦--expr: [1/0] {33} + ¦ °--STR_CONST: 'text [0/0] {32} + ¦--COMMENT: # no [3/0] {34} + ¦--expr: [1/0] {35} + ¦ ¦--expr: [0/1] {38} + ¦ ¦ °--SYMBOL: a [0/0] {37} + ¦ ¦--SPECIAL-PIPE: %>% [0/1] {39} + ¦ ¦--expr: [0/1] {40} + ¦ ¦ ¦--expr: [0/0] {42} + ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: b [0/0] {41} + ¦ ¦ ¦--'(': ( [0/0] {43} + ¦ ¦ °--')': ) [0/0] {44} + ¦ ¦--SPECIAL-PIPE: %>% [0/0] {45} + ¦ °--expr: [0/0] {46} + ¦ ¦--expr: [0/0] {48} + ¦ ¦ °--SYMBOL_FUNCTION_CALL: c [0/0] {47} + ¦ ¦--'(': ( [0/0] {49} + ¦ °--')': ) [0/0] {50} + ¦--COMMENT: # lin [2/0] {51} + ¦--expr: [1/0] {52} + ¦ ¦--expr: [0/1] {55} + ¦ ¦ °--SYMBOL: a [0/0] {54} + ¦ ¦--SPECIAL-PIPE: %>% [0/2] {56} + ¦ ¦--expr: [1/1] {57} + ¦ ¦ ¦--expr: [0/0] {59} + ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: b [0/0] {58} + ¦ ¦ ¦--'(': ( [0/0] {60} + ¦ ¦ °--')': ) [0/0] {61} + ¦ ¦--SPECIAL-PIPE: %>% [0/0] {62} + ¦ °--expr: [0/0] {63} + ¦ ¦--expr: [0/0] {65} + ¦ ¦ °--SYMBOL_FUNCTION_CALL: c [0/0] {64} + ¦ ¦--'(': ( [0/0] {66} + ¦ °--')': ) [0/0] {67} + ¦--COMMENT: # add [2/0] {68} + ¦--expr: [1/0] {69} + ¦ ¦--expr: [0/1] {72} + ¦ ¦ °--SYMBOL: a [0/0] {71} + ¦ ¦--SPECIAL-PIPE: %>% [0/2] {73} + ¦ ¦--expr: [1/1] {75} + ¦ ¦ °--SYMBOL: b [0/0] {74} + ¦ ¦--SPECIAL-PIPE: %>% [0/2] {76} + ¦ °--expr: [1/0] {78} + ¦ °--SYMBOL: c [0/0] {77} + ¦--COMMENT: # add [2/0] {79} + °--expr: [1/0] {80} + ¦--expr: [0/1] {83} + ¦ °--SYMBOL: a [0/0] {82} + ¦--SPECIAL-PIPE: %>% [0/1] {84} + ¦--expr: [0/1] {86} + ¦ °--SYMBOL: b [0/0] {85} + ¦--SPECIAL-PIPE: %>% [0/2] {87} + °--expr: [1/0] {89} + °--SYMBOL: c [0/0] {88} From 37381a323e1d708bf175f3377612e4610cd744f7 Mon Sep 17 00:00:00 2001 From: lorenzwalthert Date: Fri, 3 May 2019 09:45:38 +0200 Subject: [PATCH 13/48] try install pandoc as linked other solutions at https://github.com/krlmlr/r-appveyor/issues/82 --- appveyor.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/appveyor.yml b/appveyor.yml index 536bfcb87..5f92a566a 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -6,6 +6,12 @@ init: $ErrorActionPreference = "Stop" Invoke-WebRequest http://raw.github.com/krlmlr/r-appveyor/master/scripts/appveyor-tool.ps1 -OutFile "..\appveyor-tool.ps1" Import-Module '..\appveyor-tool.ps1' + if (-Not (Test-Path "C:\Program Files (x86)\Pandoc\")) { + cinst pandoc + } + $env:Path += ";C:\Program Files (x86)\Pandoc\" + pandoc -v + install: - ps: Bootstrap From 301a8619c4bb978cc89fc80f0dad0d0f284cf7ad Mon Sep 17 00:00:00 2001 From: lorenzwalthert Date: Sun, 28 Apr 2019 15:09:50 +0200 Subject: [PATCH 14/48] let user specify transformers, not just style argument for flexibility. Rename option styler.addins.style -> styler.addins_style_transformer. Overhaul documentumentation for Addins, add life cycle. --- .Rbuildignore | 1 + R/addins.R | 121 ++++++++++-------- inst/rstudio/addins.dcf | 4 +- ...d => get_addins_style_transformer_name.Rd} | 6 +- man/prompt_style.Rd | 12 -- man/style_selection.Rd | 12 ++ man/styler_addins.Rd | 39 ++++-- tests/testmanual/addins/non-r.py | 2 + tests/testmanual/addins/r-invalid.R | 1 + tests/testmanual/addins/r-valid.R | 1 + tests/testmanual/addins/rmd-invalid.Rmd | 30 +++++ tests/testmanual/addins/rmd-valid.Rmd | 30 +++++ tests/testmanual/addins/rnw-invalid.Rnw | 28 ++++ tests/testmanual/addins/rnw-valid.Rnw | 28 ++++ tests/testmanual/tests | 16 +++ 15 files changed, 253 insertions(+), 78 deletions(-) rename man/{get_addins_style_name.Rd => get_addins_style_transformer_name.Rd} (68%) delete mode 100644 man/prompt_style.Rd create mode 100644 man/style_selection.Rd create mode 100644 tests/testmanual/addins/non-r.py create mode 100644 tests/testmanual/addins/r-invalid.R create mode 100644 tests/testmanual/addins/r-valid.R create mode 100644 tests/testmanual/addins/rmd-invalid.Rmd create mode 100644 tests/testmanual/addins/rmd-valid.Rmd create mode 100644 tests/testmanual/addins/rnw-invalid.Rnw create mode 100644 tests/testmanual/addins/rnw-valid.Rnw create mode 100644 tests/testmanual/tests diff --git a/.Rbuildignore b/.Rbuildignore index 753470c98..a4912951e 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -16,3 +16,4 @@ CONTRIBUTING.md ^gitsum$ revdep ^cran-comments\.md$ +^tests/testmanual$ diff --git a/R/addins.R b/R/addins.R index ac63567ed..b7407f524 100644 --- a/R/addins.R +++ b/R/addins.R @@ -1,7 +1,24 @@ #' Stylers for RStudio Addins #' #' Helper functions for styling via RStudio Addins. -#' +#' @section Addins: +#' * Set style: Select the style transformers to use. For flexibility, the user +#' input is passed to the `transformers` argument, not the `style` argument, so +#' enter `styler::tidyverse_style(scope = "spaces")` in the Addin is +#' equivalent to `styler::style_text("1+1", scope = "spaces")` and +#' `styler::style_text("1+1", transformers = styler::tidyverse_style(scope = "spaces"))` +#' if the text to style is `1 + 1`. The style is memorized within an R +#' session. If you want it to persist over a session, set the option +#' `styler.addins_style_transformer` in your `.Rprofile`. +#' * Style active file: Styles the active file, by default with +#' [ tidyverse_style()] and `strict = TRUE`. You can set the style +#' with the Addin `Set style`. +#' @section Life cycle: +#' The way of specifying the style in the Addin is experimental. We currently +#' think about letting the user specify the defaults for other style APIs like +#' [styler::style_text()], either via R options, config files or other ways as +#' well. See [r-lib/styler#319](https://github.com/r-lib/styler/issues/319) for +#' the current status of this. #' @section Auto-Save Option: #' By default, both of the RStudio Addins will apply styling to the (selected) #' file contents without saving changes. Automatic saving can be enabled by @@ -16,14 +33,13 @@ #' @seealso [Sys.setenv()] NULL -#' @describeIn styler_addins Styles the active file with [tidyverse_style()] and -#' `strict = TRUE`. + #' @importFrom rlang abort #' @keywords internal style_active_file <- function() { communicate_addins_style() context <- get_rstudio_context() - transformer <- make_transformer(get_addins_style_fun()(), + transformer <- make_transformer(get_addins_style_fun(), include_roxygen_examples = TRUE, warn_empty = is_plain_r_file(context$path) ) @@ -47,38 +63,7 @@ style_active_file <- function() { rstudioapi::setCursorPosition(context$selection[[1]]$range) } -#' Style a file as if it was an .R file -#' -#' If not successful, the file is most -#' likely not a .R file, so saving the file and try styling again will work if -#' the file is an .Rmd file. Otherwise, we can throw an error that the file must -#' be a .R or .Rmd file. -#' @param context The context from `styler:::get_rstudio_context()`. -#' @param transformer A transformer function most conveniently constructed with -#' [make_transformer()]. -#' @importFrom rlang with_handlers abort -#' @keywords internal -try_transform_as_r_file <- function(context, transformer) { - with_handlers( - transformer(context$contents), - error = function(e) { - preamble_for_unsaved <- paste( - "Styling of unsaved files is only supported for R files with valid code.", - "Please save the file (as .R or .Rmd) and make sure that the R code in it", - "can be parsed. Then, try to style again." - ) - - if (context$path == "") { - abort(paste0(preamble_for_unsaved, " The error was \n", e$message)) - } else { - abort(e$message) - } - } - ) -} - -#' @describeIn styler_addins Styles the highlighted selection in a `.R` or -#' `.Rmd` file. +#' Styles the highlighted selection in a `.R` or `.Rmd` file. #' @importFrom rlang abort #' @keywords internal style_selection <- function() { @@ -100,43 +85,77 @@ get_rstudio_context <- function() { rstudioapi::getActiveDocumentContext() } -#' Ask the user to supply a style -#' +#' @describeIn styler_addins asks the user to supply a style #' @importFrom rlang abort #' @keywords internal #' @importFrom rlang with_handlers abort -prompt_style <- function() { - current_style <- get_addins_style_name() +set_style_transformers <- function() { + current_style <- get_addins_style_transformer_name() new_style <- rstudioapi::showPrompt( "Select a style", - "Enter the name of a style function, e.g. `styler::tidyverse_style`", + "Enter the name of a style transformer, e.g. `styler::tidyverse_style()`", current_style ) - parsed_new_style <- with_handlers( - eval(parse(text = new_style)), + parsed_new_style <- with_handlers({ + transformers <- eval(parse(text = new_style)) + style_text(c("a = 2", "function() {", "NULL", "}")) + }, error = function(e) { - abort(paste0("The selected style \"", new_style, "\" is not valid: ", e$message)) + abort(paste0( + "The selected style transformers \"", + new_style, "\" is not valid: ", e$message + )) } ) - options(styler.addins.style = new_style) + options(styler.addins_style_transformer = new_style) invisible(current_style) } #' Return the style function or name #' #' @keywords internal -get_addins_style_name <- function() { - getOption("styler.addins.style", default = "styler::tidyverse_style") +get_addins_style_transformer_name <- function() { + getOption("styler.addins_style_transformer", default = "styler::tidyverse_style()") } -#' @rdname get_addins_style_name +#' @rdname get_addins_style_transformer_name #' @keywords internal get_addins_style_fun <- function() { - eval(parse(text = get_addins_style_name())) + eval(parse(text = get_addins_style_transformer_name())) } communicate_addins_style <- function() { - style_name <- get_addins_style_name() - cat("Using style `", style_name, "`\n", sep = "") + style_name <- get_addins_style_transformer_name() + cat("Using style transformers`", style_name, "`\n", sep = "") +} + +#' Style a file as if it was an .R file +#' +#' If not successful, the file is most +#' likely not a .R file, so saving the file and try styling again will work if +#' the file is an .Rmd file. Otherwise, we can throw an error that the file must +#' be a .R or .Rmd file. +#' @param context The context from `styler:::get_rstudio_context()`. +#' @param transformer A transformer function most conveniently constructed with +#' [make_transformer()]. +#' @importFrom rlang with_handlers abort +#' @keywords internal +try_transform_as_r_file <- function(context, transformer) { + with_handlers( + transformer(context$contents), + error = function(e) { + preamble_for_unsaved <- paste( + "Styling of unsaved files is only supported for R files with valid code.", + "Please save the file (as .R or .Rmd) and make sure that the R code in it", + "can be parsed. Then, try to style again." + ) + + if (context$path == "") { + abort(paste0(preamble_for_unsaved, " The error was \n", e$message)) + } else { + abort(e$message) + } + } + ) } diff --git a/inst/rstudio/addins.dcf b/inst/rstudio/addins.dcf index 027ff00cb..0b524b316 100644 --- a/inst/rstudio/addins.dcf +++ b/inst/rstudio/addins.dcf @@ -1,6 +1,6 @@ Name: Set style -Description: Prompt for and set the style used by all STYLER addins -Binding: prompt_style +Description: Prompt for and set the style transformers used by all styler addins +Binding: set_style_transformers Interactive: true Name: Style active file diff --git a/man/get_addins_style_name.Rd b/man/get_addins_style_transformer_name.Rd similarity index 68% rename from man/get_addins_style_name.Rd rename to man/get_addins_style_transformer_name.Rd index 0873f3761..a5c005390 100644 --- a/man/get_addins_style_name.Rd +++ b/man/get_addins_style_transformer_name.Rd @@ -1,11 +1,11 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/addins.R -\name{get_addins_style_name} -\alias{get_addins_style_name} +\name{get_addins_style_transformer_name} +\alias{get_addins_style_transformer_name} \alias{get_addins_style_fun} \title{Return the style function or name} \usage{ -get_addins_style_name() +get_addins_style_transformer_name() get_addins_style_fun() } diff --git a/man/prompt_style.Rd b/man/prompt_style.Rd deleted file mode 100644 index 539d25103..000000000 --- a/man/prompt_style.Rd +++ /dev/null @@ -1,12 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/addins.R -\name{prompt_style} -\alias{prompt_style} -\title{Ask the user to supply a style} -\usage{ -prompt_style() -} -\description{ -Ask the user to supply a style -} -\keyword{internal} diff --git a/man/style_selection.Rd b/man/style_selection.Rd new file mode 100644 index 000000000..668695a44 --- /dev/null +++ b/man/style_selection.Rd @@ -0,0 +1,12 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/addins.R +\name{style_selection} +\alias{style_selection} +\title{Styles the highlighted selection in a \code{.R} or \code{.Rmd} file.} +\usage{ +style_selection() +} +\description{ +Styles the highlighted selection in a \code{.R} or \code{.Rmd} file. +} +\keyword{internal} diff --git a/man/styler_addins.Rd b/man/styler_addins.Rd index acddef317..1be6c4a5d 100644 --- a/man/styler_addins.Rd +++ b/man/styler_addins.Rd @@ -2,26 +2,45 @@ % Please edit documentation in R/addins.R \name{styler_addins} \alias{styler_addins} -\alias{style_active_file} -\alias{style_selection} +\alias{set_style_transformers} \title{Stylers for RStudio Addins} \usage{ -style_active_file() - -style_selection() +set_style_transformers() } \description{ Helper functions for styling via RStudio Addins. } \section{Functions}{ \itemize{ -\item \code{style_active_file}: Styles the active file with \code{\link[=tidyverse_style]{tidyverse_style()}} and -\code{strict = TRUE}. - -\item \code{style_selection}: Styles the highlighted selection in a \code{.R} or -\code{.Rmd} file. +\item \code{set_style_transformers}: asks the user to supply a style }} +\section{Addins}{ + +\itemize{ +\item Set style: Select the style transformers to use. For flexibility, the user +input is passed to the \code{transformers} argument, not the \code{style} argument, so +enter \code{styler::tidyverse_style(scope = "spaces")} in the Addin is +equivalent to \code{styler::style_text("1+1", scope = "spaces")} and +\code{styler::style_text("1+1", transformers = styler::tidyverse_style(scope = "spaces"))} +if the text to style is \code{1 + 1}. The style is memorized within an R +session. If you want it to persist over a session, set the option +\code{styler.addins_style_transformer} in your \code{.Rprofile}. +\item Style active file: Styles the active file, by default with +\code{\link[= tidyverse_style]{ tidyverse_style()}} and \code{strict = TRUE}. You can set the style +with the Addin \code{Set style}. +} +} + +\section{Life-cycle}{ + +The way of specifying the style in the Addin is experimental. We currently +think about letting the user specify the defaults for other style APIs like +\code{\link[styler:style_text]{styler::style_text()}}, either via R options, config files or other ways as +well. See \href{https://github.com/r-lib/styler/issues/319}{r-lib/styler#319} for +the current status of this. +} + \section{Auto-Save Option}{ By default, both of the RStudio Addins will apply styling to the (selected) diff --git a/tests/testmanual/addins/non-r.py b/tests/testmanual/addins/non-r.py new file mode 100644 index 000000000..381f905d2 --- /dev/null +++ b/tests/testmanual/addins/non-r.py @@ -0,0 +1,2 @@ +2 + 2 +" " diff --git a/tests/testmanual/addins/r-invalid.R b/tests/testmanual/addins/r-invalid.R new file mode 100644 index 000000000..88d5c0639 --- /dev/null +++ b/tests/testmanual/addins/r-invalid.R @@ -0,0 +1 @@ +1+ /1 diff --git a/tests/testmanual/addins/r-valid.R b/tests/testmanual/addins/r-valid.R new file mode 100644 index 000000000..612dabf52 --- /dev/null +++ b/tests/testmanual/addins/r-valid.R @@ -0,0 +1 @@ +1+ 1 diff --git a/tests/testmanual/addins/rmd-invalid.Rmd b/tests/testmanual/addins/rmd-invalid.Rmd new file mode 100644 index 000000000..5b7c2f3ee --- /dev/null +++ b/tests/testmanual/addins/rmd-invalid.Rmd @@ -0,0 +1,30 @@ +--- +title: "Untitled" +author: "Lorenz Walthert" +date: "4/28/2019" +output: html_document +--- + +```{r setup, include=FALSE} +knitr::opts_chunk$setecho = -TRUE) +``` + +## R Markdown + +This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see . + +When you click the **Knit** button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this: + +```{r cars} +summary(cars ) +``` + +## Including Plots + +You can also embed plots, for example: + +```{r pressure, echo=FALSE} +plot(pressure) +``` + +Note that the `echo = FALSE` parameter was added to the code chunk to prevent printing of the R code that generated the plot. diff --git a/tests/testmanual/addins/rmd-valid.Rmd b/tests/testmanual/addins/rmd-valid.Rmd new file mode 100644 index 000000000..b92ffe928 --- /dev/null +++ b/tests/testmanual/addins/rmd-valid.Rmd @@ -0,0 +1,30 @@ +--- +title: "Untitled" +author: "Lorenz Walthert" +date: "4/28/2019" +output: html_document +--- + +```{r setup, include=FALSE} +knitr::opts_chunk$set(echo = -TRUE) +``` + +## R Markdown + +This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see . + +When you click the **Knit** button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this: + +```{r cars} +summary(cars) +``` + +## Including Plots + +You can also embed plots, for example: + +```{r pressure, echo=FALSE} +plot(pressure) +``` + +Note that the `echo = FALSE` parameter was added to the code chunk to prevent printing of the R code that generated the plot. diff --git a/tests/testmanual/addins/rnw-invalid.Rnw b/tests/testmanual/addins/rnw-invalid.Rnw new file mode 100644 index 000000000..046415c2c --- /dev/null +++ b/tests/testmanual/addins/rnw-invalid.Rnw @@ -0,0 +1,28 @@ +\documentclass{article} + +\begin{document} + +Some text +<>>= +# Some R code +f <- function(x) { + x +} +@ + +More text + +<<>>= +# More R code +g <- function(y) { + y +} +@ + +Final text +<<>>= +1 + 2 +@ + + +\end{document} diff --git a/tests/testmanual/addins/rnw-valid.Rnw b/tests/testmanual/addins/rnw-valid.Rnw new file mode 100644 index 000000000..e964baaf9 --- /dev/null +++ b/tests/testmanual/addins/rnw-valid.Rnw @@ -0,0 +1,28 @@ +\documentclass{article} + +\begin{document} + +Some text +<<>>= +# Some R code +f <- function(x) { + x +} +@ + +More text + +<<>>= +# More R code +g <- function(y) { + y +} +@ + +Final text +<<>>= +1 + 2 +@ + + +\end{document} diff --git a/tests/testmanual/tests b/tests/testmanual/tests new file mode 100644 index 000000000..09081c041 --- /dev/null +++ b/tests/testmanual/tests @@ -0,0 +1,16 @@ +# Manual tests + +## Addins + +* set style: + - test setting a valid stlye + - test setting an invalid style +* style active file: + - saved .R file (valid and invalid code) + - unsaved .R file + - saved .Rmd file (valid and invalid code) + - unsaved .Rmd file + - saved .Rnw file (valid and invalid code) + - unsaved .Rnw file + - saved non-R file + - unsaved R file From ad492f53c94a5326f07a80fbf351b70bb999fd12 Mon Sep 17 00:00:00 2001 From: lorenzwalthert Date: Sun, 28 Apr 2019 16:32:35 +0200 Subject: [PATCH 15/48] fix function reference --- R/addins.R | 2 +- R/style-guides.R | 1 - man/set_style_transformers.Rd | 12 ++++++++++++ man/styler_addins.Rd | 12 +----------- 4 files changed, 14 insertions(+), 13 deletions(-) create mode 100644 man/set_style_transformers.Rd diff --git a/R/addins.R b/R/addins.R index b7407f524..6fb8a6490 100644 --- a/R/addins.R +++ b/R/addins.R @@ -85,7 +85,7 @@ get_rstudio_context <- function() { rstudioapi::getActiveDocumentContext() } -#' @describeIn styler_addins asks the user to supply a style +#' Asks the user to supply a style #' @importFrom rlang abort #' @keywords internal #' @importFrom rlang with_handlers abort diff --git a/R/style-guides.R b/R/style-guides.R index 89980ff83..385d1c38b 100644 --- a/R/style-guides.R +++ b/R/style-guides.R @@ -29,7 +29,6 @@ NULL #' @inheritParams create_style_guide #' @param math_token_spacing A list of parameters that define spacing around #' math token, conveniently constructed using [specify_math_token_spacing()]. - #' @details The following options for `scope` are available. #' #' * "none": Performs no transformation at all. diff --git a/man/set_style_transformers.Rd b/man/set_style_transformers.Rd new file mode 100644 index 000000000..410693bb3 --- /dev/null +++ b/man/set_style_transformers.Rd @@ -0,0 +1,12 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/addins.R +\name{set_style_transformers} +\alias{set_style_transformers} +\title{Asks the user to supply a style} +\usage{ +set_style_transformers() +} +\description{ +Asks the user to supply a style +} +\keyword{internal} diff --git a/man/styler_addins.Rd b/man/styler_addins.Rd index 1be6c4a5d..0ed2dce3b 100644 --- a/man/styler_addins.Rd +++ b/man/styler_addins.Rd @@ -2,19 +2,10 @@ % Please edit documentation in R/addins.R \name{styler_addins} \alias{styler_addins} -\alias{set_style_transformers} \title{Stylers for RStudio Addins} -\usage{ -set_style_transformers() -} \description{ Helper functions for styling via RStudio Addins. } -\section{Functions}{ -\itemize{ -\item \code{set_style_transformers}: asks the user to supply a style -}} - \section{Addins}{ \itemize{ @@ -32,7 +23,7 @@ with the Addin \code{Set style}. } } -\section{Life-cycle}{ +\section{Life cycle}{ The way of specifying the style in the Addin is experimental. We currently think about letting the user specify the defaults for other style APIs like @@ -60,4 +51,3 @@ Other stylers: \code{\link{style_dir}}, \code{\link{style_text}} } \concept{stylers} -\keyword{internal} From da092bbad3c5ff83a05f9eee43d85a3dcd78efc0 Mon Sep 17 00:00:00 2001 From: lorenzwalthert Date: Sun, 28 Apr 2019 16:33:46 +0200 Subject: [PATCH 16/48] fix ci --- tic.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tic.R b/tic.R index b23d448ac..25e33dea2 100644 --- a/tic.R +++ b/tic.R @@ -1,4 +1,4 @@ -add_package_checks(error_on = ifelse(getRversion() >= "3.2", "note", "error")) +do_package_checks(error_on = ifelse(getRversion() >= "3.2", "note", "error")) if (Sys.getenv("id_rsa") != "" && ci()$get_branch() == "master" && Sys.getenv("BUILD_PKGDOWN") != "") { # pkgdown documentation can be built optionally. Other example criteria: From 5b8f64c3626469292e6b0a77e6ec26a909dfb4c7 Mon Sep 17 00:00:00 2001 From: lorenzwalthert Date: Tue, 30 Apr 2019 21:02:36 +0200 Subject: [PATCH 17/48] hotfix addin for selection styling. --- R/addins.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/addins.R b/R/addins.R index 6fb8a6490..375518748 100644 --- a/R/addins.R +++ b/R/addins.R @@ -71,7 +71,7 @@ style_selection <- function() { context <- get_rstudio_context() text <- context$selection[[1]]$text if (all(nchar(text) == 0)) abort("No code selected") - out <- style_text(text, style = get_addins_style_fun()) + out <- style_text(text, transformers = get_addins_style_fun()) rstudioapi::modifyRange( context$selection[[1]]$range, paste0(out, collapse = "\n"), id = context$id From 1ded3d54867691d8d212c08ba944b133fef80c85 Mon Sep 17 00:00:00 2001 From: lorenzwalthert Date: Tue, 30 Apr 2019 21:24:38 +0200 Subject: [PATCH 18/48] add manual test instructions for selection styling. --- tests/testmanual/tests | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/testmanual/tests b/tests/testmanual/tests index 09081c041..e54f0373b 100644 --- a/tests/testmanual/tests +++ b/tests/testmanual/tests @@ -14,3 +14,13 @@ - unsaved .Rnw file - saved non-R file - unsaved R file +* style selection: + - saved .R file (valid and invalid code) + - unsaved .R file + - saved .Rmd file (valid and invalid code) + - unsaved .Rmd file + - saved .Rnw file (valid and invalid code) + - unsaved .Rnw file + - saved non-R file + - unsaved R file + From c3bc20201c31cb28aeda9e33f862bd1e9ed7984a Mon Sep 17 00:00:00 2001 From: lorenzwalthert Date: Tue, 30 Apr 2019 21:29:36 +0200 Subject: [PATCH 19/48] typo --- R/addins.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/addins.R b/R/addins.R index 375518748..b7a904ad0 100644 --- a/R/addins.R +++ b/R/addins.R @@ -127,7 +127,7 @@ get_addins_style_fun <- function() { communicate_addins_style <- function() { style_name <- get_addins_style_transformer_name() - cat("Using style transformers`", style_name, "`\n", sep = "") + cat("Using style transformers `", style_name, "`\n", sep = "") } #' Style a file as if it was an .R file From efabfd4c64ded614ae172b74b0fe208540ed41db Mon Sep 17 00:00:00 2001 From: lorenzwalthert Date: Fri, 3 May 2019 08:47:38 +0200 Subject: [PATCH 20/48] fix ref to tidyverse style --- R/addins.R | 2 +- man/styler_addins.Rd | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/R/addins.R b/R/addins.R index b7a904ad0..c45e937d3 100644 --- a/R/addins.R +++ b/R/addins.R @@ -11,7 +11,7 @@ #' session. If you want it to persist over a session, set the option #' `styler.addins_style_transformer` in your `.Rprofile`. #' * Style active file: Styles the active file, by default with -#' [ tidyverse_style()] and `strict = TRUE`. You can set the style +#' [tidyverse_style()] and `strict = TRUE`. You can set the style #' with the Addin `Set style`. #' @section Life cycle: #' The way of specifying the style in the Addin is experimental. We currently diff --git a/man/styler_addins.Rd b/man/styler_addins.Rd index 0ed2dce3b..ad8a08571 100644 --- a/man/styler_addins.Rd +++ b/man/styler_addins.Rd @@ -18,7 +18,7 @@ if the text to style is \code{1 + 1}. The style is memorized within an R session. If you want it to persist over a session, set the option \code{styler.addins_style_transformer} in your \code{.Rprofile}. \item Style active file: Styles the active file, by default with -\code{\link[= tidyverse_style]{ tidyverse_style()}} and \code{strict = TRUE}. You can set the style +\code{\link[=tidyverse_style]{tidyverse_style()}} and \code{strict = TRUE}. You can set the style with the Addin \code{Set style}. } } From a246b1edc3f5022d87ec31b7d8182e3b6ccec17e Mon Sep 17 00:00:00 2001 From: lorenzwalthert Date: Fri, 3 May 2019 09:08:28 +0200 Subject: [PATCH 21/48] don't visibly return rstudioapi::documentSave() --- R/addins.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/addins.R b/R/addins.R index c45e937d3..62a85eabd 100644 --- a/R/addins.R +++ b/R/addins.R @@ -77,7 +77,7 @@ style_selection <- function() { id = context$id ) if (Sys.getenv("save_after_styling") == TRUE && context$path != "") { - rstudioapi::documentSave(context$id) + invisible(rstudioapi::documentSave(context$id)) } } From abcef958a5ac6dff72ecc0440069d55526cd1992 Mon Sep 17 00:00:00 2001 From: lorenzwalthert Date: Fri, 3 May 2019 10:19:08 +0200 Subject: [PATCH 22/48] better Addin explanation --- R/addins.R | 15 +++++++++------ man/styler_addins.Rd | 11 +++++++---- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/R/addins.R b/R/addins.R index 62a85eabd..a6ad39b77 100644 --- a/R/addins.R +++ b/R/addins.R @@ -2,17 +2,20 @@ #' #' Helper functions for styling via RStudio Addins. #' @section Addins: -#' * Set style: Select the style transformers to use. For flexibility, the user +#' - Set style: Select the style transformers to use. For flexibility, the user #' input is passed to the `transformers` argument, not the `style` argument, so #' enter `styler::tidyverse_style(scope = "spaces")` in the Addin is #' equivalent to `styler::style_text("1+1", scope = "spaces")` and #' `styler::style_text("1+1", transformers = styler::tidyverse_style(scope = "spaces"))` -#' if the text to style is `1 + 1`. The style is memorized within an R -#' session. If you want it to persist over a session, set the option +#' if the text to style is `1 + 1`. The style transformers are memorized +#' within an R session via the R option `styler.addins_style_transformer` so +#' if you want it to persist over sessions, set the option #' `styler.addins_style_transformer` in your `.Rprofile`. -#' * Style active file: Styles the active file, by default with -#' [tidyverse_style()] and `strict = TRUE`. You can set the style -#' with the Addin `Set style`. +#' - Style active file: Styles the active file, by default with +#' [tidyverse_style()] and `strict = TRUE` or the value of the option +#' `styler.addins_style_transformer` if specified. +#' - Style selection: Same as *style active file*, but styles the highlighted +#' code instead of the whole file. #' @section Life cycle: #' The way of specifying the style in the Addin is experimental. We currently #' think about letting the user specify the defaults for other style APIs like diff --git a/man/styler_addins.Rd b/man/styler_addins.Rd index ad8a08571..e313d3e62 100644 --- a/man/styler_addins.Rd +++ b/man/styler_addins.Rd @@ -14,12 +14,15 @@ input is passed to the \code{transformers} argument, not the \code{style} argume enter \code{styler::tidyverse_style(scope = "spaces")} in the Addin is equivalent to \code{styler::style_text("1+1", scope = "spaces")} and \code{styler::style_text("1+1", transformers = styler::tidyverse_style(scope = "spaces"))} -if the text to style is \code{1 + 1}. The style is memorized within an R -session. If you want it to persist over a session, set the option +if the text to style is \code{1 + 1}. The style transformers are memorized +within an R session via the R option \code{styler.addins_style_transformer} so +if you want it to persist over sessions, set the option \code{styler.addins_style_transformer} in your \code{.Rprofile}. \item Style active file: Styles the active file, by default with -\code{\link[=tidyverse_style]{tidyverse_style()}} and \code{strict = TRUE}. You can set the style -with the Addin \code{Set style}. +\code{\link[=tidyverse_style]{tidyverse_style()}} and \code{strict = TRUE} or the value of the option +\code{styler.addins_style_transformer} if specified. +\item Style selection: Same as \emph{style active file}, but styles the highlighted +code instead of the whole file. } } From 4f18f0b6dc5eaf2196518bda8fb0a4751a899c96 Mon Sep 17 00:00:00 2001 From: lorenzwalthert Date: Fri, 3 May 2019 10:27:10 +0200 Subject: [PATCH 23/48] another round of doc improvement --- R/addins.R | 12 ++++++++++-- man/styler_addins.Rd | 14 +++++++++++--- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/R/addins.R b/R/addins.R index a6ad39b77..93090b8bb 100644 --- a/R/addins.R +++ b/R/addins.R @@ -4,7 +4,7 @@ #' @section Addins: #' - Set style: Select the style transformers to use. For flexibility, the user #' input is passed to the `transformers` argument, not the `style` argument, so -#' enter `styler::tidyverse_style(scope = "spaces")` in the Addin is +#' entering `styler::tidyverse_style(scope = "spaces")` in the Addin is #' equivalent to `styler::style_text("1+1", scope = "spaces")` and #' `styler::style_text("1+1", transformers = styler::tidyverse_style(scope = "spaces"))` #' if the text to style is `1 + 1`. The style transformers are memorized @@ -33,7 +33,15 @@ #' #' @name styler_addins #' @family stylers -#' @seealso [Sys.setenv()] +#' @examples +#' \dontrun{ +#' # save after styling when using the Addin +#' Sys.setenv(save_after_styling = TRUE) +#' # only style with scope = "spaces" when using the Addin +#' options( +#' styler.addins_style_transformer = "styler::tidyverse_style(scope = 'spaces')" +#' ) +#' } NULL diff --git a/man/styler_addins.Rd b/man/styler_addins.Rd index e313d3e62..48254cf48 100644 --- a/man/styler_addins.Rd +++ b/man/styler_addins.Rd @@ -11,7 +11,7 @@ Helper functions for styling via RStudio Addins. \itemize{ \item Set style: Select the style transformers to use. For flexibility, the user input is passed to the \code{transformers} argument, not the \code{style} argument, so -enter \code{styler::tidyverse_style(scope = "spaces")} in the Addin is +entering \code{styler::tidyverse_style(scope = "spaces")} in the Addin is equivalent to \code{styler::style_text("1+1", scope = "spaces")} and \code{styler::style_text("1+1", transformers = styler::tidyverse_style(scope = "spaces"))} if the text to style is \code{1 + 1}. The style transformers are memorized @@ -46,9 +46,17 @@ this setting across multiple sessions. Untitled files will always need to be saved manually after styling. } +\examples{ +\dontrun{ +# save after styling when using the Addin +Sys.setenv(save_after_styling = TRUE) +# only style with scope = "spaces" when using the Addin +options( + styler.addins_style_transformer = "styler::tidyverse_style(scope = 'spaces')" +) +} +} \seealso{ -\code{\link[=Sys.setenv]{Sys.setenv()}} - Other stylers: \code{\link{style_dir}}, \code{\link{style_file}}, \code{\link{style_pkg}}, \code{\link{style_text}} From 1dc7475e1d160dc744d4ad19fa36f9042e9615ad Mon Sep 17 00:00:00 2001 From: lorenzwalthert Date: Thu, 2 May 2019 23:20:58 +0200 Subject: [PATCH 24/48] draft: break line after pipe in most situations --- R/rules-line-break.R | 2 +- R/transform-files.R | 8 +- .../pipe-line-breaks-in.R | 50 +++++ .../pipe-line-breaks-in_tree | 196 ++++++++++++++++++ .../pipe-line-breaks-out.R | 53 +++++ tests/testthat/test-line_breaks_and_other.R | 5 + 6 files changed, 307 insertions(+), 7 deletions(-) create mode 100644 tests/testthat/line_breaks_and_other/pipe-line-breaks-in.R create mode 100644 tests/testthat/line_breaks_and_other/pipe-line-breaks-in_tree create mode 100644 tests/testthat/line_breaks_and_other/pipe-line-breaks-out.R diff --git a/R/rules-line-break.R b/R/rules-line-break.R index a13c11316..5dc30b5a1 100644 --- a/R/rules-line-break.R +++ b/R/rules-line-break.R @@ -49,7 +49,7 @@ remove_line_break_before_round_closing_fun_dec <- function(pd) { #' @importFrom rlang seq2 add_line_break_after_pipe <- function(pd) { is_special <- pd$token == c("SPECIAL-PIPE") & pd$token_after != "COMMENT" - if (any(pd$lag_newlines != 0L)) { + if (any(is_special) && !(next_terminal(pd, vars = "token_before")$token_before == c("'('"))) { pd$lag_newlines[lag(is_special)] <- 1L } pd diff --git a/R/transform-files.R b/R/transform-files.R index 737c9281b..dac30132c 100644 --- a/R/transform-files.R +++ b/R/transform-files.R @@ -211,14 +211,10 @@ parse_transform_serialize_r <- function(text, transformers, warn_empty = TRUE) { #' @importFrom purrr flatten #' @keywords internal apply_transformers <- function(pd_nested, transformers) { - transformed_line_breaks <- pre_visit( - pd_nested, - c(transformers$initialize, transformers$line_break) - ) transformed_updated_multi_line <- post_visit( - transformed_line_breaks, - c(set_multi_line, update_newlines) + pd_nested, + c(transformers$initialize, transformers$line_break, set_multi_line, update_newlines) ) transformed_all <- pre_visit( diff --git a/tests/testthat/line_breaks_and_other/pipe-line-breaks-in.R b/tests/testthat/line_breaks_and_other/pipe-line-breaks-in.R new file mode 100644 index 000000000..da3898cd8 --- /dev/null +++ b/tests/testthat/line_breaks_and_other/pipe-line-breaks-in.R @@ -0,0 +1,50 @@ +c(a %>% b) + +c(a %>% b()) + +c(a + b %>% c) + +c( + a %>% b) + +c(a %>% b() +) + +c(a %>% b() # 33 +) + +c( + a + b %>% c + ) + +c( + a + b %>% + c +) + +c( + a + b %>% # 654 + c +) + +c( # rr + a + b %>% + c +) + +c( + a + + b %>% c +) + +c(a + + b %>% c +) + +a %>% b( +) + +a %>% + b() + +{a %>% c +1} diff --git a/tests/testthat/line_breaks_and_other/pipe-line-breaks-in_tree b/tests/testthat/line_breaks_and_other/pipe-line-breaks-in_tree new file mode 100644 index 000000000..ff4c0ca4b --- /dev/null +++ b/tests/testthat/line_breaks_and_other/pipe-line-breaks-in_tree @@ -0,0 +1,196 @@ +ROOT (token: short_text [lag_newlines/spaces] {pos_id}) + ¦--expr: [0/0] {1} + ¦ ¦--expr: [0/0] {3} + ¦ ¦ °--SYMBOL_FUNCTION_CALL: c [0/0] {2} + ¦ ¦--'(': ( [0/0] {4} + ¦ ¦--expr: [0/0] {5} + ¦ ¦ ¦--expr: [0/1] {7} + ¦ ¦ ¦ °--SYMBOL: a [0/0] {6} + ¦ ¦ ¦--SPECIAL-PIPE: %>% [0/1] {8} + ¦ ¦ °--expr: [0/0] {10} + ¦ ¦ °--SYMBOL: b [0/0] {9} + ¦ °--')': ) [0/0] {11} + ¦--expr: [2/0] {12} + ¦ ¦--expr: [0/0] {14} + ¦ ¦ °--SYMBOL_FUNCTION_CALL: c [0/0] {13} + ¦ ¦--'(': ( [0/0] {15} + ¦ ¦--expr: [0/0] {16} + ¦ ¦ ¦--expr: [0/1] {18} + ¦ ¦ ¦ °--SYMBOL: a [0/0] {17} + ¦ ¦ ¦--SPECIAL-PIPE: %>% [0/1] {19} + ¦ ¦ °--expr: [0/0] {20} + ¦ ¦ ¦--expr: [0/0] {22} + ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: b [0/0] {21} + ¦ ¦ ¦--'(': ( [0/0] {23} + ¦ ¦ °--')': ) [0/0] {24} + ¦ °--')': ) [0/0] {25} + ¦--expr: [2/0] {26} + ¦ ¦--expr: [0/0] {28} + ¦ ¦ °--SYMBOL_FUNCTION_CALL: c [0/0] {27} + ¦ ¦--'(': ( [0/0] {29} + ¦ ¦--expr: [0/0] {30} + ¦ ¦ ¦--expr: [0/1] {32} + ¦ ¦ ¦ °--SYMBOL: a [0/0] {31} + ¦ ¦ ¦--'+': + [0/1] {33} + ¦ ¦ ¦--expr: [0/1] {36} + ¦ ¦ ¦ °--SYMBOL: b [0/0] {35} + ¦ ¦ ¦--SPECIAL-PIPE: %>% [0/1] {37} + ¦ ¦ °--expr: [0/0] {39} + ¦ ¦ °--SYMBOL: c [0/0] {38} + ¦ °--')': ) [0/0] {40} + ¦--expr: [2/0] {41} + ¦ ¦--expr: [0/0] {43} + ¦ ¦ °--SYMBOL_FUNCTION_CALL: c [0/0] {42} + ¦ ¦--'(': ( [0/2] {44} + ¦ ¦--expr: [1/0] {45} + ¦ ¦ ¦--expr: [0/1] {47} + ¦ ¦ ¦ °--SYMBOL: a [0/0] {46} + ¦ ¦ ¦--SPECIAL-PIPE: %>% [0/1] {48} + ¦ ¦ °--expr: [0/0] {50} + ¦ ¦ °--SYMBOL: b [0/0] {49} + ¦ °--')': ) [0/0] {51} + ¦--expr: [2/0] {52} + ¦ ¦--expr: [0/0] {54} + ¦ ¦ °--SYMBOL_FUNCTION_CALL: c [0/0] {53} + ¦ ¦--'(': ( [0/0] {55} + ¦ ¦--expr: [0/0] {56} + ¦ ¦ ¦--expr: [0/1] {58} + ¦ ¦ ¦ °--SYMBOL: a [0/0] {57} + ¦ ¦ ¦--SPECIAL-PIPE: %>% [0/1] {59} + ¦ ¦ °--expr: [0/0] {60} + ¦ ¦ ¦--expr: [0/0] {62} + ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: b [0/0] {61} + ¦ ¦ ¦--'(': ( [0/0] {63} + ¦ ¦ °--')': ) [0/0] {64} + ¦ °--')': ) [1/0] {65} + ¦--expr: [2/0] {66} + ¦ ¦--expr: [0/0] {68} + ¦ ¦ °--SYMBOL_FUNCTION_CALL: c [0/0] {67} + ¦ ¦--'(': ( [0/0] {69} + ¦ ¦--expr: [0/1] {70} + ¦ ¦ ¦--expr: [0/1] {72} + ¦ ¦ ¦ °--SYMBOL: a [0/0] {71} + ¦ ¦ ¦--SPECIAL-PIPE: %>% [0/1] {73} + ¦ ¦ °--expr: [0/0] {74} + ¦ ¦ ¦--expr: [0/0] {76} + ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: b [0/0] {75} + ¦ ¦ ¦--'(': ( [0/0] {77} + ¦ ¦ °--')': ) [0/0] {78} + ¦ ¦--COMMENT: # 33 [0/0] {79} + ¦ °--')': ) [1/0] {80} + ¦--expr: [2/0] {81} + ¦ ¦--expr: [0/0] {83} + ¦ ¦ °--SYMBOL_FUNCTION_CALL: c [0/0] {82} + ¦ ¦--'(': ( [0/2] {84} + ¦ ¦--expr: [1/2] {85} + ¦ ¦ ¦--expr: [0/1] {87} + ¦ ¦ ¦ °--SYMBOL: a [0/0] {86} + ¦ ¦ ¦--'+': + [0/1] {88} + ¦ ¦ ¦--expr: [0/1] {91} + ¦ ¦ ¦ °--SYMBOL: b [0/0] {90} + ¦ ¦ ¦--SPECIAL-PIPE: %>% [0/1] {92} + ¦ ¦ °--expr: [0/0] {94} + ¦ ¦ °--SYMBOL: c [0/0] {93} + ¦ °--')': ) [1/0] {95} + ¦--expr: [2/0] {96} + ¦ ¦--expr: [0/0] {98} + ¦ ¦ °--SYMBOL_FUNCTION_CALL: c [0/0] {97} + ¦ ¦--'(': ( [0/2] {99} + ¦ ¦--expr: [1/0] {100} + ¦ ¦ ¦--expr: [0/1] {102} + ¦ ¦ ¦ °--SYMBOL: a [0/0] {101} + ¦ ¦ ¦--'+': + [0/1] {103} + ¦ ¦ ¦--expr: [0/1] {106} + ¦ ¦ ¦ °--SYMBOL: b [0/0] {105} + ¦ ¦ ¦--SPECIAL-PIPE: %>% [0/4] {107} + ¦ ¦ °--expr: [1/0] {109} + ¦ ¦ °--SYMBOL: c [0/0] {108} + ¦ °--')': ) [1/0] {110} + ¦--expr: [2/0] {111} + ¦ ¦--expr: [0/0] {113} + ¦ ¦ °--SYMBOL_FUNCTION_CALL: c [0/0] {112} + ¦ ¦--'(': ( [0/2] {114} + ¦ ¦--expr: [1/0] {115} + ¦ ¦ ¦--expr: [0/1] {117} + ¦ ¦ ¦ °--SYMBOL: a [0/0] {116} + ¦ ¦ ¦--'+': + [0/1] {118} + ¦ ¦ ¦--expr: [0/1] {121} + ¦ ¦ ¦ °--SYMBOL: b [0/0] {120} + ¦ ¦ ¦--SPECIAL-PIPE: %>% [0/1] {122} + ¦ ¦ ¦--COMMENT: # 654 [0/4] {123} + ¦ ¦ °--expr: [1/0] {125} + ¦ ¦ °--SYMBOL: c [0/0] {124} + ¦ °--')': ) [1/0] {126} + ¦--expr: [2/0] {127} + ¦ ¦--expr: [0/0] {129} + ¦ ¦ °--SYMBOL_FUNCTION_CALL: c [0/0] {128} + ¦ ¦--'(': ( [0/1] {130} + ¦ ¦--COMMENT: # rr [0/2] {131} + ¦ ¦--expr: [1/0] {132} + ¦ ¦ ¦--expr: [0/1] {134} + ¦ ¦ ¦ °--SYMBOL: a [0/0] {133} + ¦ ¦ ¦--'+': + [0/1] {135} + ¦ ¦ ¦--expr: [0/1] {138} + ¦ ¦ ¦ °--SYMBOL: b [0/0] {137} + ¦ ¦ ¦--SPECIAL-PIPE: %>% [0/4] {139} + ¦ ¦ °--expr: [1/0] {141} + ¦ ¦ °--SYMBOL: c [0/0] {140} + ¦ °--')': ) [1/0] {142} + ¦--expr: [2/0] {143} + ¦ ¦--expr: [0/0] {145} + ¦ ¦ °--SYMBOL_FUNCTION_CALL: c [0/0] {144} + ¦ ¦--'(': ( [0/2] {146} + ¦ ¦--expr: [1/0] {147} + ¦ ¦ ¦--expr: [0/1] {149} + ¦ ¦ ¦ °--SYMBOL: a [0/0] {148} + ¦ ¦ ¦--'+': + [0/4] {150} + ¦ ¦ ¦--expr: [1/1] {153} + ¦ ¦ ¦ °--SYMBOL: b [0/0] {152} + ¦ ¦ ¦--SPECIAL-PIPE: %>% [0/1] {154} + ¦ ¦ °--expr: [0/0] {156} + ¦ ¦ °--SYMBOL: c [0/0] {155} + ¦ °--')': ) [1/0] {157} + ¦--expr: [2/0] {158} + ¦ ¦--expr: [0/0] {160} + ¦ ¦ °--SYMBOL_FUNCTION_CALL: c [0/0] {159} + ¦ ¦--'(': ( [0/0] {161} + ¦ ¦--expr: [0/0] {162} + ¦ ¦ ¦--expr: [0/1] {164} + ¦ ¦ ¦ °--SYMBOL: a [0/0] {163} + ¦ ¦ ¦--'+': + [0/4] {165} + ¦ ¦ ¦--expr: [1/1] {168} + ¦ ¦ ¦ °--SYMBOL: b [0/0] {167} + ¦ ¦ ¦--SPECIAL-PIPE: %>% [0/1] {169} + ¦ ¦ °--expr: [0/0] {171} + ¦ ¦ °--SYMBOL: c [0/0] {170} + ¦ °--')': ) [1/0] {172} + ¦--expr: [2/0] {173} + ¦ ¦--expr: [0/1] {175} + ¦ ¦ °--SYMBOL: a [0/0] {174} + ¦ ¦--SPECIAL-PIPE: %>% [0/1] {176} + ¦ °--expr: [0/0] {177} + ¦ ¦--expr: [0/0] {179} + ¦ ¦ °--SYMBOL_FUNCTION_CALL: b [0/0] {178} + ¦ ¦--'(': ( [0/0] {180} + ¦ °--')': ) [1/0] {181} + ¦--expr: [2/0] {182} + ¦ ¦--expr: [0/1] {184} + ¦ ¦ °--SYMBOL: a [0/0] {183} + ¦ ¦--SPECIAL-PIPE: %>% [0/2] {185} + ¦ °--expr: [1/0] {186} + ¦ ¦--expr: [0/0] {188} + ¦ ¦ °--SYMBOL_FUNCTION_CALL: b [0/0] {187} + ¦ ¦--'(': ( [0/0] {189} + ¦ °--')': ) [0/0] {190} + °--expr: [2/0] {191} + ¦--'{': { [0/0] {192} + ¦--expr: [0/0] {193} + ¦ ¦--expr: [0/1] {196} + ¦ ¦ °--SYMBOL: a [0/0] {195} + ¦ ¦--SPECIAL-PIPE: %>% [0/1] {197} + ¦ ¦--expr: [0/1] {199} + ¦ ¦ °--SYMBOL: c [0/0] {198} + ¦ ¦--'+': + [0/0] {200} + ¦ °--expr: [0/0] {202} + ¦ °--NUM_CONST: 1 [0/0] {201} + °--'}': } [0/0] {203} diff --git a/tests/testthat/line_breaks_and_other/pipe-line-breaks-out.R b/tests/testthat/line_breaks_and_other/pipe-line-breaks-out.R new file mode 100644 index 000000000..c0df31572 --- /dev/null +++ b/tests/testthat/line_breaks_and_other/pipe-line-breaks-out.R @@ -0,0 +1,53 @@ +c(a %>% b()) + +c(a %>% b()) + +c(a + b %>% c()) + +c( + a %>% b() +) + +c(a %>% b()) + +c( + a %>% b() # 33 +) + +c( + a + b %>% c() +) + +c( + a + b %>% + c() +) + +c( + a + b %>% # 654 + c() +) + +c( # rr + a + b %>% + c() +) + +c( + a + + b %>% c() +) + +c(a + + b %>% c()) + +a %>% + b() + +a %>% + b() + +{ + a %>% + c() + 1 +} diff --git a/tests/testthat/test-line_breaks_and_other.R b/tests/testthat/test-line_breaks_and_other.R index bdc98786b..97603068d 100644 --- a/tests/testthat/test-line_breaks_and_other.R +++ b/tests/testthat/test-line_breaks_and_other.R @@ -25,3 +25,8 @@ test_that("line break before comma is removed and placed after comma ", { expect_warning(test_collection("line_breaks_and_other", "comma", transformer = style_text), NA) }) + +test_that("line break before comma is removed and placed after comma ", { + expect_warning(test_collection("line_breaks_and_other", "pipe-line", + transformer = style_text), NA) +}) From 845d0566069164552313c336239df4f58095aacc Mon Sep 17 00:00:00 2001 From: lorenzwalthert Date: Thu, 2 May 2019 23:24:47 +0200 Subject: [PATCH 25/48] adapt tests --- R/rules-line-break.R | 3 +- .../pipe-line-breaks-in.R | 29 +- .../pipe-line-breaks-in_tree | 294 ++++++++++++++---- .../pipe-line-breaks-out.R | 32 ++ .../add_brackets_in_pipe-out.R | 6 +- .../token_adding_removing/mixed_token-in.R | 6 - .../token_adding_removing/mixed_token-in_tree | 66 +--- .../token_adding_removing/mixed_token-out.R | 7 - 8 files changed, 314 insertions(+), 129 deletions(-) diff --git a/R/rules-line-break.R b/R/rules-line-break.R index 5dc30b5a1..6b01f3f2e 100644 --- a/R/rules-line-break.R +++ b/R/rules-line-break.R @@ -49,7 +49,8 @@ remove_line_break_before_round_closing_fun_dec <- function(pd) { #' @importFrom rlang seq2 add_line_break_after_pipe <- function(pd) { is_special <- pd$token == c("SPECIAL-PIPE") & pd$token_after != "COMMENT" - if (any(is_special) && !(next_terminal(pd, vars = "token_before")$token_before == c("'('"))) { + if (any(is_special) && + !(next_terminal(pd, vars = "token_before")$token_before %in% c("'('", "EQ_SUB", "','"))) { pd$lag_newlines[lag(is_special)] <- 1L } pd diff --git a/tests/testthat/line_breaks_and_other/pipe-line-breaks-in.R b/tests/testthat/line_breaks_and_other/pipe-line-breaks-in.R index da3898cd8..f97cfaf65 100644 --- a/tests/testthat/line_breaks_and_other/pipe-line-breaks-in.R +++ b/tests/testthat/line_breaks_and_other/pipe-line-breaks-in.R @@ -19,8 +19,10 @@ c( c( a + b %>% - c -) + c) + +c(a + b %>% + c) c( a + b %>% # 654 @@ -47,4 +49,27 @@ a %>% b( a %>% b() + +fun(x, + a %>% b) + +fun(x, + gg = a %>% b, + tt %>% q) + +fun(x, gg = a %>% b, tt %>% q) + +z = a %>% b() + +fun( s = g(x), + gg = a(n == 2) %>% b, + tt %>% q(r = 3)) + +blew(x %>% + c(), y = 2) + +blew(y = 2, x %>% + c()) + + {a %>% c +1} diff --git a/tests/testthat/line_breaks_and_other/pipe-line-breaks-in_tree b/tests/testthat/line_breaks_and_other/pipe-line-breaks-in_tree index ff4c0ca4b..ea3f6478e 100644 --- a/tests/testthat/line_breaks_and_other/pipe-line-breaks-in_tree +++ b/tests/testthat/line_breaks_and_other/pipe-line-breaks-in_tree @@ -105,56 +105,56 @@ ROOT (token: short_text [lag_newlines/spaces] {pos_id}) ¦ ¦ ¦--SPECIAL-PIPE: %>% [0/4] {107} ¦ ¦ °--expr: [1/0] {109} ¦ ¦ °--SYMBOL: c [0/0] {108} - ¦ °--')': ) [1/0] {110} + ¦ °--')': ) [0/0] {110} ¦--expr: [2/0] {111} ¦ ¦--expr: [0/0] {113} ¦ ¦ °--SYMBOL_FUNCTION_CALL: c [0/0] {112} - ¦ ¦--'(': ( [0/2] {114} - ¦ ¦--expr: [1/0] {115} + ¦ ¦--'(': ( [0/0] {114} + ¦ ¦--expr: [0/0] {115} ¦ ¦ ¦--expr: [0/1] {117} ¦ ¦ ¦ °--SYMBOL: a [0/0] {116} ¦ ¦ ¦--'+': + [0/1] {118} ¦ ¦ ¦--expr: [0/1] {121} ¦ ¦ ¦ °--SYMBOL: b [0/0] {120} - ¦ ¦ ¦--SPECIAL-PIPE: %>% [0/1] {122} - ¦ ¦ ¦--COMMENT: # 654 [0/4] {123} - ¦ ¦ °--expr: [1/0] {125} - ¦ ¦ °--SYMBOL: c [0/0] {124} - ¦ °--')': ) [1/0] {126} - ¦--expr: [2/0] {127} - ¦ ¦--expr: [0/0] {129} - ¦ ¦ °--SYMBOL_FUNCTION_CALL: c [0/0] {128} - ¦ ¦--'(': ( [0/1] {130} - ¦ ¦--COMMENT: # rr [0/2] {131} - ¦ ¦--expr: [1/0] {132} - ¦ ¦ ¦--expr: [0/1] {134} - ¦ ¦ ¦ °--SYMBOL: a [0/0] {133} - ¦ ¦ ¦--'+': + [0/1] {135} - ¦ ¦ ¦--expr: [0/1] {138} - ¦ ¦ ¦ °--SYMBOL: b [0/0] {137} - ¦ ¦ ¦--SPECIAL-PIPE: %>% [0/4] {139} - ¦ ¦ °--expr: [1/0] {141} - ¦ ¦ °--SYMBOL: c [0/0] {140} - ¦ °--')': ) [1/0] {142} - ¦--expr: [2/0] {143} - ¦ ¦--expr: [0/0] {145} - ¦ ¦ °--SYMBOL_FUNCTION_CALL: c [0/0] {144} - ¦ ¦--'(': ( [0/2] {146} + ¦ ¦ ¦--SPECIAL-PIPE: %>% [0/4] {122} + ¦ ¦ °--expr: [1/0] {124} + ¦ ¦ °--SYMBOL: c [0/0] {123} + ¦ °--')': ) [0/0] {125} + ¦--expr: [2/0] {126} + ¦ ¦--expr: [0/0] {128} + ¦ ¦ °--SYMBOL_FUNCTION_CALL: c [0/0] {127} + ¦ ¦--'(': ( [0/2] {129} + ¦ ¦--expr: [1/0] {130} + ¦ ¦ ¦--expr: [0/1] {132} + ¦ ¦ ¦ °--SYMBOL: a [0/0] {131} + ¦ ¦ ¦--'+': + [0/1] {133} + ¦ ¦ ¦--expr: [0/1] {136} + ¦ ¦ ¦ °--SYMBOL: b [0/0] {135} + ¦ ¦ ¦--SPECIAL-PIPE: %>% [0/1] {137} + ¦ ¦ ¦--COMMENT: # 654 [0/4] {138} + ¦ ¦ °--expr: [1/0] {140} + ¦ ¦ °--SYMBOL: c [0/0] {139} + ¦ °--')': ) [1/0] {141} + ¦--expr: [2/0] {142} + ¦ ¦--expr: [0/0] {144} + ¦ ¦ °--SYMBOL_FUNCTION_CALL: c [0/0] {143} + ¦ ¦--'(': ( [0/1] {145} + ¦ ¦--COMMENT: # rr [0/2] {146} ¦ ¦--expr: [1/0] {147} ¦ ¦ ¦--expr: [0/1] {149} ¦ ¦ ¦ °--SYMBOL: a [0/0] {148} - ¦ ¦ ¦--'+': + [0/4] {150} - ¦ ¦ ¦--expr: [1/1] {153} + ¦ ¦ ¦--'+': + [0/1] {150} + ¦ ¦ ¦--expr: [0/1] {153} ¦ ¦ ¦ °--SYMBOL: b [0/0] {152} - ¦ ¦ ¦--SPECIAL-PIPE: %>% [0/1] {154} - ¦ ¦ °--expr: [0/0] {156} + ¦ ¦ ¦--SPECIAL-PIPE: %>% [0/4] {154} + ¦ ¦ °--expr: [1/0] {156} ¦ ¦ °--SYMBOL: c [0/0] {155} ¦ °--')': ) [1/0] {157} ¦--expr: [2/0] {158} ¦ ¦--expr: [0/0] {160} ¦ ¦ °--SYMBOL_FUNCTION_CALL: c [0/0] {159} - ¦ ¦--'(': ( [0/0] {161} - ¦ ¦--expr: [0/0] {162} + ¦ ¦--'(': ( [0/2] {161} + ¦ ¦--expr: [1/0] {162} ¦ ¦ ¦--expr: [0/1] {164} ¦ ¦ ¦ °--SYMBOL: a [0/0] {163} ¦ ¦ ¦--'+': + [0/4] {165} @@ -165,32 +165,202 @@ ROOT (token: short_text [lag_newlines/spaces] {pos_id}) ¦ ¦ °--SYMBOL: c [0/0] {170} ¦ °--')': ) [1/0] {172} ¦--expr: [2/0] {173} - ¦ ¦--expr: [0/1] {175} - ¦ ¦ °--SYMBOL: a [0/0] {174} - ¦ ¦--SPECIAL-PIPE: %>% [0/1] {176} - ¦ °--expr: [0/0] {177} - ¦ ¦--expr: [0/0] {179} - ¦ ¦ °--SYMBOL_FUNCTION_CALL: b [0/0] {178} - ¦ ¦--'(': ( [0/0] {180} - ¦ °--')': ) [1/0] {181} - ¦--expr: [2/0] {182} - ¦ ¦--expr: [0/1] {184} - ¦ ¦ °--SYMBOL: a [0/0] {183} - ¦ ¦--SPECIAL-PIPE: %>% [0/2] {185} - ¦ °--expr: [1/0] {186} - ¦ ¦--expr: [0/0] {188} - ¦ ¦ °--SYMBOL_FUNCTION_CALL: b [0/0] {187} - ¦ ¦--'(': ( [0/0] {189} - ¦ °--')': ) [0/0] {190} - °--expr: [2/0] {191} - ¦--'{': { [0/0] {192} - ¦--expr: [0/0] {193} - ¦ ¦--expr: [0/1] {196} - ¦ ¦ °--SYMBOL: a [0/0] {195} - ¦ ¦--SPECIAL-PIPE: %>% [0/1] {197} - ¦ ¦--expr: [0/1] {199} - ¦ ¦ °--SYMBOL: c [0/0] {198} - ¦ ¦--'+': + [0/0] {200} - ¦ °--expr: [0/0] {202} - ¦ °--NUM_CONST: 1 [0/0] {201} - °--'}': } [0/0] {203} + ¦ ¦--expr: [0/0] {175} + ¦ ¦ °--SYMBOL_FUNCTION_CALL: c [0/0] {174} + ¦ ¦--'(': ( [0/0] {176} + ¦ ¦--expr: [0/0] {177} + ¦ ¦ ¦--expr: [0/1] {179} + ¦ ¦ ¦ °--SYMBOL: a [0/0] {178} + ¦ ¦ ¦--'+': + [0/4] {180} + ¦ ¦ ¦--expr: [1/1] {183} + ¦ ¦ ¦ °--SYMBOL: b [0/0] {182} + ¦ ¦ ¦--SPECIAL-PIPE: %>% [0/1] {184} + ¦ ¦ °--expr: [0/0] {186} + ¦ ¦ °--SYMBOL: c [0/0] {185} + ¦ °--')': ) [1/0] {187} + ¦--expr: [2/0] {188} + ¦ ¦--expr: [0/1] {190} + ¦ ¦ °--SYMBOL: a [0/0] {189} + ¦ ¦--SPECIAL-PIPE: %>% [0/1] {191} + ¦ °--expr: [0/0] {192} + ¦ ¦--expr: [0/0] {194} + ¦ ¦ °--SYMBOL_FUNCTION_CALL: b [0/0] {193} + ¦ ¦--'(': ( [0/0] {195} + ¦ °--')': ) [1/0] {196} + ¦--expr: [2/0] {197} + ¦ ¦--expr: [0/1] {199} + ¦ ¦ °--SYMBOL: a [0/0] {198} + ¦ ¦--SPECIAL-PIPE: %>% [0/2] {200} + ¦ °--expr: [1/0] {201} + ¦ ¦--expr: [0/0] {203} + ¦ ¦ °--SYMBOL_FUNCTION_CALL: b [0/0] {202} + ¦ ¦--'(': ( [0/0] {204} + ¦ °--')': ) [0/0] {205} + ¦--expr: [3/0] {206} + ¦ ¦--expr: [0/0] {208} + ¦ ¦ °--SYMBOL_FUNCTION_CALL: fun [0/0] {207} + ¦ ¦--'(': ( [0/0] {209} + ¦ ¦--expr: [0/0] {211} + ¦ ¦ °--SYMBOL: x [0/0] {210} + ¦ ¦--',': , [0/2] {212} + ¦ ¦--expr: [1/0] {213} + ¦ ¦ ¦--expr: [0/1] {215} + ¦ ¦ ¦ °--SYMBOL: a [0/0] {214} + ¦ ¦ ¦--SPECIAL-PIPE: %>% [0/1] {216} + ¦ ¦ °--expr: [0/0] {218} + ¦ ¦ °--SYMBOL: b [0/0] {217} + ¦ °--')': ) [0/0] {219} + ¦--expr: [2/0] {220} + ¦ ¦--expr: [0/0] {222} + ¦ ¦ °--SYMBOL_FUNCTION_CALL: fun [0/0] {221} + ¦ ¦--'(': ( [0/0] {223} + ¦ ¦--expr: [0/0] {225} + ¦ ¦ °--SYMBOL: x [0/0] {224} + ¦ ¦--',': , [0/4] {226} + ¦ ¦--SYMBOL_SUB: gg [1/1] {227} + ¦ ¦--EQ_SUB: = [0/1] {228} + ¦ ¦--expr: [0/0] {229} + ¦ ¦ ¦--expr: [0/1] {231} + ¦ ¦ ¦ °--SYMBOL: a [0/0] {230} + ¦ ¦ ¦--SPECIAL-PIPE: %>% [0/1] {232} + ¦ ¦ °--expr: [0/0] {234} + ¦ ¦ °--SYMBOL: b [0/0] {233} + ¦ ¦--',': , [0/4] {235} + ¦ ¦--expr: [1/0] {236} + ¦ ¦ ¦--expr: [0/1] {238} + ¦ ¦ ¦ °--SYMBOL: tt [0/0] {237} + ¦ ¦ ¦--SPECIAL-PIPE: %>% [0/1] {239} + ¦ ¦ °--expr: [0/0] {241} + ¦ ¦ °--SYMBOL: q [0/0] {240} + ¦ °--')': ) [0/0] {242} + ¦--expr: [2/0] {243} + ¦ ¦--expr: [0/0] {245} + ¦ ¦ °--SYMBOL_FUNCTION_CALL: fun [0/0] {244} + ¦ ¦--'(': ( [0/0] {246} + ¦ ¦--expr: [0/0] {248} + ¦ ¦ °--SYMBOL: x [0/0] {247} + ¦ ¦--',': , [0/1] {249} + ¦ ¦--SYMBOL_SUB: gg [0/1] {250} + ¦ ¦--EQ_SUB: = [0/1] {251} + ¦ ¦--expr: [0/0] {252} + ¦ ¦ ¦--expr: [0/1] {254} + ¦ ¦ ¦ °--SYMBOL: a [0/0] {253} + ¦ ¦ ¦--SPECIAL-PIPE: %>% [0/1] {255} + ¦ ¦ °--expr: [0/0] {257} + ¦ ¦ °--SYMBOL: b [0/0] {256} + ¦ ¦--',': , [0/1] {258} + ¦ ¦--expr: [0/0] {259} + ¦ ¦ ¦--expr: [0/1] {261} + ¦ ¦ ¦ °--SYMBOL: tt [0/0] {260} + ¦ ¦ ¦--SPECIAL-PIPE: %>% [0/1] {262} + ¦ ¦ °--expr: [0/0] {264} + ¦ ¦ °--SYMBOL: q [0/0] {263} + ¦ °--')': ) [0/0] {265} + ¦--equal_assign: [2/0] {266} + ¦ ¦--expr: [0/1] {268} + ¦ ¦ °--SYMBOL: z [0/0] {267} + ¦ ¦--EQ_ASSIGN: = [0/1] {269} + ¦ ¦--expr: [0/1] {272} + ¦ ¦ °--SYMBOL: a [0/0] {271} + ¦ ¦--SPECIAL-PIPE: %>% [0/1] {273} + ¦ °--expr: [0/0] {274} + ¦ ¦--expr: [0/0] {276} + ¦ ¦ °--SYMBOL_FUNCTION_CALL: b [0/0] {275} + ¦ ¦--'(': ( [0/0] {277} + ¦ °--')': ) [0/0] {278} + ¦--expr: [2/0] {279} + ¦ ¦--expr: [0/0] {281} + ¦ ¦ °--SYMBOL_FUNCTION_CALL: fun [0/0] {280} + ¦ ¦--'(': ( [0/1] {282} + ¦ ¦--SYMBOL_SUB: s [0/1] {283} + ¦ ¦--EQ_SUB: = [0/1] {284} + ¦ ¦--expr: [0/0] {285} + ¦ ¦ ¦--expr: [0/0] {287} + ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: g [0/0] {286} + ¦ ¦ ¦--'(': ( [0/0] {288} + ¦ ¦ ¦--expr: [0/0] {290} + ¦ ¦ ¦ °--SYMBOL: x [0/0] {289} + ¦ ¦ °--')': ) [0/0] {291} + ¦ ¦--',': , [0/4] {292} + ¦ ¦--SYMBOL_SUB: gg [1/1] {293} + ¦ ¦--EQ_SUB: = [0/1] {294} + ¦ ¦--expr: [0/0] {295} + ¦ ¦ ¦--expr: [0/1] {296} + ¦ ¦ ¦ ¦--expr: [0/0] {298} + ¦ ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: a [0/0] {297} + ¦ ¦ ¦ ¦--'(': ( [0/0] {299} + ¦ ¦ ¦ ¦--expr: [0/0] {300} + ¦ ¦ ¦ ¦ ¦--expr: [0/1] {302} + ¦ ¦ ¦ ¦ ¦ °--SYMBOL: n [0/0] {301} + ¦ ¦ ¦ ¦ ¦--EQ: == [0/1] {303} + ¦ ¦ ¦ ¦ °--expr: [0/0] {305} + ¦ ¦ ¦ ¦ °--NUM_CONST: 2 [0/0] {304} + ¦ ¦ ¦ °--')': ) [0/0] {306} + ¦ ¦ ¦--SPECIAL-PIPE: %>% [0/1] {307} + ¦ ¦ °--expr: [0/0] {309} + ¦ ¦ °--SYMBOL: b [0/0] {308} + ¦ ¦--',': , [0/4] {310} + ¦ ¦--expr: [1/0] {311} + ¦ ¦ ¦--expr: [0/1] {313} + ¦ ¦ ¦ °--SYMBOL: tt [0/0] {312} + ¦ ¦ ¦--SPECIAL-PIPE: %>% [0/1] {314} + ¦ ¦ °--expr: [0/0] {315} + ¦ ¦ ¦--expr: [0/0] {317} + ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: q [0/0] {316} + ¦ ¦ ¦--'(': ( [0/0] {318} + ¦ ¦ ¦--SYMBOL_SUB: r [0/1] {319} + ¦ ¦ ¦--EQ_SUB: = [0/1] {320} + ¦ ¦ ¦--expr: [0/0] {322} + ¦ ¦ ¦ °--NUM_CONST: 3 [0/0] {321} + ¦ ¦ °--')': ) [0/0] {323} + ¦ °--')': ) [0/0] {324} + ¦--expr: [2/0] {325} + ¦ ¦--expr: [0/0] {327} + ¦ ¦ °--SYMBOL_FUNCTION_CALL: blew [0/0] {326} + ¦ ¦--'(': ( [0/0] {328} + ¦ ¦--expr: [0/0] {329} + ¦ ¦ ¦--expr: [0/1] {331} + ¦ ¦ ¦ °--SYMBOL: x [0/0] {330} + ¦ ¦ ¦--SPECIAL-PIPE: %>% [0/7] {332} + ¦ ¦ °--expr: [1/0] {333} + ¦ ¦ ¦--expr: [0/0] {335} + ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: c [0/0] {334} + ¦ ¦ ¦--'(': ( [0/0] {336} + ¦ ¦ °--')': ) [0/0] {337} + ¦ ¦--',': , [0/1] {338} + ¦ ¦--SYMBOL_SUB: y [0/1] {339} + ¦ ¦--EQ_SUB: = [0/1] {340} + ¦ ¦--expr: [0/0] {342} + ¦ ¦ °--NUM_CONST: 2 [0/0] {341} + ¦ °--')': ) [0/0] {343} + ¦--expr: [2/0] {344} + ¦ ¦--expr: [0/0] {346} + ¦ ¦ °--SYMBOL_FUNCTION_CALL: blew [0/0] {345} + ¦ ¦--'(': ( [0/0] {347} + ¦ ¦--SYMBOL_SUB: y [0/1] {348} + ¦ ¦--EQ_SUB: = [0/1] {349} + ¦ ¦--expr: [0/0] {351} + ¦ ¦ °--NUM_CONST: 2 [0/0] {350} + ¦ ¦--',': , [0/1] {352} + ¦ ¦--expr: [0/0] {353} + ¦ ¦ ¦--expr: [0/1] {355} + ¦ ¦ ¦ °--SYMBOL: x [0/0] {354} + ¦ ¦ ¦--SPECIAL-PIPE: %>% [0/7] {356} + ¦ ¦ °--expr: [1/0] {357} + ¦ ¦ ¦--expr: [0/0] {359} + ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: c [0/0] {358} + ¦ ¦ ¦--'(': ( [0/0] {360} + ¦ ¦ °--')': ) [0/0] {361} + ¦ °--')': ) [0/0] {362} + °--expr: [3/0] {363} + ¦--'{': { [0/0] {364} + ¦--expr: [0/0] {365} + ¦ ¦--expr: [0/1] {368} + ¦ ¦ °--SYMBOL: a [0/0] {367} + ¦ ¦--SPECIAL-PIPE: %>% [0/1] {369} + ¦ ¦--expr: [0/1] {371} + ¦ ¦ °--SYMBOL: c [0/0] {370} + ¦ ¦--'+': + [0/0] {372} + ¦ °--expr: [0/0] {374} + ¦ °--NUM_CONST: 1 [0/0] {373} + °--'}': } [0/0] {375} diff --git a/tests/testthat/line_breaks_and_other/pipe-line-breaks-out.R b/tests/testthat/line_breaks_and_other/pipe-line-breaks-out.R index c0df31572..3a27322b2 100644 --- a/tests/testthat/line_breaks_and_other/pipe-line-breaks-out.R +++ b/tests/testthat/line_breaks_and_other/pipe-line-breaks-out.R @@ -23,6 +23,9 @@ c( c() ) +c(a + b %>% + c()) + c( a + b %>% # 654 c() @@ -47,6 +50,35 @@ a %>% a %>% b() + +fun( + x, + a %>% b() +) + +fun(x, + gg = a %>% b(), + tt %>% q() +) + +fun(x, gg = a %>% b(), tt %>% q()) + +z <- a %>% + b() + +fun( + s = g(x), + gg = a(n == 2) %>% b(), + tt %>% q(r = 3) +) + +blew(x %>% + c(), y = 2) + +blew(y = 2, x %>% + c()) + + { a %>% c() + 1 diff --git a/tests/testthat/token_adding_removing/add_brackets_in_pipe-out.R b/tests/testthat/token_adding_removing/add_brackets_in_pipe-out.R index 3bb029b9f..323581851 100644 --- a/tests/testthat/token_adding_removing/add_brackets_in_pipe-out.R +++ b/tests/testthat/token_adding_removing/add_brackets_in_pipe-out.R @@ -1,5 +1,7 @@ -1 %>% 2 +1 %>% + 2 1 %x% 1 1 %x% y -1 %>% x() +1 %>% + x() 1 %s% 1 diff --git a/tests/testthat/token_adding_removing/mixed_token-in.R b/tests/testthat/token_adding_removing/mixed_token-in.R index 2d5c539e9..c984b805e 100644 --- a/tests/testthat/token_adding_removing/mixed_token-in.R +++ b/tests/testthat/token_adding_removing/mixed_token-in.R @@ -11,12 +11,6 @@ a; b ;c;d 'text with "quotes"' -# no linebreak after special if they fit in a line -a %>% b() %>%c() - -# linebreak after special -a %>% - b() %>%c() # adding brackets in pipes a %>% diff --git a/tests/testthat/token_adding_removing/mixed_token-in_tree b/tests/testthat/token_adding_removing/mixed_token-in_tree index ab05ca364..c83031c3d 100644 --- a/tests/testthat/token_adding_removing/mixed_token-in_tree +++ b/tests/testthat/token_adding_removing/mixed_token-in_tree @@ -32,55 +32,23 @@ ROOT (token: short_text [lag_newlines/spaces] {pos_id}) ¦ °--STR_CONST: "text [0/0] {30} ¦--expr: [1/0] {33} ¦ °--STR_CONST: 'text [0/0] {32} - ¦--COMMENT: # no [3/0] {34} + ¦--COMMENT: # add [4/0] {34} ¦--expr: [1/0] {35} ¦ ¦--expr: [0/1] {38} ¦ ¦ °--SYMBOL: a [0/0] {37} - ¦ ¦--SPECIAL-PIPE: %>% [0/1] {39} - ¦ ¦--expr: [0/1] {40} - ¦ ¦ ¦--expr: [0/0] {42} - ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: b [0/0] {41} - ¦ ¦ ¦--'(': ( [0/0] {43} - ¦ ¦ °--')': ) [0/0] {44} - ¦ ¦--SPECIAL-PIPE: %>% [0/0] {45} - ¦ °--expr: [0/0] {46} - ¦ ¦--expr: [0/0] {48} - ¦ ¦ °--SYMBOL_FUNCTION_CALL: c [0/0] {47} - ¦ ¦--'(': ( [0/0] {49} - ¦ °--')': ) [0/0] {50} - ¦--COMMENT: # lin [2/0] {51} - ¦--expr: [1/0] {52} - ¦ ¦--expr: [0/1] {55} - ¦ ¦ °--SYMBOL: a [0/0] {54} - ¦ ¦--SPECIAL-PIPE: %>% [0/2] {56} - ¦ ¦--expr: [1/1] {57} - ¦ ¦ ¦--expr: [0/0] {59} - ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: b [0/0] {58} - ¦ ¦ ¦--'(': ( [0/0] {60} - ¦ ¦ °--')': ) [0/0] {61} - ¦ ¦--SPECIAL-PIPE: %>% [0/0] {62} - ¦ °--expr: [0/0] {63} - ¦ ¦--expr: [0/0] {65} - ¦ ¦ °--SYMBOL_FUNCTION_CALL: c [0/0] {64} - ¦ ¦--'(': ( [0/0] {66} - ¦ °--')': ) [0/0] {67} - ¦--COMMENT: # add [2/0] {68} - ¦--expr: [1/0] {69} - ¦ ¦--expr: [0/1] {72} - ¦ ¦ °--SYMBOL: a [0/0] {71} - ¦ ¦--SPECIAL-PIPE: %>% [0/2] {73} - ¦ ¦--expr: [1/1] {75} - ¦ ¦ °--SYMBOL: b [0/0] {74} - ¦ ¦--SPECIAL-PIPE: %>% [0/2] {76} - ¦ °--expr: [1/0] {78} - ¦ °--SYMBOL: c [0/0] {77} - ¦--COMMENT: # add [2/0] {79} - °--expr: [1/0] {80} - ¦--expr: [0/1] {83} - ¦ °--SYMBOL: a [0/0] {82} - ¦--SPECIAL-PIPE: %>% [0/1] {84} - ¦--expr: [0/1] {86} - ¦ °--SYMBOL: b [0/0] {85} - ¦--SPECIAL-PIPE: %>% [0/2] {87} - °--expr: [1/0] {89} - °--SYMBOL: c [0/0] {88} + ¦ ¦--SPECIAL-PIPE: %>% [0/2] {39} + ¦ ¦--expr: [1/1] {41} + ¦ ¦ °--SYMBOL: b [0/0] {40} + ¦ ¦--SPECIAL-PIPE: %>% [0/2] {42} + ¦ °--expr: [1/0] {44} + ¦ °--SYMBOL: c [0/0] {43} + ¦--COMMENT: # add [2/0] {45} + °--expr: [1/0] {46} + ¦--expr: [0/1] {49} + ¦ °--SYMBOL: a [0/0] {48} + ¦--SPECIAL-PIPE: %>% [0/1] {50} + ¦--expr: [0/1] {52} + ¦ °--SYMBOL: b [0/0] {51} + ¦--SPECIAL-PIPE: %>% [0/2] {53} + °--expr: [1/0] {55} + °--SYMBOL: c [0/0] {54} diff --git a/tests/testthat/token_adding_removing/mixed_token-out.R b/tests/testthat/token_adding_removing/mixed_token-out.R index 3c003f944..e80aafb4d 100644 --- a/tests/testthat/token_adding_removing/mixed_token-out.R +++ b/tests/testthat/token_adding_removing/mixed_token-out.R @@ -14,13 +14,6 @@ d 'text with "quotes"' -# no linebreak after special if they fit in a line -a %>% b() %>% c() - -# linebreak after special -a %>% - b() %>% - c() # adding brackets in pipes a %>% From 69e43d9b41b36d0d8589d881bdaaf10775bd5044 Mon Sep 17 00:00:00 2001 From: lorenzwalthert Date: Fri, 3 May 2019 00:03:36 +0200 Subject: [PATCH 26/48] don't break short pipes with less than 2 %>% --- R/rules-line-break.R | 6 +- .../pipe-line-breaks-in.R | 10 + .../pipe-line-breaks-in_tree | 380 ++++++++++-------- .../pipe-line-breaks-out.R | 20 +- 4 files changed, 236 insertions(+), 180 deletions(-) diff --git a/R/rules-line-break.R b/R/rules-line-break.R index 6b01f3f2e..65b62eaf4 100644 --- a/R/rules-line-break.R +++ b/R/rules-line-break.R @@ -48,10 +48,10 @@ remove_line_break_before_round_closing_fun_dec <- function(pd) { #' @importFrom rlang seq2 add_line_break_after_pipe <- function(pd) { - is_special <- pd$token == c("SPECIAL-PIPE") & pd$token_after != "COMMENT" - if (any(is_special) && + is_pipe <- pd$token == c("SPECIAL-PIPE") & pd$token_after != "COMMENT" + if (sum(is_pipe) > 1 && !(next_terminal(pd, vars = "token_before")$token_before %in% c("'('", "EQ_SUB", "','"))) { - pd$lag_newlines[lag(is_special)] <- 1L + pd$lag_newlines[lag(is_pipe)] <- 1L } pd } diff --git a/tests/testthat/line_breaks_and_other/pipe-line-breaks-in.R b/tests/testthat/line_breaks_and_other/pipe-line-breaks-in.R index f97cfaf65..843cb157c 100644 --- a/tests/testthat/line_breaks_and_other/pipe-line-breaks-in.R +++ b/tests/testthat/line_breaks_and_other/pipe-line-breaks-in.R @@ -46,9 +46,16 @@ c(a + a %>% b( ) +a %>% b( +) %>% q + a %>% b() +a %>% b() %>% c + +# short pipes < 2 can stay on one line +a %>% b() fun(x, a %>% b) @@ -65,9 +72,12 @@ fun( s = g(x), gg = a(n == 2) %>% b, tt %>% q(r = 3)) +# FIXME closing brace could go on ntext line. Alternative: remove lin breaks completely. blew(x %>% + c(), y = 2) +# FIXME closing brace could go on ntext line. Alternative: move c() up. blew(y = 2, x %>% c()) diff --git a/tests/testthat/line_breaks_and_other/pipe-line-breaks-in_tree b/tests/testthat/line_breaks_and_other/pipe-line-breaks-in_tree index ea3f6478e..68f647175 100644 --- a/tests/testthat/line_breaks_and_other/pipe-line-breaks-in_tree +++ b/tests/testthat/line_breaks_and_other/pipe-line-breaks-in_tree @@ -188,179 +188,215 @@ ROOT (token: short_text [lag_newlines/spaces] {pos_id}) ¦ ¦--'(': ( [0/0] {195} ¦ °--')': ) [1/0] {196} ¦--expr: [2/0] {197} - ¦ ¦--expr: [0/1] {199} - ¦ ¦ °--SYMBOL: a [0/0] {198} - ¦ ¦--SPECIAL-PIPE: %>% [0/2] {200} - ¦ °--expr: [1/0] {201} - ¦ ¦--expr: [0/0] {203} - ¦ ¦ °--SYMBOL_FUNCTION_CALL: b [0/0] {202} - ¦ ¦--'(': ( [0/0] {204} - ¦ °--')': ) [0/0] {205} - ¦--expr: [3/0] {206} - ¦ ¦--expr: [0/0] {208} - ¦ ¦ °--SYMBOL_FUNCTION_CALL: fun [0/0] {207} - ¦ ¦--'(': ( [0/0] {209} - ¦ ¦--expr: [0/0] {211} - ¦ ¦ °--SYMBOL: x [0/0] {210} - ¦ ¦--',': , [0/2] {212} - ¦ ¦--expr: [1/0] {213} - ¦ ¦ ¦--expr: [0/1] {215} - ¦ ¦ ¦ °--SYMBOL: a [0/0] {214} - ¦ ¦ ¦--SPECIAL-PIPE: %>% [0/1] {216} - ¦ ¦ °--expr: [0/0] {218} - ¦ ¦ °--SYMBOL: b [0/0] {217} - ¦ °--')': ) [0/0] {219} - ¦--expr: [2/0] {220} - ¦ ¦--expr: [0/0] {222} - ¦ ¦ °--SYMBOL_FUNCTION_CALL: fun [0/0] {221} - ¦ ¦--'(': ( [0/0] {223} - ¦ ¦--expr: [0/0] {225} - ¦ ¦ °--SYMBOL: x [0/0] {224} - ¦ ¦--',': , [0/4] {226} - ¦ ¦--SYMBOL_SUB: gg [1/1] {227} - ¦ ¦--EQ_SUB: = [0/1] {228} - ¦ ¦--expr: [0/0] {229} - ¦ ¦ ¦--expr: [0/1] {231} - ¦ ¦ ¦ °--SYMBOL: a [0/0] {230} - ¦ ¦ ¦--SPECIAL-PIPE: %>% [0/1] {232} - ¦ ¦ °--expr: [0/0] {234} - ¦ ¦ °--SYMBOL: b [0/0] {233} - ¦ ¦--',': , [0/4] {235} - ¦ ¦--expr: [1/0] {236} - ¦ ¦ ¦--expr: [0/1] {238} - ¦ ¦ ¦ °--SYMBOL: tt [0/0] {237} - ¦ ¦ ¦--SPECIAL-PIPE: %>% [0/1] {239} - ¦ ¦ °--expr: [0/0] {241} - ¦ ¦ °--SYMBOL: q [0/0] {240} - ¦ °--')': ) [0/0] {242} - ¦--expr: [2/0] {243} - ¦ ¦--expr: [0/0] {245} - ¦ ¦ °--SYMBOL_FUNCTION_CALL: fun [0/0] {244} - ¦ ¦--'(': ( [0/0] {246} - ¦ ¦--expr: [0/0] {248} - ¦ ¦ °--SYMBOL: x [0/0] {247} - ¦ ¦--',': , [0/1] {249} - ¦ ¦--SYMBOL_SUB: gg [0/1] {250} - ¦ ¦--EQ_SUB: = [0/1] {251} - ¦ ¦--expr: [0/0] {252} - ¦ ¦ ¦--expr: [0/1] {254} - ¦ ¦ ¦ °--SYMBOL: a [0/0] {253} - ¦ ¦ ¦--SPECIAL-PIPE: %>% [0/1] {255} - ¦ ¦ °--expr: [0/0] {257} - ¦ ¦ °--SYMBOL: b [0/0] {256} - ¦ ¦--',': , [0/1] {258} - ¦ ¦--expr: [0/0] {259} - ¦ ¦ ¦--expr: [0/1] {261} - ¦ ¦ ¦ °--SYMBOL: tt [0/0] {260} - ¦ ¦ ¦--SPECIAL-PIPE: %>% [0/1] {262} - ¦ ¦ °--expr: [0/0] {264} - ¦ ¦ °--SYMBOL: q [0/0] {263} - ¦ °--')': ) [0/0] {265} - ¦--equal_assign: [2/0] {266} - ¦ ¦--expr: [0/1] {268} - ¦ ¦ °--SYMBOL: z [0/0] {267} - ¦ ¦--EQ_ASSIGN: = [0/1] {269} - ¦ ¦--expr: [0/1] {272} - ¦ ¦ °--SYMBOL: a [0/0] {271} - ¦ ¦--SPECIAL-PIPE: %>% [0/1] {273} - ¦ °--expr: [0/0] {274} - ¦ ¦--expr: [0/0] {276} - ¦ ¦ °--SYMBOL_FUNCTION_CALL: b [0/0] {275} - ¦ ¦--'(': ( [0/0] {277} - ¦ °--')': ) [0/0] {278} + ¦ ¦--expr: [0/1] {200} + ¦ ¦ °--SYMBOL: a [0/0] {199} + ¦ ¦--SPECIAL-PIPE: %>% [0/1] {201} + ¦ ¦--expr: [0/1] {202} + ¦ ¦ ¦--expr: [0/0] {204} + ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: b [0/0] {203} + ¦ ¦ ¦--'(': ( [0/0] {205} + ¦ ¦ °--')': ) [1/0] {206} + ¦ ¦--SPECIAL-PIPE: %>% [0/1] {207} + ¦ °--expr: [0/0] {209} + ¦ °--SYMBOL: q [0/0] {208} + ¦--expr: [2/0] {210} + ¦ ¦--expr: [0/1] {212} + ¦ ¦ °--SYMBOL: a [0/0] {211} + ¦ ¦--SPECIAL-PIPE: %>% [0/2] {213} + ¦ °--expr: [1/0] {214} + ¦ ¦--expr: [0/0] {216} + ¦ ¦ °--SYMBOL_FUNCTION_CALL: b [0/0] {215} + ¦ ¦--'(': ( [0/0] {217} + ¦ °--')': ) [0/0] {218} + ¦--expr: [2/0] {219} + ¦ ¦--expr: [0/1] {222} + ¦ ¦ °--SYMBOL: a [0/0] {221} + ¦ ¦--SPECIAL-PIPE: %>% [0/1] {223} + ¦ ¦--expr: [0/1] {224} + ¦ ¦ ¦--expr: [0/0] {226} + ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: b [0/0] {225} + ¦ ¦ ¦--'(': ( [0/0] {227} + ¦ ¦ °--')': ) [0/0] {228} + ¦ ¦--SPECIAL-PIPE: %>% [0/1] {229} + ¦ °--expr: [0/0] {231} + ¦ °--SYMBOL: c [0/0] {230} + ¦--COMMENT: # sho [2/0] {232} + ¦--expr: [1/0] {233} + ¦ ¦--expr: [0/1] {235} + ¦ ¦ °--SYMBOL: a [0/0] {234} + ¦ ¦--SPECIAL-PIPE: %>% [0/1] {236} + ¦ °--expr: [0/0] {237} + ¦ ¦--expr: [0/0] {239} + ¦ ¦ °--SYMBOL_FUNCTION_CALL: b [0/0] {238} + ¦ ¦--'(': ( [0/0] {240} + ¦ °--')': ) [0/0] {241} + ¦--expr: [2/0] {242} + ¦ ¦--expr: [0/0] {244} + ¦ ¦ °--SYMBOL_FUNCTION_CALL: fun [0/0] {243} + ¦ ¦--'(': ( [0/0] {245} + ¦ ¦--expr: [0/0] {247} + ¦ ¦ °--SYMBOL: x [0/0] {246} + ¦ ¦--',': , [0/2] {248} + ¦ ¦--expr: [1/0] {249} + ¦ ¦ ¦--expr: [0/1] {251} + ¦ ¦ ¦ °--SYMBOL: a [0/0] {250} + ¦ ¦ ¦--SPECIAL-PIPE: %>% [0/1] {252} + ¦ ¦ °--expr: [0/0] {254} + ¦ ¦ °--SYMBOL: b [0/0] {253} + ¦ °--')': ) [0/0] {255} + ¦--expr: [2/0] {256} + ¦ ¦--expr: [0/0] {258} + ¦ ¦ °--SYMBOL_FUNCTION_CALL: fun [0/0] {257} + ¦ ¦--'(': ( [0/0] {259} + ¦ ¦--expr: [0/0] {261} + ¦ ¦ °--SYMBOL: x [0/0] {260} + ¦ ¦--',': , [0/4] {262} + ¦ ¦--SYMBOL_SUB: gg [1/1] {263} + ¦ ¦--EQ_SUB: = [0/1] {264} + ¦ ¦--expr: [0/0] {265} + ¦ ¦ ¦--expr: [0/1] {267} + ¦ ¦ ¦ °--SYMBOL: a [0/0] {266} + ¦ ¦ ¦--SPECIAL-PIPE: %>% [0/1] {268} + ¦ ¦ °--expr: [0/0] {270} + ¦ ¦ °--SYMBOL: b [0/0] {269} + ¦ ¦--',': , [0/4] {271} + ¦ ¦--expr: [1/0] {272} + ¦ ¦ ¦--expr: [0/1] {274} + ¦ ¦ ¦ °--SYMBOL: tt [0/0] {273} + ¦ ¦ ¦--SPECIAL-PIPE: %>% [0/1] {275} + ¦ ¦ °--expr: [0/0] {277} + ¦ ¦ °--SYMBOL: q [0/0] {276} + ¦ °--')': ) [0/0] {278} ¦--expr: [2/0] {279} ¦ ¦--expr: [0/0] {281} ¦ ¦ °--SYMBOL_FUNCTION_CALL: fun [0/0] {280} - ¦ ¦--'(': ( [0/1] {282} - ¦ ¦--SYMBOL_SUB: s [0/1] {283} - ¦ ¦--EQ_SUB: = [0/1] {284} - ¦ ¦--expr: [0/0] {285} - ¦ ¦ ¦--expr: [0/0] {287} - ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: g [0/0] {286} - ¦ ¦ ¦--'(': ( [0/0] {288} - ¦ ¦ ¦--expr: [0/0] {290} - ¦ ¦ ¦ °--SYMBOL: x [0/0] {289} - ¦ ¦ °--')': ) [0/0] {291} - ¦ ¦--',': , [0/4] {292} - ¦ ¦--SYMBOL_SUB: gg [1/1] {293} - ¦ ¦--EQ_SUB: = [0/1] {294} + ¦ ¦--'(': ( [0/0] {282} + ¦ ¦--expr: [0/0] {284} + ¦ ¦ °--SYMBOL: x [0/0] {283} + ¦ ¦--',': , [0/1] {285} + ¦ ¦--SYMBOL_SUB: gg [0/1] {286} + ¦ ¦--EQ_SUB: = [0/1] {287} + ¦ ¦--expr: [0/0] {288} + ¦ ¦ ¦--expr: [0/1] {290} + ¦ ¦ ¦ °--SYMBOL: a [0/0] {289} + ¦ ¦ ¦--SPECIAL-PIPE: %>% [0/1] {291} + ¦ ¦ °--expr: [0/0] {293} + ¦ ¦ °--SYMBOL: b [0/0] {292} + ¦ ¦--',': , [0/1] {294} ¦ ¦--expr: [0/0] {295} - ¦ ¦ ¦--expr: [0/1] {296} - ¦ ¦ ¦ ¦--expr: [0/0] {298} - ¦ ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: a [0/0] {297} - ¦ ¦ ¦ ¦--'(': ( [0/0] {299} - ¦ ¦ ¦ ¦--expr: [0/0] {300} - ¦ ¦ ¦ ¦ ¦--expr: [0/1] {302} - ¦ ¦ ¦ ¦ ¦ °--SYMBOL: n [0/0] {301} - ¦ ¦ ¦ ¦ ¦--EQ: == [0/1] {303} - ¦ ¦ ¦ ¦ °--expr: [0/0] {305} - ¦ ¦ ¦ ¦ °--NUM_CONST: 2 [0/0] {304} - ¦ ¦ ¦ °--')': ) [0/0] {306} - ¦ ¦ ¦--SPECIAL-PIPE: %>% [0/1] {307} - ¦ ¦ °--expr: [0/0] {309} - ¦ ¦ °--SYMBOL: b [0/0] {308} - ¦ ¦--',': , [0/4] {310} - ¦ ¦--expr: [1/0] {311} - ¦ ¦ ¦--expr: [0/1] {313} - ¦ ¦ ¦ °--SYMBOL: tt [0/0] {312} - ¦ ¦ ¦--SPECIAL-PIPE: %>% [0/1] {314} - ¦ ¦ °--expr: [0/0] {315} - ¦ ¦ ¦--expr: [0/0] {317} - ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: q [0/0] {316} - ¦ ¦ ¦--'(': ( [0/0] {318} - ¦ ¦ ¦--SYMBOL_SUB: r [0/1] {319} - ¦ ¦ ¦--EQ_SUB: = [0/1] {320} - ¦ ¦ ¦--expr: [0/0] {322} - ¦ ¦ ¦ °--NUM_CONST: 3 [0/0] {321} - ¦ ¦ °--')': ) [0/0] {323} - ¦ °--')': ) [0/0] {324} - ¦--expr: [2/0] {325} - ¦ ¦--expr: [0/0] {327} - ¦ ¦ °--SYMBOL_FUNCTION_CALL: blew [0/0] {326} - ¦ ¦--'(': ( [0/0] {328} - ¦ ¦--expr: [0/0] {329} - ¦ ¦ ¦--expr: [0/1] {331} - ¦ ¦ ¦ °--SYMBOL: x [0/0] {330} - ¦ ¦ ¦--SPECIAL-PIPE: %>% [0/7] {332} - ¦ ¦ °--expr: [1/0] {333} - ¦ ¦ ¦--expr: [0/0] {335} - ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: c [0/0] {334} - ¦ ¦ ¦--'(': ( [0/0] {336} - ¦ ¦ °--')': ) [0/0] {337} - ¦ ¦--',': , [0/1] {338} - ¦ ¦--SYMBOL_SUB: y [0/1] {339} - ¦ ¦--EQ_SUB: = [0/1] {340} - ¦ ¦--expr: [0/0] {342} - ¦ ¦ °--NUM_CONST: 2 [0/0] {341} - ¦ °--')': ) [0/0] {343} - ¦--expr: [2/0] {344} - ¦ ¦--expr: [0/0] {346} - ¦ ¦ °--SYMBOL_FUNCTION_CALL: blew [0/0] {345} - ¦ ¦--'(': ( [0/0] {347} - ¦ ¦--SYMBOL_SUB: y [0/1] {348} - ¦ ¦--EQ_SUB: = [0/1] {349} - ¦ ¦--expr: [0/0] {351} - ¦ ¦ °--NUM_CONST: 2 [0/0] {350} - ¦ ¦--',': , [0/1] {352} - ¦ ¦--expr: [0/0] {353} - ¦ ¦ ¦--expr: [0/1] {355} - ¦ ¦ ¦ °--SYMBOL: x [0/0] {354} - ¦ ¦ ¦--SPECIAL-PIPE: %>% [0/7] {356} - ¦ ¦ °--expr: [1/0] {357} - ¦ ¦ ¦--expr: [0/0] {359} - ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: c [0/0] {358} - ¦ ¦ ¦--'(': ( [0/0] {360} - ¦ ¦ °--')': ) [0/0] {361} - ¦ °--')': ) [0/0] {362} - °--expr: [3/0] {363} - ¦--'{': { [0/0] {364} - ¦--expr: [0/0] {365} - ¦ ¦--expr: [0/1] {368} - ¦ ¦ °--SYMBOL: a [0/0] {367} - ¦ ¦--SPECIAL-PIPE: %>% [0/1] {369} - ¦ ¦--expr: [0/1] {371} - ¦ ¦ °--SYMBOL: c [0/0] {370} - ¦ ¦--'+': + [0/0] {372} - ¦ °--expr: [0/0] {374} - ¦ °--NUM_CONST: 1 [0/0] {373} - °--'}': } [0/0] {375} + ¦ ¦ ¦--expr: [0/1] {297} + ¦ ¦ ¦ °--SYMBOL: tt [0/0] {296} + ¦ ¦ ¦--SPECIAL-PIPE: %>% [0/1] {298} + ¦ ¦ °--expr: [0/0] {300} + ¦ ¦ °--SYMBOL: q [0/0] {299} + ¦ °--')': ) [0/0] {301} + ¦--equal_assign: [2/0] {302} + ¦ ¦--expr: [0/1] {304} + ¦ ¦ °--SYMBOL: z [0/0] {303} + ¦ ¦--EQ_ASSIGN: = [0/1] {305} + ¦ ¦--expr: [0/1] {308} + ¦ ¦ °--SYMBOL: a [0/0] {307} + ¦ ¦--SPECIAL-PIPE: %>% [0/1] {309} + ¦ °--expr: [0/0] {310} + ¦ ¦--expr: [0/0] {312} + ¦ ¦ °--SYMBOL_FUNCTION_CALL: b [0/0] {311} + ¦ ¦--'(': ( [0/0] {313} + ¦ °--')': ) [0/0] {314} + ¦--expr: [2/0] {315} + ¦ ¦--expr: [0/0] {317} + ¦ ¦ °--SYMBOL_FUNCTION_CALL: fun [0/0] {316} + ¦ ¦--'(': ( [0/1] {318} + ¦ ¦--SYMBOL_SUB: s [0/1] {319} + ¦ ¦--EQ_SUB: = [0/1] {320} + ¦ ¦--expr: [0/0] {321} + ¦ ¦ ¦--expr: [0/0] {323} + ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: g [0/0] {322} + ¦ ¦ ¦--'(': ( [0/0] {324} + ¦ ¦ ¦--expr: [0/0] {326} + ¦ ¦ ¦ °--SYMBOL: x [0/0] {325} + ¦ ¦ °--')': ) [0/0] {327} + ¦ ¦--',': , [0/4] {328} + ¦ ¦--SYMBOL_SUB: gg [1/1] {329} + ¦ ¦--EQ_SUB: = [0/1] {330} + ¦ ¦--expr: [0/0] {331} + ¦ ¦ ¦--expr: [0/1] {332} + ¦ ¦ ¦ ¦--expr: [0/0] {334} + ¦ ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: a [0/0] {333} + ¦ ¦ ¦ ¦--'(': ( [0/0] {335} + ¦ ¦ ¦ ¦--expr: [0/0] {336} + ¦ ¦ ¦ ¦ ¦--expr: [0/1] {338} + ¦ ¦ ¦ ¦ ¦ °--SYMBOL: n [0/0] {337} + ¦ ¦ ¦ ¦ ¦--EQ: == [0/1] {339} + ¦ ¦ ¦ ¦ °--expr: [0/0] {341} + ¦ ¦ ¦ ¦ °--NUM_CONST: 2 [0/0] {340} + ¦ ¦ ¦ °--')': ) [0/0] {342} + ¦ ¦ ¦--SPECIAL-PIPE: %>% [0/1] {343} + ¦ ¦ °--expr: [0/0] {345} + ¦ ¦ °--SYMBOL: b [0/0] {344} + ¦ ¦--',': , [0/4] {346} + ¦ ¦--expr: [1/0] {347} + ¦ ¦ ¦--expr: [0/1] {349} + ¦ ¦ ¦ °--SYMBOL: tt [0/0] {348} + ¦ ¦ ¦--SPECIAL-PIPE: %>% [0/1] {350} + ¦ ¦ °--expr: [0/0] {351} + ¦ ¦ ¦--expr: [0/0] {353} + ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: q [0/0] {352} + ¦ ¦ ¦--'(': ( [0/0] {354} + ¦ ¦ ¦--SYMBOL_SUB: r [0/1] {355} + ¦ ¦ ¦--EQ_SUB: = [0/1] {356} + ¦ ¦ ¦--expr: [0/0] {358} + ¦ ¦ ¦ °--NUM_CONST: 3 [0/0] {357} + ¦ ¦ °--')': ) [0/0] {359} + ¦ °--')': ) [0/0] {360} + ¦--COMMENT: # FIX [2/0] {361} + ¦--expr: [1/0] {362} + ¦ ¦--expr: [0/0] {364} + ¦ ¦ °--SYMBOL_FUNCTION_CALL: blew [0/0] {363} + ¦ ¦--'(': ( [0/0] {365} + ¦ ¦--expr: [0/0] {366} + ¦ ¦ ¦--expr: [0/1] {368} + ¦ ¦ ¦ °--SYMBOL: x [0/0] {367} + ¦ ¦ ¦--SPECIAL-PIPE: %>% [0/7] {369} + ¦ ¦ °--expr: [2/0] {370} + ¦ ¦ ¦--expr: [0/0] {372} + ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: c [0/0] {371} + ¦ ¦ ¦--'(': ( [0/0] {373} + ¦ ¦ °--')': ) [0/0] {374} + ¦ ¦--',': , [0/1] {375} + ¦ ¦--SYMBOL_SUB: y [0/1] {376} + ¦ ¦--EQ_SUB: = [0/1] {377} + ¦ ¦--expr: [0/0] {379} + ¦ ¦ °--NUM_CONST: 2 [0/0] {378} + ¦ °--')': ) [0/0] {380} + ¦--COMMENT: # FIX [2/0] {381} + ¦--expr: [1/0] {382} + ¦ ¦--expr: [0/0] {384} + ¦ ¦ °--SYMBOL_FUNCTION_CALL: blew [0/0] {383} + ¦ ¦--'(': ( [0/0] {385} + ¦ ¦--SYMBOL_SUB: y [0/1] {386} + ¦ ¦--EQ_SUB: = [0/1] {387} + ¦ ¦--expr: [0/0] {389} + ¦ ¦ °--NUM_CONST: 2 [0/0] {388} + ¦ ¦--',': , [0/1] {390} + ¦ ¦--expr: [0/0] {391} + ¦ ¦ ¦--expr: [0/1] {393} + ¦ ¦ ¦ °--SYMBOL: x [0/0] {392} + ¦ ¦ ¦--SPECIAL-PIPE: %>% [0/7] {394} + ¦ ¦ °--expr: [1/0] {395} + ¦ ¦ ¦--expr: [0/0] {397} + ¦ ¦ ¦ °--SYMBOL_FUNCTION_CALL: c [0/0] {396} + ¦ ¦ ¦--'(': ( [0/0] {398} + ¦ ¦ °--')': ) [0/0] {399} + ¦ °--')': ) [0/0] {400} + °--expr: [3/0] {401} + ¦--'{': { [0/0] {402} + ¦--expr: [0/0] {403} + ¦ ¦--expr: [0/1] {406} + ¦ ¦ °--SYMBOL: a [0/0] {405} + ¦ ¦--SPECIAL-PIPE: %>% [0/1] {407} + ¦ ¦--expr: [0/1] {409} + ¦ ¦ °--SYMBOL: c [0/0] {408} + ¦ ¦--'+': + [0/0] {410} + ¦ °--expr: [0/0] {412} + ¦ °--NUM_CONST: 1 [0/0] {411} + °--'}': } [0/0] {413} diff --git a/tests/testthat/line_breaks_and_other/pipe-line-breaks-out.R b/tests/testthat/line_breaks_and_other/pipe-line-breaks-out.R index 3a27322b2..d16d6fe56 100644 --- a/tests/testthat/line_breaks_and_other/pipe-line-breaks-out.R +++ b/tests/testthat/line_breaks_and_other/pipe-line-breaks-out.R @@ -44,12 +44,21 @@ c( c(a + b %>% c()) +a %>% b() + a %>% - b() + b() %>% + q() a %>% b() +a %>% + b() %>% + c() + +# short pipes < 2 can stay on one line +a %>% b() fun( x, @@ -63,8 +72,7 @@ fun(x, fun(x, gg = a %>% b(), tt %>% q()) -z <- a %>% - b() +z <- a %>% b() fun( s = g(x), @@ -72,14 +80,16 @@ fun( tt %>% q(r = 3) ) +# FIXME closing brace could go on ntext line. Alternative: remove lin breaks completely. blew(x %>% + c(), y = 2) +# FIXME closing brace could go on ntext line. Alternative: move c() up. blew(y = 2, x %>% c()) { - a %>% - c() + 1 + a %>% c() + 1 } From 2ffd9e1b18f6d1d9a58943840dbc802de6995734 Mon Sep 17 00:00:00 2001 From: lorenzwalthert Date: Fri, 3 May 2019 00:12:30 +0200 Subject: [PATCH 27/48] limit rule application to strict = TRUE --- R/style-guides.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/style-guides.R b/R/style-guides.R index 89980ff83..598c67bec 100644 --- a/R/style-guides.R +++ b/R/style-guides.R @@ -141,7 +141,7 @@ tidyverse_style <- function(scope = "tokens", ) }, remove_line_break_in_empty_fun_call, - add_line_break_after_pipe + add_line_break_after_pipe = if (strict) add_line_break_after_pipe ) } From f8b39ef6cffc8e1f9f4acc87628b70ffd69b77bd Mon Sep 17 00:00:00 2001 From: lorenzwalthert Date: Fri, 3 May 2019 08:42:03 +0200 Subject: [PATCH 28/48] more test fixes --- .../token_adding_removing/add_brackets_in_pipe-out.R | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/tests/testthat/token_adding_removing/add_brackets_in_pipe-out.R b/tests/testthat/token_adding_removing/add_brackets_in_pipe-out.R index 323581851..3bb029b9f 100644 --- a/tests/testthat/token_adding_removing/add_brackets_in_pipe-out.R +++ b/tests/testthat/token_adding_removing/add_brackets_in_pipe-out.R @@ -1,7 +1,5 @@ -1 %>% - 2 +1 %>% 2 1 %x% 1 1 %x% y -1 %>% - x() +1 %>% x() 1 %s% 1 From a75ab55a689875a5368524ce4197f8647d0bd530 Mon Sep 17 00:00:00 2001 From: lorenzwalthert Date: Fri, 3 May 2019 10:41:28 +0200 Subject: [PATCH 29/48] re-arrange life cylce and auto save --- R/addins.R | 21 ++++++++++----------- man/styler_addins.Rd | 26 +++++++++++++------------- 2 files changed, 23 insertions(+), 24 deletions(-) diff --git a/R/addins.R b/R/addins.R index 93090b8bb..1808afaa3 100644 --- a/R/addins.R +++ b/R/addins.R @@ -7,30 +7,29 @@ #' entering `styler::tidyverse_style(scope = "spaces")` in the Addin is #' equivalent to `styler::style_text("1+1", scope = "spaces")` and #' `styler::style_text("1+1", transformers = styler::tidyverse_style(scope = "spaces"))` -#' if the text to style is `1 + 1`. The style transformers are memorized +#' if the text to style is `1+1`. The style transformers are memorized #' within an R session via the R option `styler.addins_style_transformer` so #' if you want it to persist over sessions, set the option #' `styler.addins_style_transformer` in your `.Rprofile`. #' - Style active file: Styles the active file, by default with -#' [tidyverse_style()] and `strict = TRUE` or the value of the option +#' [tidyverse_style()] or the value of the option #' `styler.addins_style_transformer` if specified. -#' - Style selection: Same as *style active file*, but styles the highlighted +#' - Style selection: Same as *Style active file*, but styles the highlighted #' code instead of the whole file. -#' @section Life cycle: -#' The way of specifying the style in the Addin is experimental. We currently -#' think about letting the user specify the defaults for other style APIs like -#' [styler::style_text()], either via R options, config files or other ways as -#' well. See [r-lib/styler#319](https://github.com/r-lib/styler/issues/319) for -#' the current status of this. #' @section Auto-Save Option: #' By default, both of the RStudio Addins will apply styling to the (selected) #' file contents without saving changes. Automatic saving can be enabled by #' setting the environment variable `save_after_styling` to `TRUE`. -#' #' Consider setting this in your `.Rprofile` file if you want to persist #' this setting across multiple sessions. Untitled files will always need to be #' saved manually after styling. -#' +#' @section Life cycle: +#' The way of specifying the style as well as the auto-save option (see below) +#' in the Addin are experimental. We currently +#' think about letting the user specify the defaults for other style APIs like +#' [styler::style_text()], either via R options, config files or other ways as +#' well. See [r-lib/styler#319](https://github.com/r-lib/styler/issues/319) for +#' the current status of this. #' @name styler_addins #' @family stylers #' @examples diff --git a/man/styler_addins.Rd b/man/styler_addins.Rd index 48254cf48..659dd0db4 100644 --- a/man/styler_addins.Rd +++ b/man/styler_addins.Rd @@ -14,38 +14,38 @@ input is passed to the \code{transformers} argument, not the \code{style} argume entering \code{styler::tidyverse_style(scope = "spaces")} in the Addin is equivalent to \code{styler::style_text("1+1", scope = "spaces")} and \code{styler::style_text("1+1", transformers = styler::tidyverse_style(scope = "spaces"))} -if the text to style is \code{1 + 1}. The style transformers are memorized +if the text to style is \code{1+1}. The style transformers are memorized within an R session via the R option \code{styler.addins_style_transformer} so if you want it to persist over sessions, set the option \code{styler.addins_style_transformer} in your \code{.Rprofile}. \item Style active file: Styles the active file, by default with -\code{\link[=tidyverse_style]{tidyverse_style()}} and \code{strict = TRUE} or the value of the option +\code{\link[=tidyverse_style]{tidyverse_style()}} or the value of the option \code{styler.addins_style_transformer} if specified. -\item Style selection: Same as \emph{style active file}, but styles the highlighted +\item Style selection: Same as \emph{Style active file}, but styles the highlighted code instead of the whole file. } } -\section{Life cycle}{ - -The way of specifying the style in the Addin is experimental. We currently -think about letting the user specify the defaults for other style APIs like -\code{\link[styler:style_text]{styler::style_text()}}, either via R options, config files or other ways as -well. See \href{https://github.com/r-lib/styler/issues/319}{r-lib/styler#319} for -the current status of this. -} - \section{Auto-Save Option}{ By default, both of the RStudio Addins will apply styling to the (selected) file contents without saving changes. Automatic saving can be enabled by setting the environment variable \code{save_after_styling} to \code{TRUE}. - Consider setting this in your \code{.Rprofile} file if you want to persist this setting across multiple sessions. Untitled files will always need to be saved manually after styling. } +\section{Life cycle}{ + +The way of specifying the style as well as the auto-save option (see below) +in the Addin are experimental. We currently +think about letting the user specify the defaults for other style APIs like +\code{\link[styler:style_text]{styler::style_text()}}, either via R options, config files or other ways as +well. See \href{https://github.com/r-lib/styler/issues/319}{r-lib/styler#319} for +the current status of this. +} + \examples{ \dontrun{ # save after styling when using the Addin From 37750c770e9ee54c9fb02350e15b30587549f379 Mon Sep 17 00:00:00 2001 From: lorenzwalthert Date: Fri, 3 May 2019 10:43:42 +0200 Subject: [PATCH 30/48] re-arrange doc --- R/addins.R | 10 +++++----- man/styler_addins.Rd | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/R/addins.R b/R/addins.R index 1808afaa3..6d3b16691 100644 --- a/R/addins.R +++ b/R/addins.R @@ -24,11 +24,11 @@ #' this setting across multiple sessions. Untitled files will always need to be #' saved manually after styling. #' @section Life cycle: -#' The way of specifying the style as well as the auto-save option (see below) -#' in the Addin are experimental. We currently -#' think about letting the user specify the defaults for other style APIs like -#' [styler::style_text()], either via R options, config files or other ways as -#' well. See [r-lib/styler#319](https://github.com/r-lib/styler/issues/319) for +#' The way of specifying the style in the Addin as well as the auto-save option +#' (see below) are experimental. We currently think about letting the user +#' specify the defaults for other style APIs like [styler::style_text()], +#' either via R options, config files or other ways as well. +#' See [r-lib/styler#319](https://github.com/r-lib/styler/issues/319) for #' the current status of this. #' @name styler_addins #' @family stylers diff --git a/man/styler_addins.Rd b/man/styler_addins.Rd index 659dd0db4..ed585a1de 100644 --- a/man/styler_addins.Rd +++ b/man/styler_addins.Rd @@ -38,11 +38,11 @@ saved manually after styling. \section{Life cycle}{ -The way of specifying the style as well as the auto-save option (see below) -in the Addin are experimental. We currently -think about letting the user specify the defaults for other style APIs like -\code{\link[styler:style_text]{styler::style_text()}}, either via R options, config files or other ways as -well. See \href{https://github.com/r-lib/styler/issues/319}{r-lib/styler#319} for +The way of specifying the style in the Addin as well as the auto-save option +(see below) are experimental. We currently think about letting the user +specify the defaults for other style APIs like \code{\link[styler:style_text]{styler::style_text()}}, +either via R options, config files or other ways as well. +See \href{https://github.com/r-lib/styler/issues/319}{r-lib/styler#319} for the current status of this. } From 958e01da6ba713a1ab04a7b17536cbaf9f132c5d Mon Sep 17 00:00:00 2001 From: Jon Calder Date: Sun, 5 May 2019 15:24:40 +0200 Subject: [PATCH 31/48] Require cli 1.1.0 `test-public_api.R` uses `cli::is_utf8_output()` which wasn't present/exported in earlier versions of `cli`. --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 270a7640b..ee73a0f31 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -18,7 +18,7 @@ URL: https://github.com/r-lib/styler BugReports: https://github.com/r-lib/styler/issues Imports: backports (>= 1.1.0), - cli, + cli (>= 1.1.0), magrittr (>= 1.0.1), purrr (>= 0.2.3), rematch2, From 605e71ee5546dc666d2315aefe507e732408281f Mon Sep 17 00:00:00 2001 From: Jon Calder Date: Sun, 5 May 2019 15:50:00 +0200 Subject: [PATCH 32/48] Update R/addins.R Co-Authored-By: lorenzwalthert --- R/addins.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/addins.R b/R/addins.R index 6d3b16691..c91c0e4ad 100644 --- a/R/addins.R +++ b/R/addins.R @@ -25,7 +25,7 @@ #' saved manually after styling. #' @section Life cycle: #' The way of specifying the style in the Addin as well as the auto-save option -#' (see below) are experimental. We currently think about letting the user +#' (see below) are experimental. We are currently considering letting the user #' specify the defaults for other style APIs like [styler::style_text()], #' either via R options, config files or other ways as well. #' See [r-lib/styler#319](https://github.com/r-lib/styler/issues/319) for From 259192399b5270b6961e773a2c9590c0caba178e Mon Sep 17 00:00:00 2001 From: lorenzwalthert Date: Mon, 6 May 2019 19:13:41 +0200 Subject: [PATCH 33/48] renaming for consistency, re-add style pkg addin. --- R/addins.R | 19 +++++++++++++------ inst/rstudio/addins.dcf | 11 ++++++++--- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/R/addins.R b/R/addins.R index 6d3b16691..695132b98 100644 --- a/R/addins.R +++ b/R/addins.R @@ -47,9 +47,9 @@ NULL #' @importFrom rlang abort #' @keywords internal style_active_file <- function() { - communicate_addins_style() + communicate_addins_style_transformers() context <- get_rstudio_context() - transformer <- make_transformer(get_addins_style_fun(), + transformer <- make_transformer(get_addins_style_transformer(), include_roxygen_examples = TRUE, warn_empty = is_plain_r_file(context$path) ) @@ -73,15 +73,22 @@ style_active_file <- function() { rstudioapi::setCursorPosition(context$selection[[1]]$range) } +#' Wrapper around [style_pkg()] for access via Addin. +#' @keywords internal +style_active_pkg <- function() { + communicate_addins_style_transformers() + style_pkg(transformers = get_addins_style_transformer()) +} + #' Styles the highlighted selection in a `.R` or `.Rmd` file. #' @importFrom rlang abort #' @keywords internal style_selection <- function() { - communicate_addins_style() + communicate_addins_style_transformers() context <- get_rstudio_context() text <- context$selection[[1]]$text if (all(nchar(text) == 0)) abort("No code selected") - out <- style_text(text, transformers = get_addins_style_fun()) + out <- style_text(text, transformers = get_addins_style_transformer()) rstudioapi::modifyRange( context$selection[[1]]$range, paste0(out, collapse = "\n"), id = context$id @@ -131,11 +138,11 @@ get_addins_style_transformer_name <- function() { #' @rdname get_addins_style_transformer_name #' @keywords internal -get_addins_style_fun <- function() { +get_addins_style_transformer <- function() { eval(parse(text = get_addins_style_transformer_name())) } -communicate_addins_style <- function() { +communicate_addins_style_transformers <- function() { style_name <- get_addins_style_transformer_name() cat("Using style transformers `", style_name, "`\n", sep = "") } diff --git a/inst/rstudio/addins.dcf b/inst/rstudio/addins.dcf index 0b524b316..fcef8f90d 100644 --- a/inst/rstudio/addins.dcf +++ b/inst/rstudio/addins.dcf @@ -3,12 +3,17 @@ Description: Prompt for and set the style transformers used by all styler addins Binding: set_style_transformers Interactive: true +Name: Style selection +Description: Pretty-print selection +Binding: style_selection +Interactive: true + Name: Style active file Description: Pretty-print active file Binding: style_active_file Interactive: true -Name: Style selection -Description: Pretty-print selection -Binding: style_selection +Name: Style active package +Description: Pretty-print active package +Binding: style_active_pkg Interactive: true From 941506b900959d7e24257dbb77f9c6ed1b8f2650 Mon Sep 17 00:00:00 2001 From: lorenzwalthert Date: Mon, 6 May 2019 19:30:22 +0200 Subject: [PATCH 34/48] document --- man/get_addins_style_transformer_name.Rd | 4 ++-- man/style_active_pkg.Rd | 12 ++++++++++++ man/styler_addins.Rd | 2 +- 3 files changed, 15 insertions(+), 3 deletions(-) create mode 100644 man/style_active_pkg.Rd diff --git a/man/get_addins_style_transformer_name.Rd b/man/get_addins_style_transformer_name.Rd index a5c005390..deccf5ff3 100644 --- a/man/get_addins_style_transformer_name.Rd +++ b/man/get_addins_style_transformer_name.Rd @@ -2,12 +2,12 @@ % Please edit documentation in R/addins.R \name{get_addins_style_transformer_name} \alias{get_addins_style_transformer_name} -\alias{get_addins_style_fun} +\alias{get_addins_style_transformer} \title{Return the style function or name} \usage{ get_addins_style_transformer_name() -get_addins_style_fun() +get_addins_style_transformer() } \description{ Return the style function or name diff --git a/man/style_active_pkg.Rd b/man/style_active_pkg.Rd new file mode 100644 index 000000000..d16e22270 --- /dev/null +++ b/man/style_active_pkg.Rd @@ -0,0 +1,12 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/addins.R +\name{style_active_pkg} +\alias{style_active_pkg} +\title{Wrapper around \code{\link[=style_pkg]{style_pkg()}} for access via Addin.} +\usage{ +style_active_pkg() +} +\description{ +Wrapper around \code{\link[=style_pkg]{style_pkg()}} for access via Addin. +} +\keyword{internal} diff --git a/man/styler_addins.Rd b/man/styler_addins.Rd index ed585a1de..78a8d6b7b 100644 --- a/man/styler_addins.Rd +++ b/man/styler_addins.Rd @@ -39,7 +39,7 @@ saved manually after styling. \section{Life cycle}{ The way of specifying the style in the Addin as well as the auto-save option -(see below) are experimental. We currently think about letting the user +(see below) are experimental. We are currently considering letting the user specify the defaults for other style APIs like \code{\link[styler:style_text]{styler::style_text()}}, either via R options, config files or other ways as well. See \href{https://github.com/r-lib/styler/issues/319}{r-lib/styler#319} for From 352d540904fd91864effc0255b349e80bb9e535b Mon Sep 17 00:00:00 2001 From: lorenzwalthert Date: Wed, 1 May 2019 23:59:17 +0200 Subject: [PATCH 35/48] style with styler (mostly put return on new line). --- R/communicate.R | 1 - R/expr-is.R | 29 +++++++++++++++++++-------- R/indent.R | 20 ++++++++++++++----- R/nest.R | 8 ++++++-- R/nested-to-tree.R | 4 +++- R/reindent.R | 4 +++- R/relevel.R | 13 ++++++++---- R/roxygen-examples-find.R | 4 +++- R/roxygen-examples.R | 4 +++- R/rules-line-break.R | 14 ++++++++----- R/rules-other.R | 7 ++++--- R/rules-replacement.R | 4 +++- R/rules-spacing.R | 42 +++++++++++++++++++++++++++++---------- R/token-create.R | 4 +++- R/transform-files.R | 8 ++++++-- R/ui.R | 2 +- R/unindent.R | 12 ++++++++--- R/utils-navigate-nest.R | 23 ++++++++++++++------- R/utils.R | 9 ++++++--- R/visit.R | 16 +++++++++++---- 20 files changed, 163 insertions(+), 65 deletions(-) diff --git a/R/communicate.R b/R/communicate.R index c4e3e4eea..b537aa094 100644 --- a/R/communicate.R +++ b/R/communicate.R @@ -34,4 +34,3 @@ assert_data.tree_installation <- function() { abort("The package data.tree needs to be installed for this functionality.") } } - diff --git a/R/expr-is.R b/R/expr-is.R index 8a56abf53..04d0a146b 100644 --- a/R/expr-is.R +++ b/R/expr-is.R @@ -9,7 +9,9 @@ NULL #' curly brackets. #' @keywords internal is_curly_expr <- function(pd) { - if (is.null(pd)) return(FALSE) + if (is.null(pd)) { + return(FALSE) + } pd$token[1] == "'{'" } @@ -32,22 +34,30 @@ is_while_expr <- function(pd) { #' @describeIn pd_is Checks whether `pd` is a function call. #' @keywords internal is_function_call <- function(pd) { - if (is.null(pd)) return(FALSE) - if (is.na(pd$token_before[2])) return(FALSE) + if (is.null(pd)) { + return(FALSE) + } + if (is.na(pd$token_before[2])) { + return(FALSE) + } pd$token_before[2] == "SYMBOL_FUNCTION_CALL" } #' @describeIn pd_is Checks whether `pd` is a function declaration. #' @keywords internal is_function_dec <- function(pd) { - if (is.null(pd)) return(FALSE) + if (is.null(pd)) { + return(FALSE) + } pd$token[1] == "FUNCTION" } #' @describeIn pd_is Checks for every token whether or not it is a comment. #' @keywords internal is_comment <- function(pd) { - if (is.null(pd)) return(FALSE) + if (is.null(pd)) { + return(FALSE) + } pd$token == "COMMENT" } @@ -66,7 +76,9 @@ is_comment <- function(pd) { #' expression (like `a~b`). #' @keywords internal is_tilde_expr <- function(pd, tilde_pos = c(1, 2)) { - if (is.null(pd) || nrow(pd) == 1) return(FALSE) + if (is.null(pd) || nrow(pd) == 1) { + return(FALSE) + } any(pd$token[tilde_pos] == "'~'") } @@ -81,7 +93,9 @@ is_symmetric_tilde_expr <- function(pd) { } is_subset_expr <- function(pd) { - if (is.null(pd) || nrow(pd) == 1) return(FALSE) + if (is.null(pd) || nrow(pd) == 1) { + return(FALSE) + } pd$token[2] == "'['" } @@ -148,4 +162,3 @@ contains_else_expr_that_needs_braces <- function(pd) { FALSE } } - diff --git a/R/indent.R b/R/indent.R index 6219ba322..2f4afbe19 100644 --- a/R/indent.R +++ b/R/indent.R @@ -64,7 +64,9 @@ indent_eq_sub <- function(pd, indent_by, token = c("EQ_SUB", "EQ_FORMALS")) { eq_sub <- which(pd$token %in% token) - if (length(eq_sub) == 0) return(pd) + if (length(eq_sub) == 0) { + return(pd) + } has_line_break <- which(pd$lag_newlines > 0) indent_indices <- intersect(eq_sub + 1, has_line_break) pd$indent[indent_indices] <- pd$indent[indent_indices] + indent_by @@ -86,8 +88,12 @@ indent_without_paren <- function(pd, indent_by = 2) { #' @keywords internal indent_without_paren_for_while_fun <- function(pd, indent_by) { nrow <- nrow(pd) - if (!(pd$token[1] %in% c("FOR", "WHILE", "FUNCTION"))) return(pd) - if (is_curly_expr(pd$child[[nrow]])) return(pd) + if (!(pd$token[1] %in% c("FOR", "WHILE", "FUNCTION"))) { + return(pd) + } + if (is_curly_expr(pd$child[[nrow]])) { + return(pd) + } pd$indent[nrow] <- indent_by pd } @@ -148,7 +154,9 @@ compute_indent_indices <- function(pd, other_trigger_tokens = c("EQ_SUB", "EQ_FORMALS") ) trigger <- potential_triggers[needs_indention][1] - if (is.na(trigger)) return(numeric(0)) + if (is.na(trigger)) { + return(numeric(0)) + } start <- trigger + 1 if (is.null(token_closing)) { stop <- npd @@ -209,7 +217,9 @@ needs_indention_one <- function(pd, potential_trigger_pos, other_trigger_tokens) { before_first_break <- which(pd$lag_newlines > 0)[1] - 1 - if (is.na(before_first_break)) return(FALSE) + if (is.na(before_first_break)) { + return(FALSE) + } row_idx_between_trigger_and_line_break <- seq2( potential_trigger_pos, before_first_break ) diff --git a/R/nest.R b/R/nest.R index e36eebb53..6d272ff77 100644 --- a/R/nest.R +++ b/R/nest.R @@ -119,7 +119,9 @@ set_spaces <- function(spaces_after_prefix, force_one) { #' @importFrom purrr map2 #' @keywords internal nest_parse_data <- function(pd_flat) { - if (all(pd_flat$parent <= 0)) return(pd_flat) + if (all(pd_flat$parent <= 0)) { + return(pd_flat) + } pd_flat$internal <- with(pd_flat, (id %in% parent) | (parent <= 0)) split_data <- split(pd_flat, pd_flat$internal) @@ -152,7 +154,9 @@ nest_parse_data <- function(pd_flat) { #' @keywords internal combine_children <- function(child, internal_child) { bound <- bind_rows(child, internal_child) - if (nrow(bound) == 0) return(NULL) + if (nrow(bound) == 0) { + return(NULL) + } bound[order(bound$pos_id), ] } diff --git a/R/nested-to-tree.R b/R/nested-to-tree.R index 48b7db664..294b5d462 100644 --- a/R/nested-to-tree.R +++ b/R/nested-to-tree.R @@ -66,7 +66,9 @@ create_node_from_nested <- function(pd_nested, parent, structure_only) { } create_node_info <- function(pd_nested, structure_only) { - if (structure_only) return(seq2(1L, nrow(pd_nested))) + if (structure_only) { + return(seq2(1L, nrow(pd_nested))) + } paste0( pd_nested$token, ": ", pd_nested$short, " [", diff --git a/R/reindent.R b/R/reindent.R index 86f25309f..def942bbb 100644 --- a/R/reindent.R +++ b/R/reindent.R @@ -162,7 +162,9 @@ set_regex_indention <- function(flattened_pd, cond <- which( (flattened_pd$token == "COMMENT") & (flattened_pd$lag_newlines > 0) ) - if (length(cond) < 1) return(flattened_pd) + if (length(cond) < 1) { + return(flattened_pd) + } to_check <- flattened_pd[cond, ] not_to_check <- flattened_pd[-cond, ] } else { diff --git a/R/relevel.R b/R/relevel.R index eaabc7ab2..daf6e8de0 100644 --- a/R/relevel.R +++ b/R/relevel.R @@ -54,15 +54,21 @@ flatten_operators_one <- function(pd_nested) { #' @keywords internal flatten_pd <- function(pd_nested, token, child_token = token, left = TRUE) { token_pos_candidates <- which(pd_nested$token[-1] %in% token) + 1 - if (length(token_pos_candidates) == 0) return(pd_nested) + if (length(token_pos_candidates) == 0) { + return(pd_nested) + } token_pos <- token_pos_candidates[if_else(left, 1, length(token_pos_candidates))] if (left) { pos <- previous_non_comment(pd_nested, token_pos) } else { pos <- next_non_comment(pd_nested, token_pos) } - if (pos < 1) return(pd_nested) - if (!any(pd_nested$child[[pos]]$token[-1] %in% child_token)) return(pd_nested) + if (pos < 1) { + return(pd_nested) + } + if (!any(pd_nested$child[[pos]]$token[-1] %in% child_token)) { + return(pd_nested) + } bind_with_child(pd_nested, pos) } @@ -139,7 +145,6 @@ relocate_eq_assign <- function(pd) { } else { pd } - } diff --git a/R/roxygen-examples-find.R b/R/roxygen-examples-find.R index 3ddbffb05..98c8145b2 100644 --- a/R/roxygen-examples-find.R +++ b/R/roxygen-examples-find.R @@ -11,7 +11,9 @@ identify_start_to_stop_of_roxygen_examples_from_text <- function(text) { stop_candidates <- grep("^[^#]|^#'\\s*@", text, perl = TRUE) stops <- map(starts, match_stop_to_start, stop_candidates) %>% flatten_int() - if (length(stops) < 1L) return(integer()) + if (length(stops) < 1L) { + return(integer()) + } map2(starts, stops, seq2) } diff --git a/R/roxygen-examples.R b/R/roxygen-examples.R index f35d7da53..434544b09 100644 --- a/R/roxygen-examples.R +++ b/R/roxygen-examples.R @@ -36,7 +36,9 @@ style_roxygen_code_example <- function(example, transformers) { #' @importFrom purrr map2 flatten_chr #' @keywords internal style_roxygen_code_example_segment <- function(one_dont, transformers) { - if (length(one_dont) < 1L) return(character()) + if (length(one_dont) < 1L) { + return(character()) + } dont_seqs <- find_dont_seqs(one_dont) split_segments <- split_roxygen_segments(one_dont, unlist(dont_seqs)) is_dont <- diff --git a/R/rules-line-break.R b/R/rules-line-break.R index 65b62eaf4..73a5b18cb 100644 --- a/R/rules-line-break.R +++ b/R/rules-line-break.R @@ -8,9 +8,9 @@ remove_line_break_before_curly_opening <- function(pd) { set_line_break_around_comma <- function(pd) { comma_with_line_break_that_can_be_removed_before <- (pd$token == "','") & - (pd$lag_newlines > 0) & - (pd$token_before != "COMMENT") & - (lag(pd$token) != "'['") + (pd$lag_newlines > 0) & + (pd$token_before != "COMMENT") & + (lag(pd$token) != "'['") pd$lag_newlines[comma_with_line_break_that_can_be_removed_before] <- 0L pd$lag_newlines[lag(comma_with_line_break_that_can_be_removed_before)] <- 1L pd @@ -77,7 +77,9 @@ set_line_break_after_opening_if_call_is_multi_line <- function(pd, except_token_after = NULL, except_text_before = NULL) { - if (!is_function_call(pd) && !is_subset_expr(pd)) return(pd) + if (!is_function_call(pd) && !is_subset_expr(pd)) { + return(pd) + } npd <- nrow(pd) seq_x <- seq2(3L, npd - 1L) is_multi_line <- any( @@ -116,7 +118,9 @@ find_line_break_position_in_multiline_call <- function(pd) { #' closing parenthesis. #' @keywords internal set_line_break_before_closing_call <- function(pd, except_token_before) { - if (!is_function_call(pd) && !is_subset_expr(pd)) return(pd) + if (!is_function_call(pd) && !is_subset_expr(pd)) { + return(pd) + } npd <- nrow(pd) is_multi_line <- any(pd$lag_newlines[seq2(3L, npd - 1L)] > 0) if (!is_multi_line) { diff --git a/R/rules-other.R b/R/rules-other.R index 4617158de..99f4751c9 100644 --- a/R/rules-other.R +++ b/R/rules-other.R @@ -34,7 +34,8 @@ add_brackets_in_pipe_one <- function(pd, pos) { #' @keywords internal #' @importFrom purrr when wrap_if_else_while_for_multi_line_in_curly <- function(pd, indent_by = 2) { - key_token <- when(pd, + key_token <- when( + pd, is_cond_expr(.) ~ "')'", is_while_expr(.) ~ "')'", is_for_expr(.) ~ "forcond" @@ -45,7 +46,7 @@ wrap_if_else_while_for_multi_line_in_curly <- function(pd, indent_by = 2) { space_after = ifelse(contains_else_expr(pd), 1, 0), key_token = key_token ) - } + } if (is_cond_expr(pd)) { pd <- pd %>% wrap_else_multiline_curly(indent_by, space_after = 0) @@ -65,7 +66,7 @@ wrap_multiline_curly <- function(pd, indent_by, space_after = 1, key_token) { to_be_wrapped_expr_with_child <- next_non_comment( pd, which(pd$token == key_token)[1] ) - next_terminal <- next_terminal(pd[to_be_wrapped_expr_with_child,])$text + next_terminal <- next_terminal(pd[to_be_wrapped_expr_with_child, ])$text requires_braces <- if_for_while_part_requires_braces(pd, key_token) if (requires_braces | next_terminal == "return") { closing_brace_ind <- which(pd$token == key_token)[1] diff --git a/R/rules-replacement.R b/R/rules-replacement.R index 2066e6fdb..ccca40697 100644 --- a/R/rules-replacement.R +++ b/R/rules-replacement.R @@ -8,7 +8,9 @@ force_assignment_op <- function(pd) { resolve_semicolon <- function(pd) { is_semicolon <- pd$token == "';'" - if (!any(is_semicolon)) return(pd) + if (!any(is_semicolon)) { + return(pd) + } pd$lag_newlines[lag(is_semicolon)] <- 1L pd <- pd[!is_semicolon, ] pd diff --git a/R/rules-spacing.R b/R/rules-spacing.R index ccbff1fbf..ca36eafe2 100644 --- a/R/rules-spacing.R +++ b/R/rules-spacing.R @@ -14,7 +14,9 @@ add_space_around_op <- function(pd_flat) { #' @keywords internal set_space_around_op <- function(pd_flat) { op_after <- pd_flat$token %in% op_token - if (!any(op_after)) return(pd_flat) + if (!any(op_after)) { + return(pd_flat) + } op_before <- lead(op_after, default = FALSE) pd_flat$spaces[op_before & (pd_flat$newlines == 0L)] <- 1L pd_flat$spaces[op_after & (pd_flat$newlines == 0L)] <- 1L @@ -113,13 +115,15 @@ fix_quotes <- function(pd_flat) { str_const_change <- grepl("^'([^\"]*)'$", pd_flat$text[str_const]) pd_flat$text[str_const][str_const_change] <- map(pd_flat$text[str_const][str_const_change], parse_text) %>% - map_chr(~paste0("\"", .x, "\"")) + map_chr(~ paste0("\"", .x, "\"")) pd_flat } remove_space_before_opening_paren <- function(pd_flat) { paren_after <- pd_flat$token == "'('" - if (!any(paren_after)) return(pd_flat) + if (!any(paren_after)) { + return(pd_flat) + } paren_before <- lead(paren_after, default = FALSE) pd_flat$spaces[paren_before & (pd_flat$newlines == 0L)] <- 0L pd_flat @@ -127,14 +131,18 @@ remove_space_before_opening_paren <- function(pd_flat) { remove_space_after_opening_paren <- function(pd_flat) { paren_after <- pd_flat$token == "'('" - if (!any(paren_after)) return(pd_flat) + if (!any(paren_after)) { + return(pd_flat) + } 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 == "')'" - if (!any(paren_after)) return(pd_flat) + if (!any(paren_after)) { + return(pd_flat) + } paren_before <- lead(paren_after, default = FALSE) pd_flat$spaces[paren_before & (pd_flat$newlines == 0L)] <- 0L pd_flat @@ -142,7 +150,9 @@ remove_space_before_closing_paren <- function(pd_flat) { add_space_after_for_if_while <- function(pd_flat) { comma_after <- pd_flat$token %in% c("FOR", "IF", "WHILE") - if (!any(comma_after)) return(pd_flat) + if (!any(comma_after)) { + return(pd_flat) + } idx <- comma_after & (pd_flat$newlines == 0L) pd_flat$spaces[idx] <- pmax(pd_flat$spaces[idx], 1L) pd_flat @@ -150,7 +160,9 @@ add_space_after_for_if_while <- function(pd_flat) { add_space_before_brace <- function(pd_flat) { op_after <- pd_flat$token %in% "'{'" - if (!any(op_after)) return(pd_flat) + if (!any(op_after)) { + return(pd_flat) + } op_before <- lead(op_after, default = FALSE) idx_before <- op_before & (pd_flat$newlines == 0L) & pd_flat$token != "'('" pd_flat$spaces[idx_before] <- pmax(pd_flat$spaces[idx_before], 1L) @@ -171,7 +183,9 @@ set_space_after_comma <- function(pd_flat) { remove_space_before_comma <- function(pd_flat) { comma_after <- pd_flat$token == "','" - if (!any(comma_after)) return(pd_flat) + if (!any(comma_after)) { + return(pd_flat) + } comma_before <- lead(comma_after, default = FALSE) idx <- comma_before & (pd_flat$newlines == 0L) pd_flat$spaces[idx] <- 0L @@ -212,7 +226,9 @@ set_space_between_levels <- function(pd_flat) { #' @keywords internal start_comments_with_space <- function(pd, force_one = FALSE) { comment_pos <- is_comment(pd) & !is_shebang(pd) & !is_code_chunk_header(pd) - if (!any(comment_pos)) return(pd) + if (!any(comment_pos)) { + return(pd) + } comments <- rematch2::re_match( pd$text[comment_pos], @@ -241,7 +257,9 @@ start_comments_with_space <- function(pd, force_one = FALSE) { set_space_before_comments <- function(pd_flat) { comment_after <- (pd_flat$token == "COMMENT") & (pd_flat$lag_newlines == 0L) - if (!any(comment_after)) return(pd_flat) + if (!any(comment_after)) { + return(pd_flat) + } comment_before <- lead(comment_after, default = FALSE) pd_flat$spaces[comment_before & (pd_flat$newlines == 0L)] <- 1L pd_flat @@ -249,7 +267,9 @@ set_space_before_comments <- function(pd_flat) { add_space_before_comments <- function(pd_flat) { comment_after <- (pd_flat$token == "COMMENT") & (pd_flat$lag_newlines == 0L) - if (!any(comment_after)) return(pd_flat) + if (!any(comment_after)) { + return(pd_flat) + } comment_before <- lead(comment_after, default = FALSE) pd_flat$spaces[comment_before & (pd_flat$newlines == 0L)] <- pmax(pd_flat$spaces[comment_before], 1L) diff --git a/R/token-create.R b/R/token-create.R index 8a065697a..abb7880f7 100644 --- a/R/token-create.R +++ b/R/token-create.R @@ -126,7 +126,9 @@ validate_new_pos_ids <- function(new_ids, after) { wrap_expr_in_curly <- function(pd, stretch_out = c(FALSE, FALSE), space_after = 1) { - if (is_curly_expr(pd)) return(pd) + if (is_curly_expr(pd)) { + return(pd) + } if (stretch_out[1]) { pd$lag_newlines[1] <- 1L } diff --git a/R/transform-files.R b/R/transform-files.R index dac30132c..6d45b03b8 100644 --- a/R/transform-files.R +++ b/R/transform-files.R @@ -114,7 +114,9 @@ make_transformer <- function(transformers, include_roxygen_examples, warn_empty #' @keywords internal parse_transform_serialize_roxygen <- function(text, transformers) { roxygen_seqs <- identify_start_to_stop_of_roxygen_examples_from_text(text) - if (length(roxygen_seqs) < 1L) return(text) + if (length(roxygen_seqs) < 1L) { + return(text) + } split_segments <- split_roxygen_segments(text, unlist(roxygen_seqs)) map_at(split_segments$separated, split_segments$selectors, style_roxygen_code_example, @@ -139,7 +141,9 @@ parse_transform_serialize_roxygen <- function(text, transformers) { #' @importFrom rlang seq2 #' @keywords internal split_roxygen_segments <- function(text, roxygen_examples) { - if (is.null(roxygen_examples)) return(lst(separated = list(text), selectors = NULL)) + if (is.null(roxygen_examples)) { + return(lst(separated = list(text), selectors = NULL)) + } all_lines <- seq2(1L, length(text)) active_segment <- as.integer(all_lines %in% roxygen_examples) segment_id <- cumsum(abs(c(0L, diff(active_segment)))) + 1L diff --git a/R/ui.R b/R/ui.R index b8152e11d..e950f8fb0 100644 --- a/R/ui.R +++ b/R/ui.R @@ -59,7 +59,7 @@ NULL #' @family stylers #' @examples #' \dontrun{ -#' +#' #' style_pkg(style = tidyverse_style, strict = TRUE) #' style_pkg( #' scope = "line_breaks", diff --git a/R/unindent.R b/R/unindent.R index 96e5b56a9..0843f6905 100644 --- a/R/unindent.R +++ b/R/unindent.R @@ -7,15 +7,21 @@ #' @importFrom rlang seq2 #' @keywords internal set_unindention_child <- function(pd, token = "')'", unindent_by) { - if (all(pd$indent == 0) || all(pd$terminal)) return(pd) + if (all(pd$indent == 0) || all(pd$terminal)) { + return(pd) + } closing <- which(pd$token %in% token) - if (length(closing) == 0 || pd$lag_newlines[closing] > 0) return(pd) + if (length(closing) == 0 || pd$lag_newlines[closing] > 0) { + return(pd) + } first_on_last_line <- last(c(1, which(pd$lag_newlines > 0 | pd$multi_line))) on_same_line <- seq2(first_on_last_line, closing - 1) cand_ind <- setdiff(on_same_line, which(pd$terminal)) - if (length(cand_ind) < 1) return(pd) + if (length(cand_ind) < 1) { + return(pd) + } candidates <- pd[cand_ind, ] diff --git a/R/utils-navigate-nest.R b/R/utils-navigate-nest.R index ae31f9082..86ceb41ff 100644 --- a/R/utils-navigate-nest.R +++ b/R/utils-navigate-nest.R @@ -5,17 +5,25 @@ #' @importFrom rlang seq2 #' @keywords internal next_non_comment <- function(pd, pos) { - if (length(pos) < 1 || is.na(pos) || pos >= nrow(pd)) return(integer(0)) + if (length(pos) < 1 || is.na(pos) || pos >= nrow(pd)) { + return(integer(0)) + } candidates <- seq2(pos + 1L, nrow(pd)) - if (all(candidates %in% which(pd$token == "COMMENT"))) return(integer(0)) + if (all(candidates %in% which(pd$token == "COMMENT"))) { + return(integer(0)) + } setdiff(candidates, which(pd$token == "COMMENT"))[1] } #' @rdname next_non_comment previous_non_comment <- function(pd, pos) { - if (length(pos) < 1 || is.na(pos) || pos >= nrow(pd)) return(integer(0)) + if (length(pos) < 1 || is.na(pos) || pos >= nrow(pd)) { + return(integer(0)) + } candidates <- seq2(1L, pos - 1L) - if (all(candidates %in% which(pd$token == "COMMENT"))) return(integer(0)) + if (all(candidates %in% which(pd$token == "COMMENT"))) { + return(integer(0)) + } last(setdiff(candidates, which(pd$token == "COMMENT"))) } @@ -46,9 +54,8 @@ next_terminal <- function(pd, stack = FALSE, vars = c("pos_id", "token", "text"), tokens_exclude = c()) { - pd$position <- seq2(1, nrow(pd)) - pd <- pd[!(pd$token %in% tokens_exclude),] + pd <- pd[!(pd$token %in% tokens_exclude), ] if (pd$terminal[1]) { pd[1, c("position", vars)] } else { @@ -68,7 +75,9 @@ next_terminal <- function(pd, #' @param pos The position of the token to start the search from. #' @keywords internal extend_if_comment <- function(pd, pos) { - if (pos == nrow(pd)) return(pos) + if (pos == nrow(pd)) { + return(pos) + } if (pd$token[pos + 1] == "COMMENT") { extend_if_comment(pd, pos + 1L) } else { diff --git a/R/utils.R b/R/utils.R index 5db3716ac..60bef1be6 100644 --- a/R/utils.R +++ b/R/utils.R @@ -27,12 +27,16 @@ odd <- function(x) { } odd_index <- function(x) { - if (length(x) < 1) return(NULL) + if (length(x) < 1) { + return(NULL) + } seq(1L, length(x), by = 2) } even <- function(x) { - if (length(x) < 2) return(NULL) + if (length(x) < 2) { + return(NULL) + } x[even_index(x)] } @@ -55,4 +59,3 @@ calls_sys <- function(sys_call, ...) { error <- system(sys_call, ...) } } - diff --git a/R/visit.R b/R/visit.R index e1fafcb87..a79fd82f2 100644 --- a/R/visit.R +++ b/R/visit.R @@ -17,7 +17,9 @@ NULL #' @rdname visit #' @keywords internal pre_visit <- function(pd_nested, funs) { - if (is.null(pd_nested)) return() + if (is.null(pd_nested)) { + return() + } pd_transformed <- visit_one(pd_nested, funs) pd_transformed$child <- map(pd_transformed$child, pre_visit, funs = funs) @@ -27,7 +29,9 @@ pre_visit <- function(pd_nested, funs) { #' @rdname visit #' @keywords internal post_visit <- function(pd_nested, funs) { - if (is.null(pd_nested)) return() + if (is.null(pd_nested)) { + return() + } pd_transformed <- pd_nested pd_transformed$child <- map(pd_transformed$child, post_visit, funs = funs) @@ -65,7 +69,9 @@ context_to_terminals <- function(pd_nested, outer_indent, outer_spaces, outer_indention_refs) { - if (is.null(pd_nested)) return() + if (is.null(pd_nested)) { + return() + } pd_transformed <- context_towards_terminals( pd_nested, outer_lag_newlines, outer_indent, outer_spaces, outer_indention_refs @@ -120,7 +126,9 @@ context_towards_terminals <- function(pd_nested, #' @param pd_nested A nested parse table. #' @keywords internal extract_terminals <- function(pd_nested) { - if (is.null(pd_nested)) return(pd) + if (is.null(pd_nested)) { + return(pd) + } pd_split <- split(pd_nested, seq_len(nrow(pd_nested))) bind_rows(if_else(pd_nested$terminal, pd_split, pd_nested$child)) } From 3db99742f3587edd43b61f0735019d5d07d3f44d Mon Sep 17 00:00:00 2001 From: lorenzwalthert Date: Fri, 3 May 2019 09:21:22 +0200 Subject: [PATCH 36/48] more minimal version dependencies --- DESCRIPTION | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index ee73a0f31..4427425f4 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -18,16 +18,16 @@ URL: https://github.com/r-lib/styler BugReports: https://github.com/r-lib/styler/issues Imports: backports (>= 1.1.0), - cli (>= 1.1.0), + cli, magrittr (>= 1.0.1), purrr (>= 0.2.3), - rematch2, + rematch2 (>= 2.0.1), rlang (>= 0.1.1), rprojroot (>= 1.1), tibble (>= 1.4.2), tools, - withr, - xfun + withr (>= 1.0.0), + xfun (>= 0.1) Suggests: data.tree (>= 0.1.6), dplyr, From c98d56d0e5d0e650af44c05e51d7a5e960fda43e Mon Sep 17 00:00:00 2001 From: lorenzwalthert Date: Fri, 3 May 2019 09:43:56 +0200 Subject: [PATCH 37/48] draft news --- NEWS.md | 79 ++++++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 70 insertions(+), 9 deletions(-) diff --git a/NEWS.md b/NEWS.md index 842873948..9bc1a1904 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,41 @@ +# styler 1.1.1 + +This is preimarily a maintenance release upon the request of the CRAN team +(#490). + +## Major changes + +- User can now control style configurations for styler Addins (#463, #500). Use + the `Set style` Addin. See `?styler::styler_addins` for details. + +## Minor changes + +- `style_pkg()` now also styles the "demo" directory by default (#453). + +- more minimal version dependencies on other packages and clean-up (9cfe808c, + 7077d440, 8ee486c6). + +- fix line-break styling around comma (#479). + +- fix roxygen code example styling indention (#455) and EOF spacing (#469). + +- fix indention for for loop edge case (#457) and comments in pipe chain + (#482). + +- more consistent styling of multi-line strings (#459). + +- remove slightly confusing warning about empty strings caused with roxygen code + examples and Rmd. + +- fix bug that may cause an error when the variable `text` in any name space + before styler on the search path was defined and did not have lenght 1 + (#484). + +- Removed right apastrophe to let package pass R CMD Check in strict Latin-1 + locale (#490, reason for release). + +Thanks to all contributors. + # styler 1.1.0 This release introduces new features and is fully backward-compatible. It also @@ -7,27 +45,36 @@ adapts to changes in the R parser committed into R devel (#419). * styler can now style roxygen code examples in the source code of package (#332) as well as Rnw files (#431). + * the print method for the output of `style_text()` (`print.vertical()`) now - returns syntax-highlighted code by default, controllable via the option + returns syntax-highlighted code by default, controllable via the option `styler.colored_print.vertical` (#417). + * the README was redesigned (#413). + * semi-colon expression that contained multiple assignments was fixed (#404). ## Minor Changes * cursor position is remembered for styling via Addin (#416). -* adapt spacing around tilde for multi-token expressions(#424) and brace - edge case (#425). + +* adapt spacing around tilde for multi-token expressions(#424) and brace edge + case (#425). + * only add brackets to piped function call if RHS is a symbol (#422). -* increase coverage again to over 90% (#412). + +* increase coverage again to over 90% (#412). + * move rule that turns single quotes into double quotes to token modifier in `tidyverse_style_guide() (#406). + * remove line-breaks before commas (#405). + * removed package dependency enc in favor of xfun (#442). -Thanks to all contributors for patches, issues and the like: -@jonmcalder, @krlmlr, @IndrajeetPatil, @kalibera, @Hasnep, @kiranmaiganji, -@dirkschumacher, @ClaytonJY, @wlandau, @maurolepore +Thanks to all contributors for patches, issues and the like: @jonmcalder, +@krlmlr, @IndrajeetPatil, @kalibera, @Hasnep, @kiranmaiganji, @dirkschumacher, +@ClaytonJY, @wlandau, @maurolepore # styler 1.0.2 @@ -36,6 +83,7 @@ This is a maintenance release without any breaking API changes. ## Major Changes * Fixed indention for named multi-line function calls (#372). + * Non-R code chunks in `.Rmd` files are now respected and won't get styled (#386). @@ -43,11 +91,16 @@ This is a maintenance release without any breaking API changes. * Fixing an edge case in which, if very long strings were present in the code, tokens could be replaced with wrong text (#384). + * Spacing around tilde in formulas depends now on whether there is a LHS in the formula (#379). + * Spaces are now also added around `EQ_SUB` (`=`) (#380). + * Added `CONTRIBUTING.md` to outline guidelines for contributing to styler. + * More informative error messages for parsing problems (#401, #400). + * Improved documentation (#387). Thanks to all contributors for patches, issues and the like: @katrinleinweber, @@ -62,11 +115,14 @@ This is a maintenance release without any breaking API changes. * Removed implicit `dplyr` dependency via `purrr:::map_dfr()` (thanks @jimhester, #324). + * Added required minimal version dependency for purr (`>= 0.2.3`) (#338). + * We rely on the tibble package which was optimized for speed in `v1.4.2` so styler should run ~2x as fast - [(#348)](https://github.com/tidyverse/tibble/pull/348). For that reason, styler - now depends on `tibble >= 1.4.2`. + [(#348)](https://github.com/tidyverse/tibble/pull/348). For that reason, + styler now depends on `tibble >= 1.4.2`. + * In the dependency `enc`, a bug was fixed that removed/changed non-ASCII characters. Hence, styler now depends on `enc >= 0.2` (#348). @@ -75,12 +131,16 @@ This is a maintenance release without any breaking API changes. * We're now recognizing and respecting more DSLs used in R comments: rplumber (`#*`, #306), shebang `#/!` (#345), knitr chunk headers for spinning (`#+` / `#-`, #362). + * Named arguments can stay on the first line if call is multi-line (#318). + * No space anymore with `tidyverse_style()` after `!!` since with `rlang 0.2`, `!!` now binds tighter (#322), spacing around `~` (#316), no space anymore around `^` (#308). + * Code chunks in Rmd documents that don't use the R engine are no longer formatted (#313). + * Various bug fixes and edge case improvements. Thanks to all contributors for patches, issues and the like: @devSJR, @klrmlr, @@ -158,3 +218,4 @@ specify_reindention( ) initialize_default_attributes(pd_flat) ``` + From 61a22356eb683ca7513c3a1b618903e6f58d00e7 Mon Sep 17 00:00:00 2001 From: lorenzwalthert Date: Fri, 3 May 2019 11:44:18 +0200 Subject: [PATCH 38/48] add thanks, re-order. --- NEWS.md | 51 +++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 37 insertions(+), 14 deletions(-) diff --git a/NEWS.md b/NEWS.md index 9bc1a1904..ce48754eb 100644 --- a/NEWS.md +++ b/NEWS.md @@ -5,36 +5,59 @@ This is preimarily a maintenance release upon the request of the CRAN team ## Major changes -- User can now control style configurations for styler Addins (#463, #500). Use - the `Set style` Addin. See `?styler::styler_addins` for details. +- Users can now control style configurations for styler Addins (#463, #500), + using the `Set style` Addin. See `?styler::styler_addins` for details. ## Minor changes -- `style_pkg()` now also styles the "demo" directory by default (#453). - -- more minimal version dependencies on other packages and clean-up (9cfe808c, - 7077d440, 8ee486c6). - -- fix line-break styling around comma (#479). - - fix roxygen code example styling indention (#455) and EOF spacing (#469). - fix indention for for loop edge case (#457) and comments in pipe chain (#482). - more consistent styling of multi-line strings (#459). - -- remove slightly confusing warning about empty strings caused with roxygen code - examples and Rmd. +- fix line-break styling around comma (#479). - fix bug that may cause an error when the variable `text` in any name space before styler on the search path was defined and did not have lenght 1 (#484). -- Removed right apastrophe to let package pass R CMD Check in strict Latin-1 +- `style_pkg()` now also styles the "demo" directory by default (#453). + +- more minimal version dependencies on other packages and clean-up (9cfe808c, + 7077d440, 8ee486c6). + +- remove slightly confusing warning about empty strings caused with roxygen code + examples and Rmd. + +- Removed right apostrophe to let package pass R CMD Check in strict Latin-1 locale (#490, reason for release). -Thanks to all contributors. +## Adaption of styler + +Since it's never been mentioned in the release notes, we also mention here +where else you can use styler functionality: + +* `usethis::use_tidy_style()` styles your project according to the tidyverse + style guide. +* `reprex::reprex(style = TRUE)` to prettify reprex code before printing. To + permanently use `style = TRUE` without specifying it every time, you can add the + following line to your `.Rprofile` (via `usethis::edit_r_profile()`): + `options(reprex.styler = TRUE)`. +* you can pretty-print your R code in RMarkdown reports without having styler + modifying the source. This feature is implemented as a code chunk option in + knitr. use `tidy = "styler"` in the header of a code chunks (e.g. ` ```{r + name-of-the-chunk, tidy = "styler"}`), or `knitr::opts_chunk$set(tidy = + "styler")` at the top of your RMarkdown script. +* pretty-printing of [drake](https://github.com/ropensci/drake) workflow data + frames with `drake::drake_plan_source()`. +* Adding styler as a fixer to the + [ale Plug-in](https://github.com/w0rp/ale/pull/2401#issuecomment-485942966) + for VIM. + + +Thanks to all contributors involved, in particular +[@ArthurPERE](https://github.com/ArthurPERE), [@hadley](https://github.com/hadley), [@igordot](https://github.com/igordot), [@IndrajeetPatil](https://github.com/IndrajeetPatil), [@jackwasey](https://github.com/jackwasey), [@jcrodriguez1989](https://github.com/jcrodriguez1989), [@jennybc](https://github.com/jennybc), [@jonmcalder](https://github.com/jonmcalder), [@katrinleinweber](https://github.com/katrinleinweber), [@krlmlr](https://github.com/krlmlr), [@lorenzwalthert](https://github.com/lorenzwalthert), [@michaelquinn32](https://github.com/michaelquinn32), [@msberends](https://github.com/msberends), [@raynamharris](https://github.com/raynamharris), [@riccardoporreca](https://github.com/riccardoporreca), [@rjake](https://github.com/rjake), [@Robinlovelace](https://github.com/Robinlovelace), [@skirmer](https://github.com/skirmer), [@thalesmello](https://github.com/thalesmello), [@tobiasgerstenberg](https://github.com/tobiasgerstenberg), [@tvatter](https://github.com/tvatter), [@wdearden](https://github.com/wdearden), [@wmayner](https://github.com/wmayner), and [@yech1990](https://github.com/yech1990). # styler 1.1.0 From 49d24898acde6b0e6803faccb99f745670136905 Mon Sep 17 00:00:00 2001 From: lorenzwalthert Date: Fri, 3 May 2019 11:46:38 +0200 Subject: [PATCH 39/48] tidy with stylermd --- NEWS.md | 47 ++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 38 insertions(+), 9 deletions(-) diff --git a/NEWS.md b/NEWS.md index ce48754eb..ccfc67baa 100644 --- a/NEWS.md +++ b/NEWS.md @@ -5,17 +5,20 @@ This is preimarily a maintenance release upon the request of the CRAN team ## Major changes -- Users can now control style configurations for styler Addins (#463, #500), +- Users can now control style configurations for styler Addins (#463, #500), using the `Set style` Addin. See `?styler::styler_addins` for details. ## Minor changes +- `%>%` almost always causes a line break now (#503). + - fix roxygen code example styling indention (#455) and EOF spacing (#469). - fix indention for for loop edge case (#457) and comments in pipe chain (#482). - more consistent styling of multi-line strings (#459). + - fix line-break styling around comma (#479). - fix bug that may cause an error when the variable `text` in any name space @@ -35,29 +38,55 @@ This is preimarily a maintenance release upon the request of the CRAN team ## Adaption of styler -Since it's never been mentioned in the release notes, we also mention here -where else you can use styler functionality: +Since it's never been mentioned in the release notes, we also mention here where +else you can use styler functionality: * `usethis::use_tidy_style()` styles your project according to the tidyverse style guide. + * `reprex::reprex(style = TRUE)` to prettify reprex code before printing. To - permanently use `style = TRUE` without specifying it every time, you can add the - following line to your `.Rprofile` (via `usethis::edit_r_profile()`): + permanently use `style = TRUE` without specifying it every time, you can add + the following line to your `.Rprofile` (via `usethis::edit_r_profile()`): `options(reprex.styler = TRUE)`. + * you can pretty-print your R code in RMarkdown reports without having styler modifying the source. This feature is implemented as a code chunk option in knitr. use `tidy = "styler"` in the header of a code chunks (e.g. ` ```{r name-of-the-chunk, tidy = "styler"}`), or `knitr::opts_chunk$set(tidy = "styler")` at the top of your RMarkdown script. + * pretty-printing of [drake](https://github.com/ropensci/drake) workflow data frames with `drake::drake_plan_source()`. -* Adding styler as a fixer to the - [ale Plug-in](https://github.com/w0rp/ale/pull/2401#issuecomment-485942966) - for VIM. +* Adding styler as a fixer to the [ale + Plug-in](https://github.com/w0rp/ale/pull/2401#issuecomment-485942966) for + VIM. Thanks to all contributors involved, in particular -[@ArthurPERE](https://github.com/ArthurPERE), [@hadley](https://github.com/hadley), [@igordot](https://github.com/igordot), [@IndrajeetPatil](https://github.com/IndrajeetPatil), [@jackwasey](https://github.com/jackwasey), [@jcrodriguez1989](https://github.com/jcrodriguez1989), [@jennybc](https://github.com/jennybc), [@jonmcalder](https://github.com/jonmcalder), [@katrinleinweber](https://github.com/katrinleinweber), [@krlmlr](https://github.com/krlmlr), [@lorenzwalthert](https://github.com/lorenzwalthert), [@michaelquinn32](https://github.com/michaelquinn32), [@msberends](https://github.com/msberends), [@raynamharris](https://github.com/raynamharris), [@riccardoporreca](https://github.com/riccardoporreca), [@rjake](https://github.com/rjake), [@Robinlovelace](https://github.com/Robinlovelace), [@skirmer](https://github.com/skirmer), [@thalesmello](https://github.com/thalesmello), [@tobiasgerstenberg](https://github.com/tobiasgerstenberg), [@tvatter](https://github.com/tvatter), [@wdearden](https://github.com/wdearden), [@wmayner](https://github.com/wmayner), and [@yech1990](https://github.com/yech1990). +[@ArthurPERE](https://github.com/ArthurPERE), +[@hadley](https://github.com/hadley), +[@igordot](https://github.com/igordot), +[@IndrajeetPatil](https://github.com/IndrajeetPatil), +[@jackwasey](https://github.com/jackwasey), +[@jcrodriguez1989](https://github.com/jcrodriguez1989), +[@jennybc](https://github.com/jennybc), +[@jonmcalder](https://github.com/jonmcalder), +[@katrinleinweber](https://github.com/katrinleinweber), +[@krlmlr](https://github.com/krlmlr), +[@lorenzwalthert](https://github.com/lorenzwalthert), +[@michaelquinn32](https://github.com/michaelquinn32), +[@msberends](https://github.com/msberends), +[@raynamharris](https://github.com/raynamharris), +[@riccardoporreca](https://github.com/riccardoporreca), +[@rjake](https://github.com/rjake), +[@Robinlovelace](https://github.com/Robinlovelace), +[@skirmer](https://github.com/skirmer), +[@thalesmello](https://github.com/thalesmello), +[@tobiasgerstenberg](https://github.com/tobiasgerstenberg), +[@tvatter](https://github.com/tvatter), +[@wdearden](https://github.com/wdearden), +[@wmayner](https://github.com/wmayner), and +[@yech1990](https://github.com/yech1990). # styler 1.1.0 From ee54f28a792eb5954a5f127be656619a679179d8 Mon Sep 17 00:00:00 2001 From: lorenzwalthert Date: Fri, 3 May 2019 12:10:18 +0200 Subject: [PATCH 40/48] spelling --- NEWS.md | 4 ++-- R/communicate.R | 2 +- R/environments.R | 4 ++-- R/parse.R | 2 +- R/roxygen-examples.R | 2 +- R/rules-other.R | 4 ++-- R/transform-files.R | 2 +- R/ui.R | 8 ++++---- man/can_verify_roundtrip.Rd | 2 +- man/communicate_warning.Rd | 2 +- man/has_crlf_as_first_line_sep.Rd | 2 +- man/if_for_while_part_requires_braces.Rd | 2 +- man/parser_version_set.Rd | 4 ++-- man/style_dir.Rd | 4 ++-- man/style_file.Rd | 4 ++-- man/style_pkg.Rd | 4 ++-- man/style_roxygen_code_example.Rd | 2 +- man/wrap_else_multiline_curly.Rd | 2 +- vignettes/performance_improvements.Rmd | 4 ++-- 19 files changed, 30 insertions(+), 30 deletions(-) diff --git a/NEWS.md b/NEWS.md index ccfc67baa..dc51217f9 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,6 +1,6 @@ # styler 1.1.1 -This is preimarily a maintenance release upon the request of the CRAN team +This is primarily a maintenance release upon the request of the CRAN team (#490). ## Major changes @@ -22,7 +22,7 @@ This is preimarily a maintenance release upon the request of the CRAN team - fix line-break styling around comma (#479). - fix bug that may cause an error when the variable `text` in any name space - before styler on the search path was defined and did not have lenght 1 + before styler on the search path was defined and did not have length 1 (#484). - `style_pkg()` now also styles the "demo" directory by default (#453). diff --git a/R/communicate.R b/R/communicate.R index b537aa094..3e9328b8a 100644 --- a/R/communicate.R +++ b/R/communicate.R @@ -1,6 +1,6 @@ #' Communicate a warning if necessary #' -#' If roundtrip verification was not possible, issue a warning to review the +#' If round trip verification was not possible, issue a warning to review the #' changes carefully. #' @param changed Boolean with indicating for each file whether or not it has #' been changed. diff --git a/R/environments.R b/R/environments.R index 85968b59d..0f1c616af 100755 --- a/R/environments.R +++ b/R/environments.R @@ -1,7 +1,7 @@ #' Work with parser versions #' #' The structure of the parse data affects many operations in styler. There was -#' unexpected behaviour of the parser that styler was initially designed to work +#' unexpected behavior of the parser that styler was initially designed to work #' around. Examples are [#187](https://github.com/r-lib/styler/issues/187), #' [#216](https://github.com/r-lib/styler/issues/216), #' [#100](https://github.com/r-lib/styler/issues/100) and others. With @@ -26,7 +26,7 @@ #' data. This does not necessarily mean that the version found is the #' actual version, but it *behaves* like it. For example, code that does not #' contain `EQ_ASSIGN` is parsed the same way with version 1 and 2. If the -#' behaviour is identical, the version is set to 1. +#' behavior is identical, the version is set to 1. #' @param version The version of the parser to be used. #' @param pd A parse table such as the output from #' `utils::getParseData(parse(text = text))`. diff --git a/R/parse.R b/R/parse.R index d51b8a680..0c933bf8e 100644 --- a/R/parse.R +++ b/R/parse.R @@ -42,7 +42,7 @@ parse_safely <- function(text, ...) { #' Check if a string uses CRLF EOLs #' #' @param message A message returned with `tryCatch()`. -#' @param initial_text The inital text to style. +#' @param initial_text The initial text to style. #' @keywords internal has_crlf_as_first_line_sep <- function(message, initial_text) { split <- strsplit(message, ":", fixed = TRUE)[[1]] diff --git a/R/roxygen-examples.R b/R/roxygen-examples.R index 434544b09..9e8ab5607 100644 --- a/R/roxygen-examples.R +++ b/R/roxygen-examples.R @@ -1,7 +1,7 @@ #' Style a roxygen code example that may contain dontrun and friends #' #' Parses roxygen2 comments into code, breaks it into dont* (dontrun, dontest, -#' dontshow) and run sections and processes each segment indicidually using +#' dontshow) and run sections and processes each segment individually using #' [style_roxygen_example_snippet()]. #' @inheritParams parse_transform_serialize_r #' @param example Roxygen example code. diff --git a/R/rules-other.R b/R/rules-other.R index 99f4751c9..cab70c484 100644 --- a/R/rules-other.R +++ b/R/rules-other.R @@ -88,7 +88,7 @@ wrap_multiline_curly <- function(pd, indent_by, space_after = 1, key_token) { #' Add curly braces to else #' #' Wrap the else part of a conditional expression into curly braces if not -#' already wraped into a such. +#' already wrapped into a such. #' @inheritParams wrap_multiline_curly #' @keywords internal wrap_else_multiline_curly <- function(pd, indent_by = 2, space_after = 0) { @@ -139,7 +139,7 @@ wrap_subexpr_in_curly <- function(pd, #' Check if if, for or while loop expression require a braces. #' -#' This is the case if they are multi-line and not yet wraped into curly +#' This is the case if they are multi-line and not yet wrapped into curly #' braces. #' @inheritParams wrap_multiline_curly #' @keywords internal diff --git a/R/transform-files.R b/R/transform-files.R index 6d45b03b8..d43f22683 100644 --- a/R/transform-files.R +++ b/R/transform-files.R @@ -238,7 +238,7 @@ apply_transformers <- function(pd_nested, transformers) { -#' Check whether a roundtrip verification can be carried out +#' Check whether a round trip verification can be carried out #' #' If scope was set to "line_breaks" or lower (compare [tidyverse_style()]), #' we can compare the expression before and after styling and return an error if diff --git a/R/ui.R b/R/ui.R index e950f8fb0..c06c6e7e6 100644 --- a/R/ui.R +++ b/R/ui.R @@ -33,12 +33,12 @@ NULL #' #' We suggest to first style with `scope < "tokens"` and inspect and commit #' changes, because these changes are guaranteed to leave the abstract syntax -#' tree (AST) unchanged. See section 'Roundtrip Validation' for details. +#' tree (AST) unchanged. See section 'Round trip validation' for details. #' #' Then, we suggest to style with `scope = "tokens"` (if desired) and carefully #' inspect the changes to make sure the AST is not changed in an unexpected way #' that invalidates code. -#' @section Roundtrip Validation: +#' @section Round trip validation: #' The following section describes when and how styling is guaranteed to #' yield correct code. #' @@ -156,7 +156,7 @@ style_text <- function(text, #' @inheritParams style_pkg #' @inheritSection transform_files Value #' @inheritSection style_pkg Warning -#' @inheritSection style_pkg Roundtrip Validation +#' @inheritSection style_pkg Round trip validation #' @family stylers #' @examples #' \dontrun{ @@ -211,7 +211,7 @@ prettify_any <- function(transformers, #' @inheritParams style_pkg #' @inheritSection transform_files Value #' @inheritSection style_pkg Warning -#' @inheritSection style_pkg Roundtrip Validation +#' @inheritSection style_pkg Round trip validation #' @examples #' # the following is identical but the former is more convenient: #' file <- tempfile("styler", fileext = ".R") diff --git a/man/can_verify_roundtrip.Rd b/man/can_verify_roundtrip.Rd index 51952b892..1bd993b1d 100644 --- a/man/can_verify_roundtrip.Rd +++ b/man/can_verify_roundtrip.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/transform-files.R \name{can_verify_roundtrip} \alias{can_verify_roundtrip} -\title{Check whether a roundtrip verification can be carried out} +\title{Check whether a round trip verification can be carried out} \usage{ can_verify_roundtrip(transformers) } diff --git a/man/communicate_warning.Rd b/man/communicate_warning.Rd index f8911dcb6..869901a88 100644 --- a/man/communicate_warning.Rd +++ b/man/communicate_warning.Rd @@ -14,7 +14,7 @@ been changed.} Needed for reverse engineering the scope.} } \description{ -If roundtrip verification was not possible, issue a warning to review the +If round trip verification was not possible, issue a warning to review the changes carefully. } \keyword{internal} diff --git a/man/has_crlf_as_first_line_sep.Rd b/man/has_crlf_as_first_line_sep.Rd index c511b0575..707844800 100644 --- a/man/has_crlf_as_first_line_sep.Rd +++ b/man/has_crlf_as_first_line_sep.Rd @@ -9,7 +9,7 @@ has_crlf_as_first_line_sep(message, initial_text) \arguments{ \item{message}{A message returned with \code{tryCatch()}.} -\item{initial_text}{The inital text to style.} +\item{initial_text}{The initial text to style.} } \description{ Check if a string uses CRLF EOLs diff --git a/man/if_for_while_part_requires_braces.Rd b/man/if_for_while_part_requires_braces.Rd index 654548ece..3dd7335cb 100644 --- a/man/if_for_while_part_requires_braces.Rd +++ b/man/if_for_while_part_requires_braces.Rd @@ -14,7 +14,7 @@ the expression to be wrapped (ignoring comments). For if and while loops, this is the closing "')'", for a for-loop it's "forcond".} } \description{ -This is the case if they are multi-line and not yet wraped into curly +This is the case if they are multi-line and not yet wrapped into curly braces. } \keyword{internal} diff --git a/man/parser_version_set.Rd b/man/parser_version_set.Rd index 2ad3e4a13..f5ae4a15b 100644 --- a/man/parser_version_set.Rd +++ b/man/parser_version_set.Rd @@ -20,7 +20,7 @@ parser_version_find(pd) } \description{ The structure of the parse data affects many operations in styler. There was -unexpected behaviour of the parser that styler was initially designed to work +unexpected behavior of the parser that styler was initially designed to work around. Examples are \href{https://github.com/r-lib/styler/issues/187}{#187}, \href{https://github.com/r-lib/styler/issues/216}{#216}, \href{https://github.com/r-lib/styler/issues/100}{#100} and others. With @@ -47,7 +47,7 @@ environment \code{env_current}. data. This does not necessarily mean that the version found is the actual version, but it \emph{behaves} like it. For example, code that does not contain \code{EQ_ASSIGN} is parsed the same way with version 1 and 2. If the -behaviour is identical, the version is set to 1. +behavior is identical, the version is set to 1. } } \keyword{internal} diff --git a/man/style_dir.Rd b/man/style_dir.Rd index 062f940ad..3976cf43a 100644 --- a/man/style_dir.Rd +++ b/man/style_dir.Rd @@ -53,14 +53,14 @@ that are under version control or to create a backup copy. We suggest to first style with \code{scope < "tokens"} and inspect and commit changes, because these changes are guaranteed to leave the abstract syntax -tree (AST) unchanged. See section 'Roundtrip Validation' for details. +tree (AST) unchanged. See section 'Round trip validation' for details. Then, we suggest to style with \code{scope = "tokens"} (if desired) and carefully inspect the changes to make sure the AST is not changed in an unexpected way that invalidates code. } -\section{Roundtrip Validation}{ +\section{Round trip validation}{ The following section describes when and how styling is guaranteed to yield correct code. diff --git a/man/style_file.Rd b/man/style_file.Rd index 0d90909f2..a55c6fe9d 100644 --- a/man/style_file.Rd +++ b/man/style_file.Rd @@ -48,14 +48,14 @@ that are under version control or to create a backup copy. We suggest to first style with \code{scope < "tokens"} and inspect and commit changes, because these changes are guaranteed to leave the abstract syntax -tree (AST) unchanged. See section 'Roundtrip Validation' for details. +tree (AST) unchanged. See section 'Round trip validation' for details. Then, we suggest to style with \code{scope = "tokens"} (if desired) and carefully inspect the changes to make sure the AST is not changed in an unexpected way that invalidates code. } -\section{Roundtrip Validation}{ +\section{Round trip validation}{ The following section describes when and how styling is guaranteed to yield correct code. diff --git a/man/style_pkg.Rd b/man/style_pkg.Rd index 01e72ef3b..2463dd0f0 100644 --- a/man/style_pkg.Rd +++ b/man/style_pkg.Rd @@ -45,14 +45,14 @@ that are under version control or to create a backup copy. We suggest to first style with \code{scope < "tokens"} and inspect and commit changes, because these changes are guaranteed to leave the abstract syntax -tree (AST) unchanged. See section 'Roundtrip Validation' for details. +tree (AST) unchanged. See section 'Round trip validation' for details. Then, we suggest to style with \code{scope = "tokens"} (if desired) and carefully inspect the changes to make sure the AST is not changed in an unexpected way that invalidates code. } -\section{Roundtrip Validation}{ +\section{Round trip validation}{ The following section describes when and how styling is guaranteed to yield correct code. diff --git a/man/style_roxygen_code_example.Rd b/man/style_roxygen_code_example.Rd index 1b9248728..ebff00164 100644 --- a/man/style_roxygen_code_example.Rd +++ b/man/style_roxygen_code_example.Rd @@ -13,7 +13,7 @@ style_roxygen_code_example(example, transformers) } \description{ Parses roxygen2 comments into code, breaks it into dont* (dontrun, dontest, -dontshow) and run sections and processes each segment indicidually using +dontshow) and run sections and processes each segment individually using \code{\link[=style_roxygen_example_snippet]{style_roxygen_example_snippet()}}. } \section{Hierarchy}{ diff --git a/man/wrap_else_multiline_curly.Rd b/man/wrap_else_multiline_curly.Rd index b050a144a..8d405f75c 100644 --- a/man/wrap_else_multiline_curly.Rd +++ b/man/wrap_else_multiline_curly.Rd @@ -16,6 +16,6 @@ braces. Used for unindention.} } \description{ Wrap the else part of a conditional expression into curly braces if not -already wraped into a such. +already wrapped into a such. } \keyword{internal} diff --git a/vignettes/performance_improvements.Rmd b/vignettes/performance_improvements.Rmd index 58ae9611c..1f87e1441 100644 --- a/vignettes/performance_improvements.Rmd +++ b/vignettes/performance_improvements.Rmd @@ -27,7 +27,7 @@ microbenchmark::microbenchmark( #> base 4.131253 4.131253 4.172017 4.172017 4.212781 4.212781 2 ``` -Replacing mutate statments. +Replacing mutate statements. ```{r} microbenchmark::microbenchmark( base = style_file("tests/testthat/indention_multiple/overall-in.R"), @@ -50,7 +50,7 @@ microbenchmark::microbenchmark( #> base 2.18097 2.184721 2.225294 2.200893 2.241799 2.318089 5 ``` -Dropping unnecessary select and arrange stuffstatments +Dropping unnecessary select statements and arrange stuff. ```{r} microbenchmark::microbenchmark( base = style_file("tests/testthat/indention_multiple/overall-in.R"), From f270beff258123aa48b069291b10b32502439022 Mon Sep 17 00:00:00 2001 From: lorenzwalthert Date: Mon, 6 May 2019 21:14:15 +0200 Subject: [PATCH 41/48] remove badges from readme for CRAN submission --- README.Rmd | 4 +++- README.md | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/README.Rmd b/README.Rmd index 3d5325705..dc4fac75c 100644 --- a/README.Rmd +++ b/README.Rmd @@ -16,6 +16,7 @@ knitr::opts_chunk$set( # styler + + The goal of styler is to provide non-invasive pretty-printing of R source code while adhering to the [tidyverse](http://style.tidyverse.org) formatting rules. styler can be customized to format code according to other style guides too. diff --git a/README.md b/README.md index c1082851a..dabc8db1a 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,7 @@ # styler + The goal of styler is to provide non-invasive pretty-printing of R source code while adhering to the From 649916ba58d7b11814dd3450bc184e4678cc844d Mon Sep 17 00:00:00 2001 From: lorenzwalthert Date: Mon, 6 May 2019 21:35:29 +0200 Subject: [PATCH 42/48] polish news --- NEWS.md | 33 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/NEWS.md b/NEWS.md index dc51217f9..8e80d2f86 100644 --- a/NEWS.md +++ b/NEWS.md @@ -7,34 +7,31 @@ This is primarily a maintenance release upon the request of the CRAN team - Users can now control style configurations for styler Addins (#463, #500), using the `Set style` Addin. See `?styler::styler_addins` for details. +- `%>%` almost always causes a line break now (#503) for `strict = TRUE`. ## Minor changes -- `%>%` almost always causes a line break now (#503). - -- fix roxygen code example styling indention (#455) and EOF spacing (#469). - -- fix indention for for loop edge case (#457) and comments in pipe chain - (#482). +- `style_pkg()` now also styles the "demo" directory by default (#453). -- more consistent styling of multi-line strings (#459). +- multi-line strings are now styled more consistently (#459). -- fix line-break styling around comma (#479). +- indention in roxygen code example styling (#455) and EOF spacing (#469) was + fixed. -- fix bug that may cause an error when the variable `text` in any name space - before styler on the search path was defined and did not have length 1 - (#484). +- indention for for loop edge case (#457) and comments in pipe chain (#482) + were fixed. -- `style_pkg()` now also styles the "demo" directory by default (#453). +- line-break styling around comma is improved (#479). -- more minimal version dependencies on other packages and clean-up (9cfe808c, - 7077d440, 8ee486c6). +- bug that can cause an error when the variable `text` in any name space + before styler on the search path was defined and did not have length 1 is + fixed (#484). -- remove slightly confusing warning about empty strings caused with roxygen code - examples and Rmd. +- slightly confusing warning about empty strings caused with roxygen code + examples and Rmd was removed. -- Removed right apostrophe to let package pass R CMD Check in strict Latin-1 - locale (#490, reason for release). +- right apostrophe to let package pass R CMD Check in strict Latin-1 + locale was removed (#490, reason for release). ## Adaption of styler From 63a194654787e861fe6481f99ffa9c0983d2df0b Mon Sep 17 00:00:00 2001 From: lorenzwalthert Date: Mon, 6 May 2019 21:37:29 +0200 Subject: [PATCH 43/48] bump version number --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 4427425f4..fc476d147 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: styler Type: Package Title: Non-Invasive Pretty Printing of R Code -Version: 1.1.0.9000 +Version: 1.1.1 Authors@R: c(person(given = "Kirill", family = "Müller", From ff0b26fe2f4426adecdd8279aeb18e3d62f3f07f Mon Sep 17 00:00:00 2001 From: lorenzwalthert Date: Mon, 6 May 2019 21:55:50 +0200 Subject: [PATCH 44/48] again require cli >= 1.1.0 --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index fc476d147..63e388a60 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -18,7 +18,7 @@ URL: https://github.com/r-lib/styler BugReports: https://github.com/r-lib/styler/issues Imports: backports (>= 1.1.0), - cli, + cli (>= 1.1.0), magrittr (>= 1.0.1), purrr (>= 0.2.3), rematch2 (>= 2.0.1), From b5d8cc866a5dcab6707daf94ab35e0f79fc2b31a Mon Sep 17 00:00:00 2001 From: lorenzwalthert Date: Mon, 6 May 2019 22:49:10 +0200 Subject: [PATCH 45/48] finish cran release notes. --- cran-comments.md | 31 +++++++++++++------------------ 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/cran-comments.md b/cran-comments.md index 058dfd6f6..c71be8dc5 100644 --- a/cran-comments.md +++ b/cran-comments.md @@ -1,8 +1,9 @@ ## Test environments -* local OS X install (10.13.3): R 3.5 -* ubuntu 14.04 (on travis-ci): R devel, R 3.5, R 3.4, R 3.1, R 3.2 -* win-builder: R devel, R 3.5 +* local OS X install (10.14.3): R 3.6 +* ubuntu 14.04 (on travis-ci): R devel, R 3.5, R 3.4, R 3.2 +* r-hub: R devel (Windows and Linux) and R release (Windows and Linux). +* win-builder: R devel, R 3.6 ## R CMD check results @@ -10,19 +11,13 @@ ## Downstream Dependencies -I also ran R CMD check on all downstream dependencies of styler. The -downstream dependencies are: autothresholdr, crunch, detrendr, drake, nandb, -pmatch, reprex, shinydashboardPlus, usethis, exampletestr, languageserver, -sealr. +I also ran R CMD check on all downstream dependencies of styler using the +revdepcheck package. The +downstream dependencies are: exampletestr, languageserver, autothresholdr, +crunch, detrendr, drake, knitr, nandb, reprex, shinydashboardPlus, +tradestatistics, usethis. -All of them **except** drake, pass R CMD check with - -0 ERRORS | 0 WARNINGS | 0 NOTES - -The drake devel version passes the reverse dependency check with - -0 ERRORS | 0 WARNINGS | 0 NOTES - -The problem causing an R CMD CHECK ERROR for drake was resolved in -https://github.com/ropensci/drake/commit/87e473d9fb4b54db3d7adc371003ab973a4d1273 -and a new release of drake is planned in December (https://github.com/ropensci/drake/issues/584). +All of them finished R CMD CHECK with the same number of ERRORS, WARNINGS and +NOTES as with the current CRAN version of styler, which means the new +submission of styler does not introduce any ERRORS, WARNINGS and NOTES in +downstream dependencies. From d74df8926a050ee1d5b05062bafa207de3f4c1b0 Mon Sep 17 00:00:00 2001 From: lorenzwalthert Date: Mon, 6 May 2019 22:52:51 +0200 Subject: [PATCH 46/48] fix comments --- cran-comments.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cran-comments.md b/cran-comments.md index c71be8dc5..e3c6504be 100644 --- a/cran-comments.md +++ b/cran-comments.md @@ -1,8 +1,8 @@ ## Test environments * local OS X install (10.14.3): R 3.6 -* ubuntu 14.04 (on travis-ci): R devel, R 3.5, R 3.4, R 3.2 -* r-hub: R devel (Windows and Linux) and R release (Windows and Linux). +* ubuntu 14.04 (on travis-ci): R devel, R 3.6, R 3.5, R 3.4, R 3.2 +* r-hub: R devel (Windows and Linux) and R 3.6 (Windows and Linux). * win-builder: R devel, R 3.6 ## R CMD check results From 5a463fe8b4dece5b9c0ff7c84bbdbb8dd6fe86f7 Mon Sep 17 00:00:00 2001 From: lorenzwalthert Date: Tue, 7 May 2019 00:30:32 +0200 Subject: [PATCH 47/48] make this the dev version, re-add badges, fix news, --- DESCRIPTION | 2 +- NEWS.md | 2 +- README.Rmd | 3 +-- README.md | 2 -- 4 files changed, 3 insertions(+), 6 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 63e388a60..28afc5aa6 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: styler Type: Package Title: Non-Invasive Pretty Printing of R Code -Version: 1.1.1 +Version: 1.1.1.9000 Authors@R: c(person(given = "Kirill", family = "Müller", diff --git a/NEWS.md b/NEWS.md index 8e80d2f86..57eb1c145 100644 --- a/NEWS.md +++ b/NEWS.md @@ -7,7 +7,7 @@ This is primarily a maintenance release upon the request of the CRAN team - Users can now control style configurations for styler Addins (#463, #500), using the `Set style` Addin. See `?styler::styler_addins` for details. -- `%>%` almost always causes a line break now (#503) for `strict = TRUE`. +- `%>%` almost always causes a line break now for `strict = TRUE` (#503). ## Minor changes diff --git a/README.Rmd b/README.Rmd index dc4fac75c..5ee1b96d3 100644 --- a/README.Rmd +++ b/README.Rmd @@ -16,7 +16,6 @@ knitr::opts_chunk$set( # styler - + The goal of styler is to provide non-invasive pretty-printing of R source code while adhering to the [tidyverse](http://style.tidyverse.org) formatting rules. diff --git a/README.md b/README.md index dabc8db1a..c1082851a 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,6 @@ # styler - The goal of styler is to provide non-invasive pretty-printing of R source code while adhering to the From a98b2894590121f69ee0e2d7b996f83e55f5811b Mon Sep 17 00:00:00 2001 From: lorenzwalthert Date: Tue, 7 May 2019 00:48:10 +0200 Subject: [PATCH 48/48] another news fix --- NEWS.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/NEWS.md b/NEWS.md index 57eb1c145..04b3e506f 100644 --- a/NEWS.md +++ b/NEWS.md @@ -7,6 +7,10 @@ This is primarily a maintenance release upon the request of the CRAN team - Users can now control style configurations for styler Addins (#463, #500), using the `Set style` Addin. See `?styler::styler_addins` for details. + +- `return()` is now always put in braces and put on a new line when used in + a conditional statement (#492). + - `%>%` almost always causes a line break now for `strict = TRUE` (#503). ## Minor changes