/** * Shared walk scaffolding for the tree-sitter adapters. * * The actual node traversal (`visit` / `walkFile`) is language-specific * and stays in each adapter. What is duplicated — and moves here — is: * * - `record(out, occ)` — the occurrence-sink append. * - `makeFileClassifier(...)` — the regex-parameterized * `isTestFile` / `isGeneratedFile` * predicates. * - `runWalk({ input, walkFile })`— the `walkProject` driver skeleton: * allocate the output sinks, filter + * sort `input.files`, per-file * try/catch → `ParseError`. * - `synthesizeModuleInit(...)` — the module-init `FunctionOccurrence` * skeleton (top-level-text join → * `digestSyntheticBody` → occurrence). * The `qualifiedName` shape differs per * language and is passed in. */ import { nameOf, childrenOf, namedChildrenOf } from '@opensip-tools/tree-sitter'; import type { TreeSitterParsedFile, TreeSitterParsedProject } from './parse.js'; import type { BodyDigest, CallSiteRecord, DependencySiteRecord, FunctionOccurrence, WalkInput, WalkOutput } from '@opensip-tools/graph'; /** Append an occurrence into the by-simple-name occurrence sink. */ export declare function record(out: Record, occ: FunctionOccurrence): void; /** Regex inputs for the shared file classifier. */ export interface FileClassifierConfig { /** Matches a test file by name (e.g. `*_test.go`, `*Test.java`). */ readonly testRe: RegExp; /** Matches a generated / build-output path. */ readonly generatedRe: RegExp; /** * Optional path-based test matcher (e.g. `src/test/`, `tests/`). When * present, a file is a test file if EITHER `testPathRe` or `testRe` * matches. Go omits this (the `_test.go` name convention is exact); * java/python/rust supply it. */ readonly testPathRe?: RegExp; } /** The bound file-classification predicates. */ export interface FileClassifier { readonly isTestFile: (rel: string) => boolean; readonly isGeneratedFile: (rel: string) => boolean; } /** Builds `isTestFile` / `isGeneratedFile` bound to the given regexes. */ export declare function makeFileClassifier(config: FileClassifierConfig): FileClassifier; /** * The three output accumulators a per-file walk appends into. Grouping * them keeps `walkFile` (and the adapter `visit` helpers that thread * them) under the wide-function parameter budget, and names the cohesive * "walk output" concept the driver allocates once per project. */ export interface WalkSinks { /** By-simple-name occurrence sink (the engine's `out` map). */ readonly occurrences: Record; /** Flat list of call sites discovered across the file. */ readonly callSites: CallSiteRecord[]; /** Flat list of dependency (import) sites discovered across the file. */ readonly dependencySites: DependencySiteRecord[]; } /** Inputs to the shared `walkProject` driver. */ export interface RunWalkParams

{ readonly input: WalkInput

; /** * The adapter's per-file walk: visits one file's AST and pushes * occurrences / call sites / dependency sites into the supplied sinks. */ readonly walkFile: (absPath: string, file: P['files'] extends ReadonlyMap ? F : never, projectDirAbs: string, sinks: WalkSinks) => void; } /** * Drives `walkProject`: allocate the output sinks, iterate * `input.files` (filtered to parsed files, sorted for I-1 determinism), * and run `walkFile` per file with a try/catch that records a * `ParseError` on failure. */ export declare function runWalk

(params: RunWalkParams

): WalkOutput; /** Inputs to the shared module-init occurrence builder. */ export interface SynthesizeModuleInitParams { readonly file: F; readonly filePathProjectRel: string; readonly inTestFile: boolean; readonly definedInGenerated: boolean; /** The adapter's synthetic-body digest (same normalization as real bodies). */ readonly digestSyntheticBody: (text: string) => BodyDigest; /** * The fully-built `qualifiedName` for the synthetic `` * occurrence — language-specific (extension strip + separator differ: * `pkg/file.` for go, `a.b.` for python, * `a::b::` for rust, …). Computed by the adapter. */ readonly qualifiedName: string; } /** * Build the synthetic `` `FunctionOccurrence`: hash the * file's top-level statement-text concatenation and assemble the * occurrence with the adapter-supplied `qualifiedName`. */ export declare function synthesizeModuleInit(params: SynthesizeModuleInitParams): FunctionOccurrence; export { nameOf, childrenOf, namedChildrenOf }; /** * Build a simple-name → bodyHash[] index from the walk's occurrence map. * Skips synthetic names (those starting with `<`); only real names are * resolution targets. Language-agnostic (operates on the engine's * `FunctionOccurrence` record), so it is shared by every resolver that * needs it (go / java / python; rust resolves differently). */ export declare function buildNameIndex(functions: Readonly>): ReadonlyMap; //# sourceMappingURL=walk.d.ts.map