Expand description
Function inventory walker for fallow coverage upload-inventory.
Emits one InventoryEntry per function (declaration, expression, arrow,
method) whose name matches what oxc-coverage-instrument produces at
instrument time. This is the static side of the three-state production
coverage story: uploaded inventory minus runtime-seen functions equals
untracked.
§Naming contract
The cloud stores function identity as
(filePath, functionName, lineNumber). This walker is responsible for the
functionName and lineNumber parts of that contract. Anonymous functions
are named (anonymous_N) where N is a file-scoped monotonic counter that
starts at 0 and increments in pre-order AST traversal each time a function
is entered without a resolvable explicit name. Name resolution precedence:
- Parent-provided
pending_name(fromMethodDefinition,VariableDeclarator), same pattern as the internal complexity visitor. - The function’s own
id(namedfunction foo() {}, named function expressionconst x = function named() {}). (anonymous_N)with the current counter value; counter then increments.
Counter scope is per-file. Reference implementation:
oxc-coverage-instrument/src/transform.rs (fn_counter field; lines 201
and 612 at the time of writing).
Structs§
- Inventory
Entry - A single static-inventory entry:
(name, line)for one function.
Functions§
- walk_
source - Parse
sourceatpathand return every function as anInventoryEntry.