import type { DiagnosticCode, DiagnosticValues } from '../catalogue/index.js'; import type { Span } from '../span/index.js'; import type { Diagnostic } from './diagnostic.js'; /** * What a stage is handed so it can report. * * A stage takes the narrow interface rather than the bag, so a stage can be * driven by an editor that wants diagnostics streamed to it and by a compile * that wants them collected, without either of them being the stage's business. */ export interface DiagnosticSink { report(code: Code, span: Span, values: DiagnosticValues[Code]): void; } /** * Gathers diagnostics instead of throwing on the first one. * * A trader who has three syntax errors in a file wants to see three, not one * per compile. A compiler that throws makes the second error cost a whole * edit-and-run cycle to discover, and it is the same file, so the cost is paid * for nothing. * * The bag refuses an exact repeat: the same code over the same span, which is * what a parser that recovers and re-enters the same construct produces. It * refuses nothing else, so two different codes on one character both survive * and the reader decides which one they believe. */ export declare class DiagnosticBag implements DiagnosticSink { #private; report(code: Code, span: Span, values: DiagnosticValues[Code]): void; add(diagnostic: Diagnostic): void; /** Everything reported, in the order it was reported. */ get all(): readonly Diagnostic[]; get isEmpty(): boolean; /** Whether compilation has to stop. A file with only warnings still runs. */ get hasErrors(): boolean; get errors(): readonly Diagnostic[]; get warnings(): readonly Diagnostic[]; /** * Everything reported, in the order a reader walks the file. * * Stages report in the order they run, so a checker warning about line 2 * arrives after a parser error about line 40. A reader reads top to bottom. * * **The order is total, and it depends on nothing outside the program.** Two * engines handed the same diagnostics have to print them in the same order, so * the tie after the offset is the span's length and then the code compared by * code point. It was a locale comparison, which `compiled-program.md` 8.4 * forbids by name: the same two codes order differently under different * collation rules, and the machine that is set up differently is the one * nobody is looking at. Length is in the comparison because without it two * diagnostics sharing a code and an offset tie, and a tie leaves the answer to * whether the sort happens to be stable, which is a property of the engine * rather than of the language. With it, nothing can tie: the bag already * refuses a second diagnostic with the same code, offset and length. */ ordered(): readonly Diagnostic[]; } //# sourceMappingURL=collector.d.ts.map