diff --git a/DESCRIPTION b/DESCRIPTION index fe9e89d..1f83aad 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: typetracer Title: Trace Function Parameter Types -Version: 0.1.1.035 +Version: 0.1.1.036 Authors@R: c( person("Mark", "Padgham", , "mark.padgham@email.com", role = c("aut", "cre"), comment = c(ORCID = "0000-0003-2172-5265")), diff --git a/R/tracer-define.R b/R/tracer-define.R index 08cf77c..8acc777 100644 --- a/R/tracer-define.R +++ b/R/tracer-define.R @@ -59,6 +59,11 @@ typetracer_header <- function () { utils::getFromNamespace ("process_back_trace", "typetracer") # Initial trace has to be called in this environment: trace_dat <- rlang::trace_back (bottom = fn_env) + + # Uncomment this for debugging, and add "trace_dat" to "trace_objs" at start + # of "load_traces" fn: + # typetracer_env$data$trace_dat <- trace_dat + typetracer_env$data$call_envs <- typetracer_env$process_back_trace (trace_dat, typetracer_env$fn_name) @@ -185,8 +190,7 @@ process_back_trace <- function (trace_dat, fn_name) { # includes any embedded environments of those, such as testthat expectations # or 'tryCatch' calls. Those will then be first on the call_env list in the # final reduction to one row, below. - tt <- as.data.frame (trace_dat) - has_fn_name <- vapply (tt$call, function (i) { + has_fn_name <- vapply (trace_dat$call, function (i) { pd <- tryCatch ( utils::getParseData (parse (text = i)), error = function (e) NULL @@ -198,7 +202,8 @@ process_back_trace <- function (trace_dat, fn_name) { fns <- pd$text [index] return (any (fns == fn_name)) }, logical (1L)) - trace_dat <- trace_dat [which (has_fn_name), ] + parent_level <- sort (unique (trace_dat$parent [which (has_fn_name)])) + trace_dat <- trace_dat [which (trace_dat$parent %in% parent_level), ] if (nrow (trace_dat) == 0L) { return (call_envs) } diff --git a/codemeta.json b/codemeta.json index 55ced0f..b444ac2 100644 --- a/codemeta.json +++ b/codemeta.json @@ -11,7 +11,7 @@ "codeRepository": "https://github.com/mpadge/typetracer", "issueTracker": "https://github.com/mpadge/typetracer/issues", "license": "https://spdx.org/licenses/MIT", - "version": "0.1.1.035", + "version": "0.1.1.036", "programmingLanguage": { "@type": "ComputerLanguage", "name": "R",