types/code.types.ts

types/code.types.ts is a file in Bane's Lab Site. 41 lines of code and 7 definitions.

import type { DefinitionLocation } from "#types/anatomy.types";

export interface TemplateParts {
    readonly holes: readonly string[];
    readonly literals: readonly string[];
}

export interface CandidateLocation {
    readonly file: string;
    readonly line: number | null;
    readonly name: string;
}

export type CodeTarget =
    | { readonly kind: "candidates"; readonly locations: readonly CandidateLocation[] }
    | { readonly kind: "definition"; readonly location: DefinitionLocation }
    | { readonly kind: "file"; readonly path: string }
    | { readonly kind: "folder"; readonly path: string }
    | { readonly kind: "record"; readonly ref: string };

export interface Binding {
    readonly column: number;
    readonly file: string;
    readonly line: number;
    readonly module: boolean;
    readonly name: string;
    readonly target: number;
}

export interface CodeFile {
    readonly absolute: string;
    readonly path: string;
}

export interface ReferenceLookups {
    readonly bindings: (path: string) => readonly Binding[] | null;
    readonly records: ReadonlySet<string>;
    readonly ruleRecord: (text: string) => string | null;
    readonly slotDeclaration: (path: string) => string | null;
}

export interface SourceReferences {
    readonly sites: readonly number[];
    readonly spans: Readonly<Record<string, CodeTarget>>;
    readonly strings: Readonly<Record<string, CodeTarget>>;
    readonly targets: readonly CodeTarget[];
    readonly words: Readonly<Record<string, CodeTarget>>;
}