Documentation
¶
Overview ¶
Package diag exposes error types used throughout River and a method to pretty-print them to the screen.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Diagnostic ¶
type Diagnostic struct {
// Severity holds the severity level of this Diagnostic.
Severity Severity
// StartPos refers to a position in a file where this Diagnostic starts.
StartPos token.Position
// EndPos refers to an optional position in a file where this Diagnostic
// ends. If EndPos is the zero value, the Diagnostic should be treated as
// only covering a single character (i.e., StartPos == EndPos).
//
// When defined, EndPos must have the same Filename value as the StartPos.
EndPos token.Position
Message string
Value string
}
Diagnostic is an individual diagnostic message. Diagnostic messages can have different levels of severities.
func (Diagnostic) As ¶
func (d Diagnostic) As(v interface{}) bool
As allows d to be interpreted as a list of Diagnostics.
type Diagnostics ¶
type Diagnostics []Diagnostic
Diagnostics is a collection of diagnostic messages.
func (*Diagnostics) Add ¶
func (ds *Diagnostics) Add(d Diagnostic)
Add adds an individual Diagnostic to the diagnostics list.
func (Diagnostics) ErrorOrNil ¶
func (ds Diagnostics) ErrorOrNil() error
ErrorOrNil returns an error interface if the list diagnostics is non-empty, nil otherwise.
func (Diagnostics) HasErrors ¶
func (ds Diagnostics) HasErrors() bool
HasErrors reports whether the list of Diagnostics contain any error-level diagnostic.
type Printer ¶
type Printer struct {
// contains filtered or unexported fields
}
A Printer pretty-prints Diagnostics.
func NewPrinter ¶
func NewPrinter(cfg PrinterConfig) *Printer
NewPrinter creates a new diagnostics Printer with the provided config.
type PrinterConfig ¶
type PrinterConfig struct {
// When Color is true, the printer will output with color and special
// formatting characters (such as underlines).
//
// This should be disabled when not printing to a terminal.
Color bool
// ContextLinesBefore and ContextLinesAfter controls how many context lines
// before and after the range of the diagnostic are printed.
ContextLinesBefore, ContextLinesAfter int
}
PrinterConfig controls different settings for the Printer.