Skip to content

Add find references feature to goto service#2209

Draft
soutaro wants to merge 3 commits into
masterfrom
claude/lsp-goto-references-Lh8Jr
Draft

Add find references feature to goto service#2209
soutaro wants to merge 3 commits into
masterfrom
claude/lsp-goto-references-Lh8Jr

Conversation

@soutaro
Copy link
Copy Markdown
Owner

@soutaro soutaro commented Apr 12, 2026

Summary

This PR implements a "find references" feature for the Steep language server, allowing users to find all references to constants, methods, and type names across Ruby and RBS files.

Key Changes

  • GotoService enhancements:

    • Added as_json and from_json methods to ConstantQuery, MethodQuery, and TypeNameQuery for serialization
    • Added query_from_json factory method to deserialize query objects
    • Implemented references method to find all references to a symbol with optional declaration inclusion
    • Added helper methods: resolve_references_queries, find_references, constant_references_in_ruby, method_references_in_ruby, and type_name_references_in_rbs
  • Language Server Protocol support:

    • Added references_provider: true to server capabilities in master.rb
    • Implemented textDocument/references request handler with two-phase resolution:
      1. Query resolution phase (interaction worker) to identify what symbol is being referenced
      2. Search phase (typecheck workers) to find all references across the codebase
  • Worker implementations:

    • InteractionWorker: Added ReferencesQueryJob and process_references_query to resolve references queries at a given position
    • TypeCheckWorker: Added ReferencesJob and references method to search for references across type-checked files
  • Custom methods:

    • Added References__QueryResolution and References__Search custom LSP methods for the two-phase reference finding workflow
  • Tests:

    • Added comprehensive test coverage for finding references to constants, methods, and type names
    • Tests verify both with and without declaration inclusion

Implementation Details

The feature uses a two-phase approach:

  1. The interaction worker resolves what queries (constant, method, or type name) are at the cursor position
  2. The typecheck workers then search their respective type-checked files for references matching those queries
  3. Results are aggregated and returned to the client as LSP location links

References are found in both Ruby source files (via typing information) and RBS signature files (via RBS index queries).

https://claude.ai/code/session_016jjaePV7QxhdjsytmUE3Sw

@soutaro soutaro force-pushed the claude/lsp-goto-references-Lh8Jr branch from b22859c to 339131e Compare April 12, 2026 15:23
soutaro and others added 3 commits April 13, 2026 00:35
…bol name

Add $/steep/resolve_symbol custom LSP method. The interaction worker
receives a textDocument position, resolves it to query objects via
GotoService#resolve_references_queries, and returns them serialized
as JSON. Add as_json/from_json/query_from_json for query serialization.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add $/steep/references/search custom LSP method. Typecheck workers
receive a symbol name, search assigned files via
GotoService#find_references, and return location links.

Add reference search methods: constant_references_in_ruby,
method_references_in_ruby, type_name_references_in_rbs.
Extract locations_to_links helper in TypeCheckWorker.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Orchestrate two-phase find references: send ResolveSymbol to the
interaction worker to resolve the cursor position, then broadcast
References__Search to all typecheck workers and merge results.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@soutaro soutaro force-pushed the claude/lsp-goto-references-Lh8Jr branch from 339131e to c7ec6bc Compare April 12, 2026 15:37
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.

1 participant