-
Notifications
You must be signed in to change notification settings - Fork 154
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
Switch to storing URIs in entries instead of file paths #2341
Conversation
9391c9e
to
0d47a2d
Compare
0d47a2d
to
ce52fcd
Compare
🤔 Will this have any impact on addons? |
@@ -2,6 +2,8 @@ | |||
# frozen_string_literal: true | |||
|
|||
module RubyIndexer | |||
# Represents a file system path that can be indexed. This class should only be used for files in the file system and | |||
# not for other URIs that may be indexed, such as unsaved file URIs using the `untitled` scheme |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we not enforce this by using URI::File
instead of URI::Generic
?
# } | ||
@files_to_entries = T.let({}, T::Hash[String, T::Array[Entry]]) | ||
@uris_to_entries = T.let({}, T::Hash[String, T::Array[Entry]]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we change this to use the URI as the key?
This pull request is being marked as stale because there was no activity in the last 2 months |
Closing this for now. We need to re-think the approach. |
Motivation
First step towards #2340 and #1908
Currently, we save the file paths for entries in the index. This decision is incompatible with how language servers work, because you can have files that exist in different URI schemes (such as the one for unsaved files like
untitled:Untitled-1
).In general, we should always strive to use URIs everywhere and only get the file paths when we want to return something or when we're reading from disk.
This PR changes our entries to store the URIs where they were declared, rather than tying ourselves with file paths. This change is necessary in order to fix #1908, because if we index files before they are saved, there's no file path associated to the declarations being made in the unsaved file.
Implementation
The change is essentially switching from
file_path
to URI pretty much everywhere.As an added benefit, we now no longer need to build the URI when serving features, because that's already available directly in the entries - which is another indication that standardizing on URIs is likely the best choice.
Automated Tests
Adapted existing tests.