-
Notifications
You must be signed in to change notification settings - Fork 73
Code in braces added to "if" not indented properly #257
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I think the problem is that reprex::reprex_info()
#> Created by the reprex package v0.1.1.9000 on 2017-10-25
styler:::create_tree("
if (x >= 52) {
2 +1 \n } else {\n 5
}")
#> levelName
#> 1 ROOT (token: short_text [lag_newlines/spaces] {id})
#> 2 °--expr: [0/0] {41}
#> 3 ¦--IF: if [0/1] {3}
#> 4 ¦--'(': ( [0/0] {4}
#> 5 ¦--expr: [0/0] {11}
#> 6 ¦ ¦--expr: [0/1] {7}
#> 7 ¦ ¦ °--SYMBOL: x [0/0] {5}
#> 8 ¦ ¦--GE: >= [0/1] {6}
#> 9 ¦ °--expr: [0/0] {9}
#> 10 ¦ °--NUM_CONST: 52 [0/0] {8}
#> 11 ¦--')': ) [0/1] {10}
#> 12 ¦--expr: [0/1] {26}
#> 13 ¦ ¦--'{': { [0/2] {13}
#> 14 ¦ ¦--expr: [1/1] {21}
#> 15 ¦ ¦ ¦--expr: [0/1] {16}
#> 16 ¦ ¦ ¦ °--NUM_CONST: 2 [0/0] {15}
#> 17 ¦ ¦ ¦--'+': + [0/0] {17}
#> 18 ¦ ¦ °--expr: [0/0] {19}
#> 19 ¦ ¦ °--NUM_CONST: 1 [0/0] {18}
#> 20 ¦ °--'}': } [1/0] {24}
#> 21 ¦--ELSE: else [0/1] {27}
#> 22 °--expr: [0/0] {38}
#> 23 ¦--'{': { [0/1] {29}
#> 24 ¦--expr: [1/0] {32}
#> 25 ¦ °--NUM_CONST: 5 [0/0] {31}
#> 26 °--'}': } [1/0] {36} However, when I added the brace insertion feature, I did not think of that and since it is also the easiest to implement, I just wrapped the children of expression id 20 below in braces, so the tree has no intermediate child. reprex::reprex_info()
#> Created by the reprex package v0.1.1.9000 on 2017-10-25
styler:::create_tree("
if (x >= 52)
2 +1 else \n 5
")
#> levelName
#> 1 ROOT (token: short_text [lag_newlines/spaces] {id})
#> 2 °--expr: [0/0] {27}
#> 3 ¦--IF: if [0/1] {3}
#> 4 ¦--'(': ( [0/0] {4}
#> 5 ¦--expr: [0/0] {11}
#> 6 ¦ ¦--expr: [0/1] {7}
#> 7 ¦ ¦ °--SYMBOL: x [0/0] {5}
#> 8 ¦ ¦--GE: >= [0/1] {6}
#> 9 ¦ °--expr: [0/0] {9}
#> 10 ¦ °--NUM_CONST: 52 [0/0] {8}
#> 11 ¦--')': ) [0/2] {10}
#> 12 ¦--expr: [1/1] {20}
#> 13 ¦ ¦--expr: [0/1] {15}
#> 14 ¦ ¦ °--NUM_CONST: 2 [0/0] {14}
#> 15 ¦ ¦--'+': + [0/0] {16}
#> 16 ¦ °--expr: [0/0] {18}
#> 17 ¦ °--NUM_CONST: 1 [0/0] {17}
#> 18 ¦--ELSE: else [0/1] {19}
#> 19 °--expr: [1/0] {24}
#> 20 °--NUM_CONST: 5 [0/0] {23} The tree then looks like this #> levelName
#> 1 ROOT (token: short_text [lag_newlines/spaces] {id})
#> 2 °--expr: [0/0] {27}
#> 3 ¦--IF: if [0/1] {3}
#> 4 ¦--'(': ( [0/0] {4}
#> 5 ¦--expr: [0/0] {11}
#> 6 ¦ ¦--expr: [0/1] {7}
#> 7 ¦ ¦ °--SYMBOL: x [0/0] {5}
#> 8 ¦ ¦--GE: >= [0/1] {6}
#> 9 ¦ °--expr: [0/0] {9}
#> 10 ¦ °--NUM_CONST: 52 [0/0] {8}
#> 11 ¦--')': ) [0/2] {10}
#> 12 ¦--expr: [1/1] {20}
#> ¦ ¦--'{': ...
#> 13 ¦ ¦--expr: [0/1] {15}
#> 14 ¦ ¦ °--NUM_CONST: 2 [0/0] {14}
#> 15 ¦ ¦--'+': + [0/0] {16}
#> 16 ¦ °--expr: [0/0] {18}
#> 17 ¦ °--NUM_CONST: 1 [0/0] {17}
#> ¦ ¦--'{': ...
#> 18 ¦--ELSE: else [0/1] {19}
#> 19 °--expr: [1/0] {24}
#> 20 °--NUM_CONST: 5 [0/0] {23} Bottom line: Probably need to adapt |
I think I get the general idea. Do we still need the original |
Closed with #263. |
Uh oh!
There was an error while loading. Please reload this page.
Maybe we need to add braces before doing other transformations?
The text was updated successfully, but these errors were encountered: