/** * "Did you mean …": the bounded edit distance behind every unresolved-name * suggestion, and the roster that answers it in constant time. * * D114 R1d: split out of `./scopes.ts` during the move, which came to 827 lines * as one file — over the 800-line budget of D115 §一.1. What lives here is * string distance and a bucketed index of the names in scope; what stays there * is the scope stack those names live in. */ /** The furthest a suggestion may be from what was written. */ export declare const nearestNameLimit = 2; /** * Edit distance, abandoned as soon as it is known to exceed `nearestNameLimit`. * Only cells within that many steps of the diagonal can hold a value inside the * limit, so each row is a fixed-width band rather than the whole right operand, * and a row whose every cell is already over the limit ends the walk. */ export declare function boundedEditDistance(left: string, right: string): number; /** Returns the sole nearest spelling within two edits, never an ambiguous guess. */ export declare function uniqueNearestName(requested: string, candidates: Iterable): string | null; /** `name` with up to `nearestNameLimit` characters deleted, the shared key of any two near spellings. */ export declare function deletionKeys(name: string): readonly string[]; /** * The roster a "did you mean" reads. It used to be rebuilt — core vocabulary, * extension globals, imports, and every name in every live scope — and then run * through a full edit-distance pass, once per unresolved name, which made a * module of typos quadratic in its own size. The roster is now maintained as * scopes come and go, and each name is filed under the strings left by deleting * up to two of its characters: two spellings within two edits always share one * of those, so a query reads a few buckets instead of the whole roster. */ export declare class NearestNameRoster { private readonly counts; /** Filled on the first question asked of the roster; a module with no typo never pays for it. */ private buckets; add(name: string): void; remove(name: string): void; nearest(requested: string): string | null; private file; } //# sourceMappingURL=nearest-names.d.ts.map