r-lib / R6

Encapsulated object-oriented programming for R
https://R6.r-lib.org
Other
405 stars 56 forks source link

autocomplete for Class$new() parameters. #104

Closed dfalbel closed 4 years ago

dfalbel commented 7 years ago

It would be great to have autocomplete for the initialize method.

R6 <- R6Class("R6",
  public = list(
    x = NULL,
    initialize = function(x = 1) self$x <- x,
    getx = function() self$x,
    inc = function(n = 1) self$x <- x + n
  )
)

In this example R6$new() autocompletes with ..., it would be nice to show x.

hadley commented 7 years ago

This would be fairly easy to do if you don't mind an rlang dep, but not too hard to do without it.

wch commented 7 years ago

I'd prefer to keep R6 dependency-free, especially if the dependency package requires compilation.

wch commented 4 years ago

FWIW, I just learned that the RStudio IDE has had autocomplete support for $new() for some time now. https://github.com/rstudio/rstudio/blob/2a9eaa49/src/cpp/session/modules/SessionRCompletions.R#L654-L658