Repository navigation
Fix member completion for static namespace objects - #818
Conversation
eitsupi
left a comment
There was a problem hiding this comment.
Review by ChatGPT
I found two issues worth addressing before merging:
-
Incomplete startup metadata can bypass the completion wait (
R/handlers-langfeatures.R)member_metadata_waiting()treats any existing catalog without an error as ready. However,workspace_startup_members()may have already cached adataset_onlysnapshot. A first completion request for a regular namespace object can therefore return incomplete results while full metadata is still being prepared. Please account fordataset_only/namespace_attemptedwhen checking readiness. -
External S3 subset methods are not considered (
R/member-inference.R)member_subset_method()checks document bindings and the owning package's definitions, but may miss[/[[methods registered by other packages. It can then incorrectly infer results from the underlying list elements despite custom dispatch. Please detect registered methods or conservatively avoid default subset inference when dispatch cannot be ruled out.
Regression tests covering both cases would be useful.
Static namespace values such as
redux::redisreturned no member completions because class-based guards rejected their observed members. Lists, data frames, pairlists, and stored S4/R6 values also lacked complete metadata. Lazy datasets live outside ordinary namespace bindings, somtcars$andggplot2::diamonds$were missing as well.Prepare bounded structural snapshots and preserve package ownership, captured values, and receiver bindings through aliases, nested access, indexing, and explicit
:::lookup.$and@completion now resolve the correct members and signatures while respecting custom dispatch and avoiding getter or coercion-hook execution. Callable S4 instances retain their slots and.Datastorage, and R6 function fields keep their original lexical bindings.Add constructed regressions for namespace collisions, captured and returned callbacks, class changes, local and custom dispatch, matrix/array conversion hooks, R6 inheritance/private contexts, and S4 instances.
Include lazy datasets with correct public/export precedence, seed default-package dataset models once per host, and propose known dataframe columns without invoking custom accessors. Recover namespace hints from incomplete
$/@buffers and wait for relevant member preparation so the first LSP response is complete. Retain bounded dataset models if full namespace metadata exceeds its size limit. Test the package-dataset path with a temporary base-R package containing lazy-loaded data and a custom dataframe accessor, without adding a ggplot2 dependency.Local validation:
mtcarsand the constructed package dataset over LSP on the first request, with retries disabled and no getter execution.R CMD check --as-cran --no-tests --no-manual --no-vignettes: no errors or warnings (existing non-failing notes only).git diff --check: clean.