errata

    Apply machine-applicable fixes safely: refuse overlap, keep order independent, diff before writing. Rendering is delegated to marianoguerra/error-report.

    fix
    autofix
    diagnostic
    refactor
    developer-tools
    Download zip
    Version
    0.2.0
    License
    MIT
    Last updated
    yesterday
    Downloads
    18

    #errata

    ci

    Apply the fixes a tool already knows about, without corrupting the file.

    errata is the missing half of source diagnostics. Rendering a snippet is a solved problem: marianoguerra/error-report already holds the report model and prints rich, short and JSON output. What no MoonBit package does is take a set of machine-applicable fixes and land them safely. errata does that, and reuses error-report for everything else.

    #What this project adds

    CapabilityState
    Check a fix set before touching the file: range, character boundary, intersectionimplemented
    Apply a fix set in one pass, refusing instead of corruptingimplemented
    Order independence: the same set applies the same way whatever the input orderimplemented
    Manifest parsing, grouped per file, one bad line does not hide the restimplemented
    Unified-style diff for a dry runimplemented
    errata fix <manifest> [--write]implemented
    errata render <json-record> <source> through error-reportimplemented
    Fixpoint loop that re-checks after applyingnot implemented
    Report set: sort, dedupe, group, summary counts, exit codesnot implemented

    #What this project deliberately does not do

    • It does not render diagnostics. error-report does, and a second renderer would only drift from it.
    • It does not implement display width, tab expansion or CJK alignment. error-report/render owns those.
    • It does not parse MoonBit syntax, run the compiler, or replace moon fmt.

    #Install

    moon add cp15695540483/errata

    #Usage

    Render one compiler record the toolchain prints:

    moon run cmd/errata -- render '{"level":"error","error_code":4014,"loc":"1:9-1:10","message":"Expr Type Mismatch"}' 'let y = x + 1'

    Preview a fix set (no write):

    moon run cmd/errata -- fix fixes.tsv

    A manifest is one fix per line, tab separated:

    # path start len replacement src/lib.mbt 8 1 y

    Add --write to apply. A file whose text would not change is reported as unchanged, so a second run is visibly a no-op rather than a second edit.

    #From the library

    let fixes : Array[@error-report.Fix] = [
    {
    source: @error-report.SourceId(0),
    span: @error-report.Span::{ start: 8, len: 1 },
    replacement: "y",
    description: "",
    },
    ]
    match @fix.apply("let y = x + 1", fixes) {
    Applied(text) => println(text)
    Refused(reason) => println(@fix.describe(reason))
    }

    #Documentation

    #License

    MIT, see LICENSE.