marianoguerra/wax/diagnostic does not have a README file

    Context

    pub struct Context {
    max : Int
    queue : Array[Diagnostic]
    source : String?
    related : Array[Label]
    policy :
    Policy

    render : Render?
    recovery : Bool
    failed : Bool
    }

    A reporting context.

    Context::collected

    fn Context::collected(self : Context) -> Array[Diagnostic]

    The entries accumulated in a collector, neither cleared nor printed.

    Context::failed

    fn Context::failed(self : Context) -> Bool

    Whether an error was reported. The CLI turns this into an exit code.

    Context::in_recovery

    fn Context::in_recovery(self : Context) -> Bool

    Context::report

    Report a diagnostic.

    warning names the warning so the policy can decide its level. It is meaningful for Warning and Suggestion severities and ignored for errors.

    Context::set_recovery

    fn Context::set_recovery(self : Context, v : Bool) -> Unit

    Context::source

    fn Context::source(self : Context) -> String?

    Diagnostic

    One diagnostic.

    Edit

    pub(all) struct Edit {
    loc :
    Location

    new_text : String
    }

    A machine-applicable rewrite: replace the source spanned by loc with new_text. The diagnostic's own message doubles as the quick-fix title.

    Label

    A secondary span with its own note, rendered under the snippet.

    OutputFormat

    pub(all) enum OutputFormat {
    Human
    Json
    Short
    } derive(Eq,
    Debug
    )

    How diagnostics are rendered.

    Render

    type Render

    Where and how a context renders.

    Held only by a RENDERING context; a collector has none, since it merely accumulates entries for a rendering context to re-report later.

    Severity

    pub(all) enum Severity {
    Error
    Warning
    Suggestion
    } derive(Eq,
    Debug
    )

    Severity::header

    fn Severity::header(self : Severity) -> String

    The capitalised word heading a human-format diagnostic.

    Severity::to_str

    fn Severity::to_str(self : Severity) -> String

    Sink

    pub(all) struct Sink {
    write : (String) -> Unit
    flush : () -> Unit
    }

    A destination for rendered diagnostics.

    An indirection rather than a hard-wired stderr, because two consumers need to capture: the differential harness, and the renderer's own tests.

    Theme

    pub(all) struct Theme {
    error_header : String
    warning_header : String
    hint_header : String
    error_label : String
    warning_label : String
    secondary_label : String
    line_numbers : String
    body :
    Theme

    }

    The colours of the diagnostic frame.

    buffer_sink

    fn buffer_sink(buf : StringBuilder) -> Sink

    A sink collecting into a growable buffer. Its flush does nothing.

    collector

    fn collector(parent? : Context?, source? : String?) -> Context

    A context that buffers reported diagnostics without printing or exiting.

    It renders nothing, so it needs none of a rendering context's parameters. source is still worth threading: a lint that inspects the original text runs against this context.

    get_theme

    fn get_theme(color? :
    Flag
    , palette? :
    Theme
    , is_tty? : Bool) -> Theme

    of_report

    Turn a lexer or parser report into a diagnostic.

    The front end produces plain strings; a diagnostic body is a Message, and text is the right constructor for these: they are prose, and prose is what reflows to the terminal width.

    The warning field comes back None however the report named itself: the front end names no warnings, because every report it makes is unconditional and there is nothing for a -W to switch off.

    output_error

    fn output_error(sink : Sink, theme : Theme, format : OutputFormat, source : String?, d : Diagnostic) -> Unit

    Render one diagnostic in whichever format is selected.

    run

    fn[T] run(sink : Sink, color :
    Flag
    , palette :
    Theme
    , source : String?, f : (Context) -> T, format? : OutputFormat, related? : Array[Label], exit_on_error? : Bool, policy? :
    Policy
    , is_tty? : Bool, max? : Int) -> (T, Context)

    Run f in a rendering context, flushing its diagnostics afterwards.

    color and palette are both required: a rendering context must decide up front whether to emit colour, and which source palette to colour embedded AST fragments with, so a caller cannot silently fall back to a default.

    Powered by MoonBit

    Site sourceReport issuePackagesBuild queueSkillsStatistics

    © 2026 mooncakes.io