Repository navigation
fix(parser): index JavaScript and TypeScript generator functions - #1131
Merged
1 commit merged intoNov 6, 2026
Merged
1 commit merged into
1 commit merged into
Conversation
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Generator handling skips non-function declarators in mixed declarations, losing the CALLS edge to setup; preserve their traversal and add a regression test.
1 open issue
What changed in this PR
This PR adds JavaScript, TypeScript and TSX generator functions to the code graph, allowing calls inside generators to be attributed to their function nodes.
Changes:
- Recognizes generator declarations in all three languages.
- Recognizes generator expressions through shared function-value handling.
- Adds six regression cases covering declarations, async generators, and variable/member assignments.
| File | Description |
|---|---|
| tests/test_parser.py | Adds generator node and call-attribution regression tests. |
| code_review_graph/parser.py | Registers generator declarations and expressions for function extraction. |
Review effort: Balanced
|
|
||
| _JS_FUNC_VALUE_TYPES = frozenset( | ||
| {"arrow_function", "function_expression", "function"}, | ||
| {"arrow_function", "function_expression", "function", "generator_function"}, |
0160eb0
gowrishacv
pushed a commit
to gowrishacv/code-review-graph
that referenced
this pull request
Nov 6, 2026
…rth8205#1131) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
gowrishacv
pushed a commit
to gowrishacv/code-review-graph
that referenced
this pull request
Nov 6, 2026
# Conflicts: # code_review_graph/parser.py
gowrishacv
pushed a commit
to gowrishacv/code-review-graph
that referenced
this pull request
Nov 6, 2026
Ruby methods always carry their full lexical scope (tirth8205#933), so the leaf collision index from tirth8205#1087 now covers Python only, and the docs and tests say so. Generators are not component wrappers' functions (tirth8205#972 with tirth8205#1131). Partial graph coverage counts tracked files only (tirth8205#881 with tirth8205#1094). A pending marker recomputes all derived data (tirth8205#1105), so that test starts from a finished graph, the deleted-seed case now passes (tirth8205#1062 with tirth8205#673), and hooks.json keeps its events under a hooks key (tirth8205#1102 with tirth8205#1126). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

Linked issue
No issue. This is a small parser fix; the reproduction is below.
What & why
Generator functions in JavaScript, TypeScript and TSX never become graph nodes. Tree-sitter parses
function* gen() {}andasync function* gen() {}asgenerator_function_declaration, and parsesconst gen = function* () {}andobj.gen = function* () {}asgenerator_function. Neither node type is listed, so a generator gets noFunctionnode and every call inside it is attributed to the file:ids;CALLS a.ts -> nextIdFunction ids,CONTAINS a.ts -> a.ts::ids,CALLS a.ts::ids -> nextIdThat leaves sagas, iterators and async streams out of
callers_of, impact radius, test gaps and dead code.parser.py: addgenerator_function_declarationto_FUNCTION_TYPESforjavascript,typescriptandtsx.parser.py: addgenerator_functionto_JS_FUNC_VALUE_TYPES, which both the variable-assigned and member-assigned function handlers use.refactor.pyalready lists both node types, so only the parser was missing them.How it was tested
TestJsGeneratorFunctionsintests/test_parser.py. It covers declarations in.js,.tsand.tsx, an async generator, and generator expressions assigned to a variable and to a member. All 6 tests fail onstagingand pass with this change.pytest tests/test_parser.py tests/test_parser_grammar_contract.py tests/test_multilang.py tests/test_typescript_node_extensions.py tests/test_typescript_declaration_gaps.py tests/test_js_module_resolution.py tests/test_storybook_dead_code.py tests/test_rename_imports.py tests/test_refactor.py. The grammar contract now also checks the new dispatch name. The only failures are the same 33 Windows path-separator failures thatstaginghas without this change.ruff check code_review_graph/: passes.mypy code_review_graph/ --ignore-missing-imports --no-strict-optional: only the existingfcntl.flockerrors indaemon.py(Windows).bandit -r code_review_graph/ -c pyproject.toml: passes.Environment: Windows 10, Python 3.11, dependencies installed with pip from
pyproject.tomlbecause uv isn't installed here. I didn't run the full suite.Checklist
uv run pytest tests/ --tb=short -q(I ran targeted suites only; the remaining failures also occur onstagingon Windows)uv run ruff check code_review_graph/uv run mypy code_review_graph/ --ignore-missing-imports --no-strict-optional(apart from the existing Windows-onlydaemon.pyerrors)