Skip to content

Commit

Permalink
work around 'devtools::load_all()' clobbering imports
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinushey committed Apr 7, 2016
1 parent 5ee501f commit 940b245
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion src/cpp/session/modules/SessionRCompletions.R
Original file line number Diff line number Diff line change
Expand Up @@ -1392,7 +1392,6 @@ assign(x = ".rs.acCompletionTypes",
return(.rs.emptyCompletions())

n <- vapply(symbols, function(x) length(x[[1]]), USE.NAMES = FALSE, FUN.VALUE = numeric(1))
total <- sum(n)

output <- list(
exports = unlist(lapply(symbols, `[[`, "exports"), use.names = FALSE),
Expand Down Expand Up @@ -2429,6 +2428,26 @@ assign(x = ".rs.acCompletionTypes",
error = function(e) NULL
)

# workaround for devtools::load_all() clobbering the
# namespace imports
if (length(importCompletions) && is.null(names(importCompletions))) {
try({
env <- new.env(parent = emptyenv())
for (el in importCompletions) {
# Length one element: get all exports from that package
if (length(el) == 1) {
env[[el]] <- c(env[[el]], getNamespaceExports(asNamespace(el)))
}

# Length >1 element: 'importFrom()'.
else if (length(el) > 1) {
env[[el]] <- c(env[[el]], tail(el, n = -1))
}
}
importCompletions <- as.list(env)
}, silent = TRUE)
}

# remove 'base' element if it's just TRUE
if (length(importCompletions))
{
Expand Down

0 comments on commit 940b245

Please sign in to comment.