A single diagnostic — an error, warning, info, or hint tied to a location.
Source-agnostic: LSP servers, external linters, compilers, and test runners
all produce the same struct. The source field identifies the producer
(e.g., "expert", "mix_compile").
Summary
Types
The LSP position encoding used by range columns.
A zero-indexed source location range. Columns are raw offsets in the diagnostic's encoding.
Severity level, ordered from most to least severe.
A diagnostic entry.
Functions
Compares two severities. Returns :lt, :eq, or :gt.
Returns the diagnostic end position as a byte-column position for the given line text.
Returns the more severe of two severities.
Sorts diagnostics by line, then column, then severity (most severe first).
Returns the diagnostic start position as a byte-column position for the given line text.
Types
@type encoding() :: :utf8 | :utf16 | :utf32
The LSP position encoding used by range columns.
@type position() :: {line :: non_neg_integer(), col :: non_neg_integer()}
@type range() :: %{ start_line: non_neg_integer(), start_col: non_neg_integer(), end_line: non_neg_integer(), end_col: non_neg_integer() }
A zero-indexed source location range. Columns are raw offsets in the diagnostic's encoding.
@type severity() :: :error | :warning | :info | :hint
Severity level, ordered from most to least severe.
@type t() :: %Minga.Diagnostics.Diagnostic{ code: String.t() | integer() | nil, encoding: encoding(), message: String.t(), range: range(), severity: severity(), source: String.t() | nil }
A diagnostic entry.
Functions
Compares two severities. Returns :lt, :eq, or :gt.
:error is the most severe (lowest rank).
Examples
iex> Minga.Diagnostics.Diagnostic.compare_severity(:error, :warning)
:lt
iex> Minga.Diagnostics.Diagnostic.compare_severity(:hint, :error)
:gt
Returns the diagnostic end position as a byte-column position for the given line text.
Returns the more severe of two severities.
Examples
iex> Minga.Diagnostics.Diagnostic.more_severe(:warning, :error)
:error
iex> Minga.Diagnostics.Diagnostic.more_severe(:info, :hint)
:info
Sorts diagnostics by line, then column, then severity (most severe first).
Returns the diagnostic start position as a byte-column position for the given line text.