docs(cfg): correct the Kotlin and Python grammar-field notes (#3354)

The Kotlin CFG visitor claimed no control-flow node has fields; a parse of
the vendored grammar shows if_expression fields condition/consequence/
alternative (when/for/while/do/try/elvis are fieldless). The Python harvest
note listed conditional_expression's children like field names; the node is
fieldless and they are positional. Both notes were misleading reviewers of
the #3354 value-alternatives hooks. Comment-only.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Gergo Magyar 2026-09-25 18:49:59 +00:00
parent 37dc404341
commit 587347ba17
2 changed files with 6 additions and 5 deletions

View file

@ -3,9 +3,10 @@
*
* Kotlin's tree-sitter grammar (vendored, NOT an npm package — loaded via
* `requireVendoredGrammar('tree-sitter-kotlin')`, exactly like tree-sitter-swift)
* is field-less for control flow: NONE of the control-flow nodes expose
* `childForFieldName` fields (verified by a real parse — every `fieldNameForChild`
* came back null), so this visitor navigates purely by child TYPE and position.
* is mostly field-less for control flow (`when` / loops / `try` / `elvis_expression`
* expose no fields), so this visitor navigates purely by child TYPE and position.
* `if_expression` is the exception: it DOES field `condition` / `consequence` /
* `alternative` (#3354 — callable-flow capture reads them); position still works.
* Every node-type literal below was grammar-validated against the vendored
* tree-sitter-kotlin via the introspection probe before use (mandatory pre-step —
* the grammar-literal CI gate maps `kotlin.ts → Kotlin` and fails on a wrong

View file

@ -46,8 +46,8 @@
* - reads: `attribute` (fields `object`/`attribute`), `subscript` (fields
* `value`/`subscript`), `call` (fields `function`/`arguments`),
* `boolean_operator` (fields `left`/`operator`/`right`),
* `conditional_expression` (ternary: consequent / condition / alternative in
* source order), `parenthesized_expression`.
* `conditional_expression` (ternary, FIELDLESS: consequent, condition,
* alternative as positional children), `parenthesized_expression`.
*
* TWO-PHASE, ORDER-INDEPENDENT (load-bearing — mirrors the TS / Go harvesters):
* the CFG walk is NOT source-order, so resolving names against a scope stack