Skip to content
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

handle autocompletion of C++Object #1655

Merged
merged 1 commit into from Oct 24, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
29 changes: 14 additions & 15 deletions src/cpp/session/modules/SessionRCompletions.R
Expand Up @@ -1134,22 +1134,21 @@ assign(x = ".rs.acCompletionTypes",
dollarNamesMethod <- .rs.getDollarNamesMethod(object, TRUE, envir = envir)
if (is.function(dollarNamesMethod))
{
allNames <- dollarNamesMethod(object)
allNames <- dollarNamesMethod(object, "")

# rJava will include closing parentheses as part of the
# completion list -- clean those up and use them to infer
# symbol types
if ("rJava" %in% loadedNamespaces() &&
identical(environment(dollarNamesMethod), asNamespace("rJava")))
{
types <- ifelse(
grepl("[()]$", allNames),
.rs.acCompletionTypes$FUNCTION,
.rs.acCompletionTypes$UNKNOWN
)
allNames <- gsub("[()]*$", "", allNames)
attr(allNames, "types") <- types
}
# detect completion systems that append closing parentheses
# to the completion item, and assume those are functions
# rJava and Rcpp will do this for some objects
# for example:
# - rJava:::.DollarNames.jobjref
# - Rcpp:::.DollarNames.C++Object
types <- ifelse(
grepl("[()]\\s*$", allNames),
.rs.acCompletionTypes$FUNCTION,
.rs.acCompletionTypes$UNKNOWN
)
allNames <- gsub("[()]*\\s*$", "", allNames)
attr(allNames, "types") <- as.integer(types)

# check for custom helpHandler
helpHandler <- attr(allNames, "helpHandler", exact = TRUE)
Expand Down