Fix Go and Ruby reference extraction - #30
Merged
Merged
Conversation
Go: match qualified_type as well as selector_expression so type-position references (composite literals, var declarations) are captured. Also use the correct 'operand' receiver field for selector_expression instead of relying on the NamedChild(0) fallback. Ruby: use the 'method' field on call nodes instead of the last named child, which is the block or argument list when either is present.
There was a problem hiding this comment.
Pull request overview
This PR fixes reference extraction in the Refs API for Go and Ruby so Hyrum’s usage indexing can correctly identify package/constant member references across more syntactic forms.
Changes:
- Go: add reference matching for
qualified_type(type-position package refs) and correctselector_expressionreceiver extraction to use theoperandfield. - Ruby: fix
callmember extraction to use themethod/receiverfields so blocks/arglists aren’t misidentified as the member. - Add regression coverage in
TestHyrumLanguageRefsfor the above cases.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| ref.go | Routes Go ref extraction through a dedicated goRefs implementation. |
| ref_hyrum.go | Implements improved Go and Ruby reference extraction logic for Hyrum-related languages. |
| ref_test.go | Adds regression cases covering Go type-position refs and Ruby calls with blocks/arguments. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Two separate walks over selector_expression and qualified_type would return out-of-order results when a type reference precedes a selector in the file. Use a single walk with a per-node-type switch, matching the rubyRefs structure, and reorder the Go fixture so the test asserts source order across both node types.
andrew
added a commit
to alpha-omega-security/hyrum
that referenced
this pull request
Aug 11, 2026
One tree-sitter-backed indexer replaces the per-ecosystem regex and
text scanners in js.go, python.go, and generic.go. For each source
file it calls outline.Imports to extract import statements, filters
them via provides.ProvidedName.Matches (prefix + separator per
ecosystem, case-folded for PHP), collects the local identifiers each
matching import binds, then calls outline.Refs to trace direct member
accesses on those identifiers. Member accesses now record under the
export or module name rather than whatever local alias the target
chose, so 'import {X as Y}; Y.foo' surfaces as X.foo.
Seed receivers cover ecosystems where the dependency's canonical name
is referenced without an import line: Ruby's Bundler-autoloaded
constant, Rust and Elixir's module identifier, PHP's PSR-4 root, and
Go's implicit package name for an unaliased import.
outline is pinned to a475607 (git-pkgs/outline#30, merged) for Go
qualified_type refs and the Ruby call-with-block method-field fix;
provides to 29fb3d0 (git-pkgs/provides#1) for CaseInsensitive matching.
The strict linter set (gocognit, goconst, gocyclo, maintidx, dupl,
mnd, unparam, ireturn) is now enabled in .golangci.yml so CI enforces
what the previous commit cleaned up; the deleted files were the last
offenders.
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.
Two fixes surfaced while wiring
Refsinto hyrum's usage indexer.Go:
Refsonly matchedselector_expression, so type-position package references were missed.sse.Event{}andvar e sse.Eventboth parse asqualified_type(fieldspackage/name), notselector_expression. This adds a second match onqualified_typeand also switchesselector_expressionto its actualoperandreceiver field instead of theobjectdefault that only worked via theNamedChild(0)fallback.Ruby:
rubyRefstook the last named child of acallnode as the member. When the call has a block or argument list, that is the last child, soOctokit.configure { |c| ... }reported the block text as the member. Now usesChildByFieldName("method")andChildByFieldName("receiver").Regression cases added to
TestHyrumLanguageRefs.