Return LocationLink for definition jumps and query definition#2216
Open
soutaro wants to merge 2 commits into
Open
Return LocationLink for definition jumps and query definition#2216soutaro wants to merge 2 commits into
soutaro wants to merge 2 commits into
Conversation
The `$/steep/query/definition` custom method previously returned only the identifier (name) range of a definition. Coding agents typically want the full declaration range (e.g. `class Foo ... end`), so this is unhelpful. Unify the result shape with LSP's `LocationLink`, which carries both ranges (`targetRange` for the full declaration, `targetSelectionRange` for the name). `textDocument/definition`, `/implementation`, and `/typeDefinition` now also emit `LocationLink[]` when the client advertises `linkSupport`, and fall back to `Location[]` (with the name range, for backwards compatibility) otherwise. Internally, `GotoService` helpers now return `DefinitionLocation` values that pair the two ranges, and the range filtering is factored into `filter_assigned_locations`.
For Ruby class/module definitions, `source_index` only tracks the `:const` name node. Walk up the AST via `typing.source.find_nodes` to find the enclosing `:class`/`:module` so `target_range` covers the full declaration rather than just the name. Also update `test/type_check_worker_test.rb` to assert the new `LocationLink` shape returned by `TypeCheckWorker#goto`, and fix a leftover raw-location assertion in `test_go_to_type_definition`.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
$/steep/query/definitioncustom method previously returned onlythe identifier (name) range of a definition. Coding agents typically
want the full declaration range (e.g.
class Foo ... end), so this isunhelpful.
Unify the result shape with LSP's
LocationLink, which carries bothranges (
targetRangefor the full declaration,targetSelectionRangefor the name).
textDocument/definition,/implementation, and/typeDefinitionnow also emitLocationLink[]when the clientadvertises
linkSupport, and fall back toLocation[](with the namerange, for backwards compatibility) otherwise.
Internally,
GotoServicehelpers now returnDefinitionLocationvalues that pair the two ranges, and the range filtering is factored
into
filter_assigned_locations.