Replace uses of lsp::Location
with a custom Location type
#11486
+121
−155
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The lsp location type has the lsp's URI type and a range. We can replace that with a custom type private to the lsp commands module that uses the core URI type instead.
Note that we can't create a helix-core Location type instead...
That type would look like:
But we can't convert every
lsp::Location
to this type because for definitions, references and diagnostics language servers send documents which we haven't opened yet, so we don't have the information to convert anlsp::Range
(line+col) to ahelix_core::Range
(char indexing).This cleans up the picker definitions in this file so that they can all use helpers like
jump_to_location
andlocation_to_file_location
for the picker preview. It also enables some refactors to make some things cheaper:PathOrId::from_path_buf
so we can drop the owned variant of that type. Now the picker preview callback never allocates.Arc<Path>
as the internal representation ofhelix_core::Uri
, making it cheap to clone. We clone URIs potentially often in diagnostics and symbol pickers.With this change we also validate URIs for LSP based pickers and goto references/definition/etc. so we don't open ones with unsupported schemes, for example #11484