Skip to main content

Module inventory

Module inventory 

Source
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:

  1. Parent-provided pending_name (from MethodDefinition, VariableDeclarator), same pattern as the internal complexity visitor.
  2. The function’s own id (named function foo() {}, named function expression const x = function named() {}).
  3. (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§

InventoryEntry
A single static-inventory entry: (name, line) for one function.

Functions§

walk_source
Parse source at path and return every function as an InventoryEntry.