Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,4 @@ importFrom(rlang,is_installed)
importFrom(rlang,seq2)
importFrom(rlang,set_names)
importFrom(rlang,warn)
importFrom(vctrs,vec_rbind)
2 changes: 1 addition & 1 deletion R/rules-tokens.R
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ fix_quotes <- function(pd_flat) {
return(pd_flat)
}

pd_flat$text[str_const] <- map(pd_flat$text[str_const], fix_quotes_one)
pd_flat$text[str_const] <- map_chr(pd_flat$text[str_const], fix_quotes_one)
pd_flat
}

Expand Down
12 changes: 6 additions & 6 deletions R/styler-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@
#' style_text("a%>%b; a", scope = "tokens")
"_PACKAGE"

## styler namespace: start
## usethis namespace: start
#'
#' @importFrom rlang abort warn seq2 is_installed "%||%" set_names
#' @importFrom purrr map map_lgl map_int map_chr map2 map2_chr map_at pmap pwalk
#' @importFrom purrr compact partial flatten flatten_int flatten_chr
#' @importFrom magrittr "%>%"
#'
## styler namespace: end
#' @importFrom purrr compact partial flatten flatten_int flatten_chr
#' @importFrom purrr map map_lgl map_int map_chr map2 map2_chr map_at pmap pwalk
#' @importFrom rlang abort warn seq2 is_installed "%||%" set_names
#' @importFrom vctrs vec_rbind
## usethis namespace: end
NULL


Expand Down
4 changes: 3 additions & 1 deletion R/transform-block.R
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ parse_transform_serialize_r_block <- function(pd_nested,
base_indention) {
if (!all(pd_nested$is_cached, na.rm = TRUE) || !cache_is_activated()) {
transformed_pd <- apply_transformers(pd_nested, transformers)
flattened_pd <- post_visit_one(transformed_pd, extract_terminals) %>%
flattened_pd <-
# Special transformer: returns a list of pd
vec_rbind(!!!post_visit_one(transformed_pd, extract_terminals)) %>%
enrich_terminals(transformers$use_raw_indention) %>%
apply_ref_indention() %>%
set_regex_indention(
Expand Down
19 changes: 13 additions & 6 deletions R/visit.R
Original file line number Diff line number Diff line change
Expand Up @@ -188,12 +188,19 @@ context_towards_terminals <- function(pd_nested,
#' @param pd_nested A nested parse table.
#' @keywords internal
extract_terminals <- function(pd_nested) {
bind_rows(
ifelse(pd_nested$terminal | pd_nested$is_cached,
split(pd_nested, seq_len(nrow(pd_nested))),
pd_nested$child
)
)
terminal <- pd_nested$terminal
is_cached <- pd_nested$is_cached

child <- pd_nested$child

for (i in seq_len(nrow(pd_nested))) {
if (terminal[[i]] || is_cached[[i]]) {
child[[i]] <- list(pd_nested[i, ])
}
}

# child is a list of data frame lists here
unlist(unname(child), recursive = FALSE)
}

#' Enrich flattened parse table
Expand Down