Skip to content

Handle pipe context across signature help, inlay hints, and providers - #803

Merged
renkun-ken merged 6 commits into
masterfrom
codex/fix-pipe-signature-help
Oct 18, 2026
Merged

renkun-ken merged 6 commits into
masterfrom
codex/fix-pipe-signature-help

Conversation

@renkun-ken

@renkun-ken renkun-ken commented Oct 18, 2026 •

Copy link
Copy Markdown
Member

Piped calls currently lose their implicit argument context in several language features. For example, x |> findInterval() highlights x instead of vec, and x |> fun1(1, 2) labels the explicit arguments as arg1/arg2 instead of arg2/arg3.

This change accounts for implicit pipe arguments and explicit native _ or magrittr . placeholders in signature help and inlay hints for |>, %>%, %<>%, and %T>%, including placeholders after the cursor, nested calls, and incomplete edits. Cached inlay hints are invalidated when their pipe context changes.

It also fixes the related provider issues:

  • Restore member completion, hover, and signatures for native-pipe callees such as x |> obj$run() without evaluating user code.
  • Match class names and inheritance to their actual formal arguments, preserving source ranges for piped R6, S4, and RefClass declarations.
  • Include bare magrittr stages such as x %>% target in call hierarchy and CodeLens while preserving namespace and local binding identity.
  • Allow extraction of independent expressions inside pipe arguments, such as 1 + 2 in x |> sum(1 + 2). Keep whole-RHS calls, placeholder-dependent expressions, and data-mask expressions in their pipe context; extracting the whole pipe remains available.

Magrittr source-file discovery ("file.R" %>% source()) is outside this PR.

Validation

  • Built and installed the package with R 4.6.1 on macOS.
  • Added regression coverage for pipe matching, placeholders, cached edits, member lookup, class hierarchy, bare calls, and safe extraction, including requests to the installed language server.
  • Signature, inlay-hint, member, type-hierarchy, reference/call-hierarchy, CodeLens, refactor, and indexing suites passed.
  • The full local parallel run completed with failures confined to terminal-newline diagnostics in test-code-action.R and test-lintr.R. A worker probe confirmed it loaded the user-level lintr configuration rather than the isolated test configuration. Both affected files passed with the isolated serial runner.
  • Latest focused validation: 71 tests / 644 assertions passed across signature help, inlay hints, pipe providers, refactoring, and intelligence-performance suites, using the isolated serial runner. Tests also evaluate both extraction actions to verify that results are preserved.
  • Changed-file lint and git diff --check pass.

@renkun-ken
renkun-ken requested a review from eitsupi October 18, 2026 12:22

@eitsupi eitsupi left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ChatGPT-assisted code review

I reviewed this PR with ChatGPT. Overall, the implementation looks good, particularly the handling of implicit pipe arguments, placeholders, and argument matching without evaluating user code. The regression test coverage is also appreciated.

ChatGPT identified two non-blocking points worth considering:

  1. %T>% support: The tee pipe is handled in class indexing, references, and refactoring, but not in signature help or inlay hints (R/inlay_hint.R, src/provider_index.c, and src/signature.c). Since %T>% passes its LHS to the RHS in the same way as %>%, it would be good to handle it consistently.

  2. Extract refactoring restrictions: The new check in refactor_expression_movable() prevents extracting any subexpression within a pipe RHS, including independent expressions such as 1 + 2 in x |> sum(1 + 2). I understand the conservative approach to avoid breaking placeholder-dependent expressions, but it may be worth narrowing this restriction in a follow-up.

Neither seems serious enough to block this PR. Approved. Thanks for the comprehensive work!

@renkun-ken
renkun-ken merged commit 834e317 into master Oct 18, 2026
10 checks passed
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

Successfully merging this pull request may close these issues.

2 participants