import { type Advisory, type Diagnostic } from "./diagnostic.ts"; import { type SourceText, type Span } from "./source.ts"; export interface AdvisorySuppression { /** The advisory code this clause names, such as `A1`. */ readonly code: string; /** The reason written after the colon, with the surrounding whitespace removed. */ readonly reason: string; /** The clause itself, from `velar-allow` through the end of the reason. */ readonly span: Span; /** * The range a deletion takes with it, which is wider than `span`: the * whitespace ahead of the clause, the `//` when the clause owns the whole * comment, and the line itself when the comment owns the whole line. */ readonly removal: Span; } export interface AdvisorySuppressionScan { readonly suppressions: readonly AdvisorySuppression[]; readonly diagnostics: readonly Diagnostic[]; /** * Where the comment's own text ends: the start of its first `velar-allow` * clause when it carries one, and the trimmed end of the comment otherwise. * An advisory that reads comment text — A1 reads it to decide whether the * tail of the line is a bare arithmetic expression — must read * `[bodyStart, contentEnd)` rather than the whole comment. D89's own example * shows why: * * const step = total // 2 // velar-allow A1: 2 is a step number * * There is one comment there, not two, so A1 measured over the whole comment * would see letters, refuse to fire, and turn the suppression that was * written for it into a stale one. `contentEnd` cuts at the clause, and the * `//` an author writes to set the clause apart goes with it. */ readonly contentEnd: number; } /** * Reads the `velar-allow` clauses of one line comment. `commentStart` is the * comment's first character, `bodyStart` the first character of its text, and * `commentEnd` the end of the physical line. */ export declare function scanAdvisorySuppressions(text: string, commentStart: number, bodyStart: number, commentEnd: number): AdvisorySuppressionScan; export interface AdvisoryResolution { /** The advisories that survived; a suppressed one is gone rather than marked. */ readonly advisories: readonly Advisory[]; /** The stale-suppression failures, which belong to the diagnostic channel. */ readonly diagnostics: readonly Diagnostic[]; /** * D114 MD-I4: the suppressions this stage may neither apply nor call stale, * because they name an advisory only the project graph can raise * (`PROJECT_GRAPH_ADVISORY_CODES`). They are handed on to the stage that owns * that graph; a compile with no project driver above it simply drops them, * which is the same silence a `velar-allow` on a module that was never * compiled in a project already has. */ readonly deferred: readonly AdvisorySuppression[]; } /** * Applies the suppressions of a compile to its advisories. A suppression * matches an advisory by line and by code, so it sits on the line the advisory * points at and covers nothing else. * * `reportStale` is false where a stage that would have reported the advisory * did not run — an earlier failure kept analysis from starting, or the caller * only lexed and parsed. Answering "this advisory did not fire" there would * blame the author for the compile stopping short. A project-graph code is the * same argument made permanent: this stage is never the one that would have * reported it. */ export declare function resolveAdvisorySuppressions(source: SourceText, advisories: readonly Advisory[], suppressions: readonly AdvisorySuppression[], options: { readonly reportStale: boolean; }): AdvisoryResolution; /** * D114 MD-I4: applies a module's deferred `velar-allow` clauses to advisories * the project graph raised over that module after its compile finished, and * reports the ones that suppressed nothing. * * The matching rule is the one `resolveAdvisorySuppressions` uses — same line, * same code — because an author writing `// velar-allow A18: …` on an import * line is doing exactly what they do for `A1`, and must not have to learn that * one id in the roster answers differently. * * CO-I2: staleness is decided here too, and only here. The charter's third * suppression rule — a `velar-allow` that suppresses nothing is an error — was * simply false for the project-graph codes: a rotted `// velar-allow A18` could * sit on an import line forever, telling every later reader that a cycle it had * outlived was deliberate. The reason it could not be decided during the * compile is that the compile is not the stage that raises A18; this caller * *is* that stage, and it has read the whole graph before it asks. */ export declare function resolveDeferredAdvisorySuppressions(source: SourceText, advisories: readonly Advisory[], deferred: readonly AdvisorySuppression[]): { readonly advisories: readonly Advisory[]; readonly diagnostics: readonly Diagnostic[]; }; //# sourceMappingURL=advisory-suppression.d.ts.map