-
Notifications
You must be signed in to change notification settings - Fork 2
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
write_mutated_pkg: replacing lines instead of writing new lines? #9
Comments
this is complicated. the way R parses functions, it doesn't maintain the same number of lines, e.g., remotes::install_github("ropenscilabs/astr")
library(astr)
foo <- function(x = NULL) {
if (!is.null(x)) x * 10
return(x)
}
w = ast_decompose(foo)
fun = ast_recompose(w)
cat(fun)
#> function (x = NULL)
#> {
#> if (!is.null(x))
#> x * 10
#> return(x)
#> } In this example, the if statement is all on one line, which isn't that uncommon. So the recomposed function adds an additional line, with the if statement over 2 lines. If we wanted to re-insert mutated functions into the original file structure they were pulled from, we'd need to account for these additional lines and push any further lines down. |
coming back to later |
Right now
write_mutated_pkg
makes completely new R files, and writes the mutated fxns into those files. Maybe copy over R files from original location, and use line number/column position to replace lines - so that roxygen tags/constants/etc are retained as those things could affect outcomesThe text was updated successfully, but these errors were encountered: