Skip to content

Return LocationLink for definition jumps and query definition#2216

Open
soutaro wants to merge 2 commits into
masterfrom
claude/fix-query-definition-range-SStcT
Open

Return LocationLink for definition jumps and query definition#2216
soutaro wants to merge 2 commits into
masterfrom
claude/fix-query-definition-range-SStcT

Conversation

@soutaro

@soutaro soutaro commented Apr 24, 2026

Copy link
Copy Markdown
Owner

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.

claude added 2 commits April 24, 2026 06:58
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`.
@soutaro soutaro added this to the Steep 2.1 milestone Apr 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants