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: from aMethodDefinition/VariableDeclaratorbinding, OR from the callee of the call /newexpression a function is passed to as an argument (arr.map(cb)-> “map”,foo(cb)-> “foo”,new Promise(cb)-> “Promise”). The callee case matchesoxc-coverage-instrument’s opt-inname_callback_arguments(which the Fallow runtime beacon enables), so a callback’s static name lines up with its runtime-instrumented name instead of both sides drifting to different anonymous placeholders. - The function’s own
id(namedfunction foo() {}, named function expressionconst x = function named() {}). (anonymous_N)with the current counter value; counter then increments. Only genuinely unnamed functions reach this: an immediately-invoked function expression, an arrow returned from another function, or a computed non-string-key call.
Counter scope is per-file. Reference implementation:
oxc-coverage-instrument/src/transform.rs (resolve_function_name +
callback_argument_name).
Structs§
- Inventory
Complexity - Per-function static complexity collected alongside the inventory walk.
- Inventory
Entry - A single static-inventory entry for one function.
Functions§
- walk_
source - Parse
sourceatpathand return every function as anInventoryEntry. - walk_
source_ with_ complexity - Parse
sourceatpathonce and return every function as anInventoryEntrytogether with asource_hash -> InventoryComplexitymap.