//#region src/core/source/types.d.ts interface BaseSourceFile { contentHash: string; language: string; path: string; } /** * Carried on a file target under `metadata.calls`, in source order. * * Every call in the file, including those outside any function: a consumer counting how often a * name is used has to see the uses, not just the definitions. */ interface CallSite extends SourceMetadataObject { /** The last segment only: `a.b.helper()` and `helper()` both yield `helper`. */ name: string; /** Absolute, into the file's text. */ range: SourceRange; } type ClassTarget = PlannedSourceTargetOfKind<'class'>; type FileTarget = PlannedSourceTargetOfKind<'file'>; /** * Carried under `metadata.function`, so a consumer can fingerprint, count and classify a function * without reaching for a parser of its own. * * Every producer of function targets should fill it in; a consumer still validates the expected * domain fields when reading the recursive JSON metadata contract. * * Ranges are relative to the target's own `text`, not to the file, so a consumer can slice that * text directly and never has to rebase. */ interface FunctionInfo extends SourceMetadataObject { /** * Stricter than one statement: a body that is one `if` and its two returns is one statement and * not one expression. */ bodyIsSingleExpression: boolean; /** Statements in the body, not counting comments. */ bodyStatements: number; commentRanges: readonly SourceRange[]; /** * The names the function declares: its own name, its parameters and its locals. * * A copy can rename what it declares and stay a copy, so this is the set an α-renaming * fingerprint may replace. Everything else — callees, globals, types, properties — stays * verbatim and is what tells two same-shaped functions apart. */ declaredNames: readonly string[]; /** Reachable from outside its file, however the language spells it. */ exported: boolean; /** * Identifiers that MAY be renamed away, which is narrower than "every identifier token". * * Property, field and type names must not be here: replacing them collapses `entry.name` and * `entry.size` into the same fingerprint, which is the mistake this set exists to avoid. */ identifierRanges: readonly SourceRange[]; } type FunctionTarget = PlannedSourceTargetOfKind<'function'>; interface LanguageContext { cwd: string; languageOptions: Record; src: SourceRuntime; } interface LineRange { endLine: number; startLine: number; } interface PlannedSourceTarget { file: BaseSourceFile; identity: string; kind: SourceTargetKind; language: string; loc?: SourceLocation; metadata?: SourceTargetMetadata; name?: string; origin?: SourceTargetOrigin; range?: SourceRange; } type PlannedSourceTargetOfKind = Omit & { kind: Kind; }; interface ProcessedSource { identity: string; language?: string; origin?: ProcessedSourceOrigin; path: string; text: string; } interface ProcessedSourceOrigin { physicalPath: string; range?: SourceRange; virtualPath?: string; } interface ProcessorContext { cwd: string; options: Record; src: SourceRuntime; } interface ProcessorPostprocessContext extends ProcessorContext { file: SourceFile; processedSources: ProcessedSource[]; } interface SourceExtractOptions { /** * Overrides the file's configured `language:` pin. * * For a caller walking a mixed tree, where the file's own config cannot know what each file is. */ language?: string; } interface SourceFile extends BaseSourceFile { lines: string[]; text: string; } interface SourceLocation { end: SourcePosition; start: SourcePosition; } interface SourceMetadataObject { readonly [key: string]: SourceMetadataValue; } type SourceMetadataValue = boolean | null | number | readonly SourceMetadataValue[] | SourceMetadataObject | SourceRange | string; interface SourcePosition { column: number; line: number; } interface SourceRange { end: number; start: number; } interface SourceRuntime { /** * Targets for any file, linted or not. * * Resolves the file's own config the way linting does, resolves its language from that config, * and runs that language's extract. A rule handed `ProjectTarget.files`, or an index builder * sweeping files outside the lint set, has no other way to parse them. * * An ignored file extracts to `[]` rather than throwing: sweeping broadly and skipping what the * config excluded is the normal case, not an error. * * Only wired inside a run. A runtime built by `createSourceRuntime()` with no extractor throws, * because there is no config to resolve the file against. */ extract: (filePath: string, options?: SourceExtractOptions) => Promise; getText: (file: SourceFile) => string; readFile: (file: BaseSourceFile | string) => Promise; sliceLines: (file: SourceFile, range: LineRange) => SourceText; sliceRange: (file: SourceFile, range: SourceRange) => SourceText; } interface SourceTarget { file: SourceFile; identity: string; kind: SourceTargetKind; language: string; loc?: SourceLocation; metadata?: SourceTargetMetadata; name?: string; origin?: SourceTargetOrigin; range?: SourceRange; text: string; } type SourceTargetKind = 'class' | 'file' | 'fragment' | 'function' | 'symbol' | (string & {}); type SourceTargetMetadata = Readonly>; type SourceTargetOfKind = Omit & { kind: Kind; }; interface SourceTargetOrigin { physicalPath: string; range?: SourceRange; virtualPath?: string; } interface SourceText { filePath: string; loc: SourceLocation; text: string; } //#endregion export { SourceTarget as C, SourceTargetOrigin as D, SourceTargetOfKind as E, SourceText as O, SourceRuntime as S, SourceTargetMetadata as T, SourceLocation as _, FunctionInfo as a, SourcePosition as b, LineRange as c, ProcessedSource as d, ProcessedSourceOrigin as f, SourceFile as g, SourceExtractOptions as h, FileTarget as i, PlannedSourceTarget as l, ProcessorPostprocessContext as m, CallSite as n, FunctionTarget as o, ProcessorContext as p, ClassTarget as r, LanguageContext as s, BaseSourceFile as t, PlannedSourceTargetOfKind as u, SourceMetadataObject as v, SourceTargetKind as w, SourceRange as x, SourceMetadataValue as y };