Source-aware diagnostic reports for MoonBit developer tools
let sources = @report.SourceMap::new()
let id = sources.add("app.conf", "port = 70000")
let problem = @report.Diagnostic::new(Error, "invalid port")
.with_code("CFG002")
.with_label(
@report.Label::primary(
id,
@report.Span::new(7, 12).unwrap(),
"expected a value from 1 to 65535",
),
)
.with_help("try port 8080")
println(@report.render(sources, problem))moon run cmd/mainmoon check --deny-warn
moon test
moon fmt --check
moon build
moon info
moon run cmd/mainfn DiagnosticBag::render(self : DiagnosticBag, sources : SourceMap, config? : RenderConfig) -> Stringfn DiagnosticPolicy::limits(self : DiagnosticPolicy, advice? : Int?, warnings? : Int?, errors? : Int?, total? : Int?) -> DiagnosticPolicyfn DiagnosticPolicy::with_deduplication(self : DiagnosticPolicy, enabled : Bool) -> DiagnosticPolicyfn DiagnosticPolicy::with_warnings_as_errors(self : DiagnosticPolicy, enabled : Bool) -> DiagnosticPolicyfn Fix::apply_to_source(self : Fix, sources : SourceMap, source_id : SourceId) -> (String?, FixValidation)pub struct FixPlanSummary {
total_fixes : Int
selected_fixes : Int
skipped_fixes : Int
selected_edits : Int
}pub(all) enum FixPlanValidation {
PlanValid
EmptyPlan
NoSelectedFixes
InvalidPlannedFix(Int, FixValidation)
ConflictingPlannedFixes(FixValidation)
} derive(Eq, Debug)pub struct PolicyResult {
emitted : DiagnosticBag
suppressed : Array[SuppressedDiagnostic]
summary : PolicySummary
}pub struct PolicySummary {
input : Int
emitted : Int
promoted : Int
suppressed : Int
duplicates : Int
budgeted : Int
}fn RenderConfig::new(context_lines? : Int, tab_width? : Int, show_source_name? : Bool, show_code? : Bool) -> RenderConfigfn render_all(sources : SourceMap, diagnostics : Array[Diagnostic], config? : RenderConfig) -> Stringfn render_ansi(sources : SourceMap, diagnostic : Diagnostic, enabled? : Bool, theme? : Theme, config? : RenderConfig) -> Stringfn strip_ansi(text : String) -> StringSource-aware diagnostic reports for MoonBit developer tools