Skip to content

feat(parser): emit FUNCTION nodes for namespace-assigned JS functions#77

Merged
smochan merged 1 commit into
mainfrom
feat/ts-namespace-assigned-functions
Jun 10, 2026
Merged

feat(parser): emit FUNCTION nodes for namespace-assigned JS functions#77
smochan merged 1 commit into
mainfrom
feat/ts-namespace-assigned-functions

Conversation

@smochan

@smochan smochan commented Jun 10, 2026

Copy link
Copy Markdown
Owner

Summary

Plain-script JS (no ES modules) attaches its API to namespace objects — CGUI.esc = function esc(s) {...}, window.CGViews.flows = (host) => {...}. The parser handled function declarations and const-assigned functions but emitted nothing for member-expression assignments, leaving these functions invisible to the graph.

Concrete impact: PR #73's helper move (app.js → ui/helpers.js, the new module pattern of the whole refactored dashboard) was flagged removed-referenced critical three times, because the new CGUI.* definitions produced no added nodes for the move detection (#76) to match.

New _handle_assigned_function in the module-level visitor:

  • LHS must be a member expression of plain identifiers (computed members obj[key] skipped)
  • window. prefix stripped (environment artifact, not a namespace)
  • node name = property name (the API name callers use); inner named function expressions preserved as metadata.function_name
  • body calls/fetches attributed to the new node like every other handler

Test plan

  • 3 new extractor tests + fixture (assignment forms, skip rules, CALLS attribution)
  • Full suite: 779 passed
  • ruff + mypy --strict clean
  • codegraph lint self-run clean

Unblocks #73 (final wave-2 train car).

🤖 Generated with Claude Code

Plain-script JS (no ES modules) attaches its API to namespace objects:
CGUI.esc = function esc(s) {...}, window.CGViews.flows = (host) => {...}.
The TS/JS parser handled function declarations and const-assigned
functions but emitted nothing for member-expression assignments, so
these functions were invisible to the graph - no nodes, no CALLS
attribution, and review flagged the dashboard helper move (app.js ->
ui/helpers.js) as removed-referenced because the new definitions
produced no added nodes for move detection to match.

New _handle_assigned_function in the module-level visitor: LHS must be
a member expression of plain identifiers (computed members skipped),
window. prefix is stripped, RHS must be a function/arrow expression.
Node name is the property name (the API name callers use); an inner
named function expression is preserved as metadata.function_name. Body
calls/fetches are attributed to the new node like every other handler.

Gate: 779 tests pass, ruff + mypy --strict clean.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

codegraph PR review

Diff vs main · severity ≤ high

codegraph review (target: main)

Diff: +9 / -0 / ~0 nodes, +239 / -164 edges

Findings (0)

No findings.

Triggered by codegraph CI · last run

@smochan smochan merged commit 4c5fb20 into main Jun 10, 2026
5 checks passed
@smochan smochan deleted the feat/ts-namespace-assigned-functions branch June 10, 2026 17:33
@github-actions github-actions Bot locked and limited conversation to collaborators Jun 10, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant