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

Backport "Improve signature help by more stable position calculation + better named arg support" to LTS #20845

Merged
merged 1 commit into from
Jun 28, 2024

Conversation

WojciechMazur
Copy link
Contributor

Backports #19214 to the LTS branch.

PR submitted by the release tooling.
[skip ci]

…amed arg support (#19214)

Previously, signature help had unstable way of calculating active
parameter inside the signature help. It is now changed to work better
with erroneous trees such as unclosed openings.

It also adds a new feature for signature help, which will help user
navigate inside named arguments. Furthermore, it will now find reordered
named arguments, and display in the same way, by also marking the
remaining parameters that they are now required to be named.

Example:


https://github.com/lampepfl/dotty/assets/48657087/b181d2d5-60f0-46a5-b2df-a58aa5f07454

The following changes have been made:

    - we will stop supporting Signature Helps for unclosed openings. It is too hard to recover from such errors reliably and to track where we are with the cursor. All modern editors will close opening on input. It simplified the code, and is the best way forward.
    - if there is an error within a definition return type parameter, we will now fall back to source, instead of print error,
    - tuples and functions are now supported when they are returned from methods.
    - this rewrite made me change a few things, and I took the chance and made it support clause interleaving. There is now a proper test suite for that. It required changing the way we represent Signatures.
    - argument reordering now works for all parameter lists, not only the currently applied one,
    - type parameters now also correctly display documentation

I've changed the PR to use ShortenedTypePrinter and fixed some other minor issues like correctly marking reordered argumentss or hiding synthetic parameter names.

In the future, Signature help should be changed to return symbols from the compiler instead of already printed values, and only print them later using shared API of ShortenedTypePrinter in the Presentation Compiler. Ideally we'd want a shared implementation for label printing with completions, hovers and other features.
[Cherry-picked 01171de]
@WojciechMazur
Copy link
Contributor Author

No regressions detected in the community build up to lts-19520.

Reference

Base automatically changed from lts-19243 to lts-18702 June 28, 2024 10:17
@WojciechMazur WojciechMazur merged commit 6dcfeab into lts-18702 Jun 28, 2024
19 checks passed
@WojciechMazur WojciechMazur deleted the lts-19214 branch June 28, 2024 10:17
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