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

Setting breakpoints in methods #236

Open
dmurdoch opened this issue Nov 10, 2021 · 0 comments
Open

Setting breakpoints in methods #236

dmurdoch opened this issue Nov 10, 2021 · 0 comments

Comments

@dmurdoch
Copy link

The debugging vignette says RStudio debugging doesn't work with R6 methods. A step towards this would be to allow breakpoints to be set in methods by location, similar to the utils::setBreakpoint function.

I've written a simple version of this, which appears as a generator method: https://github.com/dmurdoch/R6/blob/b233e0a2f3f6d922df753416729992000d1f5f73/R/generator_funs.R#L105 .

The function would also work on an instance, but I haven't added it: I'm not sure all users would want a new setBreakpoint method to show up. Alternatively, the standard function can be used on instance as

setBreakpoint("filename#line", envir = instance)

though I don't think this will see private methods.

In order to allow breakpoints to be set in RStudio, it would also need to identify ranges of code that are within the
R6Class definition. This could be tricky, because function definitions might not appear within the call, e.g.

fn <- function(x) print(x)

R6Class(public = list(fn = fn))

However, I guess there would be some workaround.

I'd be happy to put together a PR for this if there's interest.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant