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

Replace IndexablePath with URI #2916

Merged
merged 3 commits into from
Nov 27, 2024
Merged

Conversation

vinistock
Copy link
Member

@vinistock vinistock commented Nov 26, 2024

Motivation

Second step for #1908

This PR gets rid of IndexablePath and standardizes on using URI. This is necessary because IndexablePath is coupled with file paths on disk, which is incompatible with the URI scheme for unsaved files (untitled:Untitled-1) - a scenario where the files don't exist on disk.

Implementation

The important changes are just in the URI extension file. Everything else is essentially just renaming things from IndexablePath to URI.

Note: this PR takes a slightly different approach than my previous attempt. I previously tried to create a separate URI class for the indexer, fully disconnected from the original URI::Generic class. That turned out to be a terrible idea that lead to an enormous amount of duplication, so the approach here is just to extend URI::Generic a bit more to handle require paths.

Automated Tests

Added a couple of new tests for the URI extension.

Copy link
Member Author

vinistock commented Nov 26, 2024

This stack of pull requests is managed by Graphite. Learn more about stacking.

@vinistock vinistock added other Changes that aren't bugfixes, enhancements or breaking changes server This pull request should be included in the server gem's release notes labels Nov 26, 2024 — with Graphite App
@vinistock vinistock marked this pull request as ready for review November 26, 2024 21:10
@vinistock vinistock requested a review from a team as a code owner November 26, 2024 21:10
exe/ruby-lsp Show resolved Hide resolved
@vinistock vinistock changed the base branch from 11-26-move_uri_extension_to_indexer to graphite-base/2916 November 27, 2024 14:14
@vinistock vinistock force-pushed the 11-26-replace_indexablepath_with_uri branch from f5b52b6 to 1af4abb Compare November 27, 2024 14:14
@vinistock vinistock changed the base branch from graphite-base/2916 to main November 27, 2024 14:15
@vinistock vinistock force-pushed the 11-26-replace_indexablepath_with_uri branch from 1af4abb to ea2b9bb Compare November 27, 2024 14:15
@vinistock vinistock requested a review from andyw8 November 27, 2024 14:16
@vinistock vinistock merged commit f386d41 into main Nov 27, 2024
39 checks passed
@vinistock vinistock deleted the 11-26-replace_indexablepath_with_uri branch November 27, 2024 15:17
vinistock added a commit that referenced this pull request Nov 27, 2024
<!--
NOTE: If you plan to invest significant effort into a large pull request with multiple decisions that may impact the long term maintenance of the Ruby LSP, please open a [discussion](https://github.com/Shopify/ruby-lsp/discussions/new/choose) first to align on the direction.
-->

### Motivation

Addresses #2916 (comment)

Rename `indexables` to `indexable_uris`, which is a much clearer name.
koic added a commit to koic/rubocop that referenced this pull request Jan 10, 2025
This PR fixes build error on specs of RubyLSP add-on:

```console
$ bundle exec rspec ./spec/ruby_lsp/rubocop/addon_spec.rb
(snip)

6 examples, 5 failures

Failed examples:

rspec ./spec/ruby_lsp/rubocop/addon_spec.rb:104 # RubyLSP::RuboCop::Addon textDocument/formatting has basic result information
rspec ./spec/ruby_lsp/rubocop/addon_spec.rb:109 # RubyLSP::RuboCop::Addon textDocument/formatting has autocorrected code
rspec ./spec/ruby_lsp/rubocop/addon_spec.rb:60 # RubyLSP::RuboCop::Addon textDocument/diagnostic has first diagnostic information
rspec ./spec/ruby_lsp/rubocop/addon_spec.rb:72 # RubyLSP::RuboCop::Addon textDocument/diagnostic has second diagnostic information
rspec ./spec/ruby_lsp/rubocop/addon_spec.rb:54 # RubyLSP::RuboCop::Addon textDocument/diagnostic has basic result information
```

This change now requires Ruby LSP 0.23+, which includes Shopify/ruby-lsp#2916, during development.
koic added a commit to koic/rubocop that referenced this pull request Jan 10, 2025
This PR fixes the following build errors related to the RubyLSP add-on specs:

```console
$ bundle exec rspec ./spec/ruby_lsp/rubocop/addon_spec.rb
(snip)

6 examples, 5 failures

Failed examples:

rspec ./spec/ruby_lsp/rubocop/addon_spec.rb:104 # RubyLSP::RuboCop::Addon textDocument/formatting has basic result information
rspec ./spec/ruby_lsp/rubocop/addon_spec.rb:109 # RubyLSP::RuboCop::Addon textDocument/formatting has autocorrected code
rspec ./spec/ruby_lsp/rubocop/addon_spec.rb:60 # RubyLSP::RuboCop::Addon textDocument/diagnostic has first diagnostic information
rspec ./spec/ruby_lsp/rubocop/addon_spec.rb:72 # RubyLSP::RuboCop::Addon textDocument/diagnostic has second diagnostic information
rspec ./spec/ruby_lsp/rubocop/addon_spec.rb:54 # RubyLSP::RuboCop::Addon textDocument/diagnostic has basic result information
```

https://github.com/rubocop/rubocop/actions/runs/12704843475/job/35414859443

This change now requires Ruby LSP 0.23+, which includes Shopify/ruby-lsp#2916, during development.
bbatsov pushed a commit to rubocop/rubocop that referenced this pull request Jan 10, 2025
This PR fixes the following build errors related to the RubyLSP add-on specs:

```console
$ bundle exec rspec ./spec/ruby_lsp/rubocop/addon_spec.rb
(snip)

6 examples, 5 failures

Failed examples:

rspec ./spec/ruby_lsp/rubocop/addon_spec.rb:104 # RubyLSP::RuboCop::Addon textDocument/formatting has basic result information
rspec ./spec/ruby_lsp/rubocop/addon_spec.rb:109 # RubyLSP::RuboCop::Addon textDocument/formatting has autocorrected code
rspec ./spec/ruby_lsp/rubocop/addon_spec.rb:60 # RubyLSP::RuboCop::Addon textDocument/diagnostic has first diagnostic information
rspec ./spec/ruby_lsp/rubocop/addon_spec.rb:72 # RubyLSP::RuboCop::Addon textDocument/diagnostic has second diagnostic information
rspec ./spec/ruby_lsp/rubocop/addon_spec.rb:54 # RubyLSP::RuboCop::Addon textDocument/diagnostic has basic result information
```

https://github.com/rubocop/rubocop/actions/runs/12704843475/job/35414859443

This change now requires Ruby LSP 0.23+, which includes Shopify/ruby-lsp#2916, during development.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
other Changes that aren't bugfixes, enhancements or breaking changes 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.

2 participants