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

Handle Sorbet levels to prevent some feature duplication #2322

Merged
merged 1 commit into from
Jul 23, 2024

Conversation

vinistock
Copy link
Member

Motivation

This PR is a step towards #2294

We added a bunch of new features recently, but we weren't super careful about checking which parts overlapped with Sorbet's behaviour and under which scenarios. This resulted in a bit of duplicate behaviour and we can improve that.

Note that full removal of any kind of duplication is going to require deep integration with the type checker and is a much more involved effort.

Implementation

Essentially, requests have to know the level of Sorbet type checking available for a file to make decisions about what to provide.

Instead of trying to use a blanket statement like typechecker_enabled?, I switched to passing the Sorbet level of type checking to the relevant requests.

I left some comments on the PR to help understand the decisions.

Automated Tests

Added tests.

@vinistock vinistock added bugfix This PR will fix an existing bug server This pull request should be included in the server gem's release notes labels Jul 18, 2024
@vinistock vinistock self-assigned this Jul 18, 2024
@vinistock vinistock requested a review from a team as a code owner July 18, 2024 14:27
@vinistock vinistock requested review from andyw8 and st0012 July 18, 2024 14:27
@andyw8
Copy link
Contributor

andyw8 commented Jul 18, 2024

🤔 Will any of the signature changes here impact addons?

@vinistock
Copy link
Member Author

Will any of the signature changes here impact addons?

It shouldn't, we weren't passing typechecked_enabled? to any of them before.

lib/ruby_lsp/document.rb Show resolved Hide resolved
lib/ruby_lsp/listeners/completion.rb Outdated Show resolved Hide resolved
lib/ruby_lsp/listeners/completion.rb Outdated Show resolved Hide resolved
lib/ruby_lsp/listeners/definition.rb Show resolved Hide resolved
@vinistock
Copy link
Member Author

I dug a little deeper and there were a few other scenarios I hadn't realized. For example, Sorbet can provide constant completion even if a file has no typed sigil. The only time it cannot provide it is on typed: ignore.

The PR should be good for another round of reviews.

@vinistock vinistock requested a review from st0012 July 22, 2024 14:39
@vinistock vinistock merged commit 9a83447 into main Jul 23, 2024
37 checks passed
@vinistock vinistock deleted the vs/handle_sorbet_levels branch July 23, 2024 14:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix This PR will fix an existing bug server This pull request should be included in the server gem's release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants