fix(extraction): fix Ruby call edge extraction for local vars and chained .new#684
Open
ricobl wants to merge 2 commits into
Open
fix(extraction): fix Ruby call edge extraction for local vars and chained .new#684ricobl wants to merge 2 commits into
ricobl wants to merge 2 commits into
Conversation
…ined .new Ruby call nodes use receiver + method fields instead of a function field, causing the generic extractor to miss two common patterns: - `var = SomeClass.new(...); var.method` emitted `var.method` which the resolver couldn't match to `SomeClass::method` - `SomeClass.new(...).method` emitted only the method name without its class Both the caller and callee sides of these edges were broken as a result. Fixes: - Extract the `method` field from Ruby call nodes in the generic extractor so chained `.new(...).method` correctly emits the method name - Add a `buildLocalScope` hook to `LanguageExtractor` that lets a language pre-scan a function body and return a var → class prefix map; the engine uses this to resolve `var.method` to `ClassName::method` at extraction time - Ruby implements the hook by scanning for `var = ClassName.new(...)` assignments The hook is separator-agnostic (map values include the separator, e.g. `"Foo::"`), so other languages can implement it without engine changes. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
4a342b2 to
ccd6617
Compare
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.
Summary
callnodes usereceiver+methodfields rather than afunctionfield, causing two common patterns to produce unresolvable references:obj = SomeClass.new(...); obj.methodemittedobj.method, andSomeClass.new(...).methodemitted only the method name — neither could be matched by the resolver, socodegraph_callersandcodegraph_calleesboth returned incomplete results.tree-sitter.tsfor call nodes that use amethodfield: chained receivers (class/namespace) emit the class name; bare method receivers emitreceiver.method; complex receivers (e.g. a chained call) emit just the method name.buildLocalScopehook toLanguageExtractorthat lets a language pre-scan a function body and return avar → "ClassName::"prefix map. The engine uses this during call extraction to resolvevar.methodtoClassName::method. Ruby implements it by scanningvar = ClassName.new(...)assignments. The hook is separator-agnostic so other languages can adopt it without engine changes.Test plan
npx vitest run __tests__/extraction.test.ts -t "Ruby calls"— 5 tests covering bare.new, namespaced.new, chained.new(...).method, local var assignment with simple class, and local var assignment with namespaced classnpx vitest run— full suite, no new regressionsshuts down when its parent is SIGKILL'd and stdin stays open