Skip to content

Conversation

@jscharf
Copy link
Contributor

@jscharf jscharf commented Jan 5, 2024

Motivation

This is a follow up to #1245 by @SeanKG and I.

We did another pair programming session today to continue that work to add hover and go to definition support for when the type checker is enabled but the file is typed: false.

A lot of our files are currently typed: false but we still wanted to get the editor benefits of the Ruby LSP despite that.

Implementation

The implementation was very similar to #1245. We added an extra parameter to the initialize method in both hover.rb and definition.rb to store whether the type checker is enabled or not, and then we replaced existing instances of DependencyDetector.instance.typechecker with that newly provided instance variable @typechecker_enabled.

There is also a small refactor to common.rb included in these changes so that we could modify the code we needed to modify. We pulled out the call to DependencyDetector.instance.typechecker because it didn't relate to whether the caller was defined in a gem or not. So now the defined_in_gem? method looks like this

def defined_in_gem?(file_path)
  BUNDLE_PATH &&
    !file_path.start_with?(T.must(BUNDLE_PATH)) &&
    !file_path.start_with?(RbConfig::CONFIG["rubylibdir"])
end

Automated Tests

We didn't add any new automated tests as part of this change. However we did update existing ones.

The reasoning behind that was we thought the change in functionality was small enough this time that updating the existing tests would be ok. If this is not ok definitely let us know.

Manual Tests

Note as of 2:00pm on January 5th, 2024 this has not been manually tested yet. I will update when it has been.

…t typed: false

Co-authored-by: Sean Graves <SeanKGraves@gmail.com>
@jscharf jscharf requested a review from a team as a code owner January 5, 2024 19:06
@jscharf jscharf requested review from KaanOzkan and egiurleo January 5, 2024 19:06
@jscharf
Copy link
Contributor Author

jscharf commented Jan 5, 2024

I have signed the CLA!

Copy link
Member

@vinistock vinistock left a comment

Choose a reason for hiding this comment

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

Awesome! Thanks for the contribution

@vinistock vinistock merged commit 24147e8 into Shopify:main Jan 8, 2024
@st0012 st0012 added the enhancement New feature or request label Jan 11, 2024
andyw8 pushed a commit to Shopify/ruby-lsp-rails that referenced this pull request Jan 12, 2024
After Shopify/ruby-lsp#1280, the hover request
will now contain information about the class's information too.

This previously was not the case because this project has Sorbet
in the depdenencies.
sports-fan added a commit to sports-fan/LSP that referenced this pull request Feb 6, 2024
After Shopify/ruby-lsp#1280, the hover request
will now contain information about the class's information too.

This previously was not the case because this project has Sorbet
in the depdenencies.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants