Relocate the expressions containing the token EQ_ASSIGN within the nested parse table
Although syntactically identical, utils::getParseData()
does not produce
the same hierarchy of the parse table (parent and id relationship) for <-
and =
(See 'Examples').
This is considered to be a bug and causes problems because the
nested parse table constructed with compute_parse_data_nested()
is not
consistent if EQ_ASSIGN
occurs in the expression to style. In particular,
EQ_ASSIGN
and the tokens to its left and right are located too high up in
the hierarchy of the nested parse data. Hence, this function wraps the
sub-expression into an expression, similar to wrap_expr_in_curly()
.
Since wrap_expr_in_curly()
is called from within a visitor
(and relocate_eq_assign()
not), we need to
wrap the the implementation relocate_eq_assign_nest()
that operates on
nests into a visitor call.
relocate_eq_assign(pd)
pd |
A parse table. |
styler:::get_parse_data("a <- b <- 3") styler:::get_parse_data("a = b = 3") styler:::get_parse_data( "x = 5 if(x >= 5) y = TRUE else y = FALSE", ) styler:::get_parse_data( "x <- 5 if(x >= 5) y <- TRUE else y <- FALSE", )
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.