Skip to content

fix(native): remove unused source param from get_first_call_arg#1960

Open
carlos-alm wants to merge 1 commit into
fix/issue-1815-same-f-file-array-vs-string-native-crashfrom
fix/issue-1817-unused-source-param-on-get-first-call-arg-in
Open

fix(native): remove unused source param from get_first_call_arg#1960
carlos-alm wants to merge 1 commit into
fix/issue-1815-same-f-file-array-vs-string-native-crashfrom
fix/issue-1817-unused-source-param-on-get-first-call-arg-in

Conversation

@carlos-alm

Copy link
Copy Markdown
Contributor

Summary

  • get_first_call_arg in crates/codegraph-core/src/extractors/javascript.rs took a source: &[u8] parameter it never used — it only inspects node structure (child kinds via child_by_field_name/find_child) to locate the first non-punctuation call argument, never calling node_text on it internally.
  • Confirmed this parameter is genuinely dead rather than a wiring gap: the WASM/TS mirror, getFirstCallArg in src/extractors/javascript.ts, has never taken a source parameter at all — it doesn't need one because TreeSitterNode already carries .text inline (a web-tree-sitter API difference from native tree_sitter::Node, which needs a separate source buffer only when extracting text, not when just returning a node handle).
  • Removed the parameter from get_first_call_arg and updated its three call sites (eval() string-literal key_expr capture, Reflect.apply, Reflect.construct) to match. No behavior change — callers already had their own source in scope for their own node_text calls on the returned node.
  • Added 5 native unit tests exercising all three call sites (previously untested at the Rust unit level), so this helper's contract is now pinned against future regressions.

Fixes #1817

Test plan

  • cargo test in crates/codegraph-core — 522 passed, 0 failed (including 5 new tests: eval_captures_string_literal_key_expr, eval_with_non_literal_arg_has_no_key_expr, reflect_apply_extracts_first_arg_as_callee, reflect_construct_extracts_first_arg_as_callee, reflect_apply_member_expression_arg_extracts_property_with_receiver)
  • cargo check --release / cargo clippy --release — the original dead-parameter warning is gone; no new warnings introduced
  • Rebuilt the native napi addon locally (codesigned) and ran the full vitest suite against it — 225 files, 3722 passed, 0 failed, including tests/engines/dynamic-call-ffi.test.ts and tests/integration/build-parity.test.ts (native vs WASM parity)
  • npm run lint — clean

Stacked on #1815 (base branch fix/issue-1815-same-f-file-array-vs-string-native-crash) — only the crates/codegraph-core/src/extractors/javascript.rs diff is this issue's change.

The JS/TS extractor's get_first_call_arg helper never used its source
parameter — it only needs node structure (child kinds) to locate the
first non-punctuation call argument, matching the WASM/TS mirror
(getFirstCallArg in src/extractors/javascript.ts), which never took a
source parameter at all. Removed it and updated the three call sites
(eval() key_expr capture, Reflect.apply, Reflect.construct), silencing
the dead-parameter compiler warning.

Added native unit tests covering all three call sites so a future
change to this helper's signature or behavior is caught by cargo test.
@greptile-apps

greptile-apps Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR removes a dead source: &[u8] parameter from get_first_call_arg in the JavaScript extractor and adds unit tests for all three call sites (eval, Reflect.apply, Reflect.construct) that were previously untested at the Rust level.

  • Signature of get_first_call_arg simplified from (call_node, source)(call_node) since the function only traverses node structure, never reading source text.
  • Three call sites updated to drop the now-removed argument; callers retain their own source reference for subsequent node_text calls on the returned node.
  • Five new unit tests added, pinning eval string-literal capture, non-literal no-key_expr, Reflect.apply identifier/member-expression extraction, and Reflect.construct extraction against future regressions.

Confidence Score: 5/5

Safe to merge — removes a dead function parameter with no behavioral change, and all three affected call sites are covered by new unit tests.

The change is a straightforward dead-parameter removal. get_first_call_arg never called node_text or otherwise used source, so eliminating it cannot alter runtime behavior. All callers already held their own source reference. Five new tests exercise every call site and verify the returned Call fields, providing a clear regression baseline.

No files require special attention.

Important Files Changed

Filename Overview
crates/codegraph-core/src/extractors/javascript.rs Removes unused source: &[u8] parameter from get_first_call_arg, updates 3 call sites, and adds 5 unit tests covering all affected code paths.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[extract_call_info] -->|eval| B[get_first_call_arg call_node]
    A -->|Reflect.apply| C[get_first_call_arg call_node]
    A -->|Reflect.construct| D[get_first_call_arg call_node]
    B --> E{arg kind?}
    C --> F[extract_reflect_callee_from_arg]
    D --> F
    E -->|string/template_string| G[node_text → key_expr]
    E -->|other| H[key_expr = None]
    F -->|identifier| I[Call name = identifier text]
    F -->|member_expression| J[Call name = property, receiver = object]
    F -->|other| K[Call name = dynamic:unresolved]
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
    A[extract_call_info] -->|eval| B[get_first_call_arg call_node]
    A -->|Reflect.apply| C[get_first_call_arg call_node]
    A -->|Reflect.construct| D[get_first_call_arg call_node]
    B --> E{arg kind?}
    C --> F[extract_reflect_callee_from_arg]
    D --> F
    E -->|string/template_string| G[node_text → key_expr]
    E -->|other| H[key_expr = None]
    F -->|identifier| I[Call name = identifier text]
    F -->|member_expression| J[Call name = property, receiver = object]
    F -->|other| K[Call name = dynamic:unresolved]
Loading

Reviews (1): Last reviewed commit: "fix(native): remove unused source param ..." | Re-trigger Greptile

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