Repository navigation
feat(codegraph): extract call graph from Rust function bodies - #1025
Conversation
_extract_symbols_rust populated Symbol.calls as [] for every function. The generic _extract_calls() already handles call_expression (Rust's node type), so wiring it to the function body is a one-liner fix. Adds tests: test_parse_rust_function_calls (multiply → multiply_internal) and test_parse_rust_impl_method_calls (add body = no calls, with_max has a non-empty but not-crashing calls list). Closes part of #1024.
Greptile SummaryThis PR fixes the long-standing gap where
Confidence Score: 5/5Safe to merge — the change is a two-line addition to an isolated Rust extractor function with no effect on Python or JS/TS extraction paths. The fix reuses the battle-tested No files require special attention. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["_extract_symbols_rust(root, filepath)"] --> B{node.type == function_item?}
B -- Yes --> C["name = child_by_field_name('name')"]
C --> D["body_node = child_by_field_name('body')"]
D --> E{"body_node is not None?"}
E -- Yes --> F["_extract_calls(body_node)"]
F --> G["Walk body via cursor looking for call_expression nodes"]
G --> H["calls.append(_text(func_node))"]
E -- No --> I["calls = []"]
H --> J["calls = list(set(calls))"]
I --> J
J --> K["Symbol(..., calls=calls)"]
B -- No --> L["Recurse into children (impl_item passes parent_kind='impl')"]
L --> B
Reviews (2): Last reviewed commit: "test(codegraph): improve Rust call-extra..." | Re-trigger Greptile |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
- Replace bare next() with next(..., None) + assert for meaningful error messages when a symbol is missing - Fix trivially-passing 'is not None' assertion on with_max to assert calls == [] (with_max body has no call_expression nodes) - Exclude gptme-codegraph from mirrors-mypy hook (typecheck-packages already handles it; fresh pre-commit envs failed with import-not-found) Addresses Greptile feedback on PR #1025.
|
Thanks for the review! Addressed in 112acfc:
|
|
@greptileai review |
Summary
_extract_symbols_rustbuiltSymbolobjects forfunction_itemnodes but never populatedSymbol.calls— the field was always[]_extract_calls()already handlescall_expression(the node type Rust tree-sitter uses for function calls), so the fix is adding two lines to thefunction_itembranchtest_parse_rust_function_calls(verifiesmultiply → multiply_internal) andtest_parse_rust_impl_method_calls(verifies impl methods also get calls extracted, and pure-arithmetic functions return[])Closes
Part of #1024 (Rust call extraction). Rust import (
usestatement) extraction from the same issue is a follow-up.Test plan
uv run --package gptme-codegraph --extra treesitter pytest packages/gptme-codegraph/tests/test_multilang.py -k rust— all 10 Rust tests passmultiply.callscontains"multiply_internal"after the fix