/** * Which words of a sentence are names this workspace publishes or declares, * and how they are said: pure functions of the reading and the placements, so * a test holding them needs no repository and no index. A word names something * only whole: `check` beside `checkoutPath` names nothing. There is no ranking * and no model; the dictionary is the reading, and the index for identifiers. */ import { type Help } from '@variance-authority/package/help'; import type { FileDeclarations, RankedArea } from '@variance-authority/sense'; /** * What one word names: a package, one of its entrypoints, a name it exports, a * name a file declares, or a file. */ export interface Named { readonly kind: 'package' | 'entrypoint' | 'export' | 'declared' | 'file'; /** The package, the entrypoint, the specifier the name is imported from, the declaring file and line as `at:line`, or the file. */ readonly specifier: string; /** For a declaration or a file: the file, without the line. */ readonly file?: string; /** The package it is or is in; for a declaration or a file, the map package nearest at or above it, empty when none is. */ readonly package: string; /** Whether the reading publishes it; a package the map holds may publish nothing, and a declaration or a file is not published. */ readonly published: boolean; /** On the last declaration or file of a word shown: how many more of its kind there are past it. */ readonly more?: number; } /** Where the identifier-shaped words that name nothing published are declared, and which files are named them: at most a few of each, in the order to show them. */ export type Locate = (words: readonly string[], filesOnly?: ReadonlySet) => ReadonlyMap; /** A word that names something, with everything it names: packages first, then entrypoints, then exports. */ export interface Entity { readonly word: string; readonly names: readonly Named[]; } export interface Classified { /** In the order the asker first wrote each one, each naming only what no earlier word named. */ readonly entities: readonly Entity[]; /** The words that name nothing, in the asker's order, each once. */ readonly plain: readonly string[]; } /** Where a package sits on the code map: its innermost area, absent for one no area took, and its dependency layer. */ export interface Placed { readonly area?: { readonly id: string; readonly name: string; }; readonly layer: number; /** Its directory from the workspace, as the map's scan drew it; empty for the root. */ readonly directory: string; } /** Every package on the code map, placed, and whether the map was folded from the source index as it stands. */ export interface CodeMapPlaces { readonly current: boolean; readonly packages: ReadonlyMap; /** Why the map holds no package, when the index was folded into none. */ readonly unfolded?: string; } /** * Whether a word is shaped as an identifier rather than a word of prose: one * spelled of letters, digits, `_` and `$` alone, with a capital past its first * letter, an underscore, or a digit after a letter. */ export declare function identifier(word: string): boolean; /** * The asker's words: a scoped name, a path and an identifier stay whole, and * the punctuation a sentence puts around them is dropped. */ export declare function wordsOf(text: string): readonly string[]; /** * The words of `text` that are, whole, one of `packages` (scoped or not) or an * entrypoint `help` publishes, both without case, or an export it publishes as * spelled; or, shaped as an identifier and no package or entrypoint, a name * `locate` finds declared or a file it finds named — of an export, only the * files, as the export already says where it is declared; and the words that * are not. */ export declare function classifyWords(text: string, help: Help, packages: Iterable, locate?: Locate): Classified; /** An area of the tree, with the package it sits in when a manifest at or above it names one. */ export type PlacedArea = RankedArea & { readonly package?: string; }; /** * Each area in the map package whose directory is nearest at or above it, * under the name the map gives that package; an area above every package on * the map is in none. */ export declare function placedAreas(areas: readonly RankedArea[], packages: ReadonlyMap): readonly PlacedArea[]; /** The name the map gives the package whose directory is nearest at or above a path, or none when every one is below or beside it. */ export declare function ownerOf(packages: ReadonlyMap): (path: string) => string | undefined; /** The start point the asker said, by the flag that said it. */ export type StartPoint = { readonly from?: readonly string[]; readonly to?: readonly string[]; }; /** * The entities, one line per thing each names with its place on the code map, * then the plain words on one line, then the areas of the tree the words point * to, best first, each with its package and that package's place on the map. */ export declare function formatClassified({ entities, plain }: Classified, { current, packages, unfolded }: CodeMapPlaces, areas?: readonly PlacedArea[], said?: StartPoint): string; /** * The files a classified request names, in the order its words name them: the * source files a word names, else the first source file that declares it — an * export's declaring file, or else the first declarer in the order classify * lists them — else the tests and stories it names. Under a start point, * `inReach` says which files it reaches, and a file it does not reach is not * named. */ export declare function namedFiles({ entities }: Classified, inReach?: (file: string) => boolean): readonly string[]; /** The words whose tracked files outnumber the rows classify shows, with how many it left out. */ export declare function unshownFiles({ entities }: Classified): readonly { readonly word: string; readonly more: number; }[]; /** * The block classify ends with: one row per named file with the functions and * classes it declares at its top level, exported first, then by line, under a * line saying they are the answer, since a reader handed files and no reason to * stop at them answers with their folder. Every file in `asked` gets its row, * one `read` holds nothing of or one with nothing to list saying why, and every * row says so when `read` is absent, as no index was published; nothing at all * when no file is named. */ export declare function formatNamedFiles(asked: readonly string[], read: readonly FileDeclarations[] | undefined, { rest, scoped, unshown }?: { readonly rest?: boolean; readonly scoped?: boolean; readonly unshown?: readonly { readonly word: string; readonly more: number; }[]; }): string; //# sourceMappingURL=classify-words.d.ts.map