///|
/// A position in source text. `line` and `column` start at 1. `offset` counts UTF-16 code units
/// from the start of the text, as MoonBit `String` indexes do.
#derive(Eq, Compare, Debug)
pub(all) struct SourcePosition {
line : Int32
column : Int32
offset : Int32
}
///|
/// A range of source text from `start` (inclusive) to `end` (exclusive).
#derive(Eq, Debug)
pub(all) struct SourceSpan {
start : SourcePosition
end : SourcePosition
}
///|
#derive(Eq, Compare, Debug)
pub(all) enum Severity {
Error
Warning
}
///|
/// A problem that a reader found. `code` is a stable identifier, such as `xml-malformed` or
/// `unknown-type`; `message` is for people.
#derive(Eq, Debug)
pub(all) struct Diagnostic {
severity : Severity
code : String
message : String
span : SourceSpan?
}
///|
pub fn Diagnostic::error(
code : String,
message : String,
span? : SourceSpan,
) -> Diagnostic {
{ severity: Error, code, message, span, }
}
///|
pub fn Diagnostic::warning(
code : String,
message : String,
span? : SourceSpan,
) -> Diagnostic {
{ severity: Warning, code, message, span, }
}
///|
pub fn Diagnostic::is_error(self : Diagnostic) -> Bool {
self.severity is Error
}