diagnostic

package
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 4, 2022 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Cause

func Cause(err error) string

func Color

func Color(ctx context.Context) aurora.Aurora

func DisplayError

func DisplayError(ctx context.Context, w io.Writer, spans []*SpanError, err error, printBacktrace bool)

func FormatPos

func FormatPos(pos lexer.Position) string

FormatPos returns a lexer.Position formatted as a string.

func Levenshtein

func Levenshtein(s1, s2 []rune) int

Levenshtein returns the levenshtein distance between two rune arrays.

This implementation translated from the optimized C code at https://en.wikibooks.org/wiki/Algorithm_Implementation/Strings/Levenshtein_distance#C

func Offset

func Offset(pos lexer.Position, offset int, line int) lexer.Position

func Suggestion

func Suggestion(value string, candidates []string) string

func WithColor

func WithColor(ctx context.Context, color aurora.Aurora) context.Context

func WithError

func WithError(err error, pos, end lexer.Position, opts ...Option) error

Types

type Error

type Error struct {
	Err         error
	Diagnostics []error
}

func (*Error) Error

func (e *Error) Error() string

func (*Error) Unwrap

func (e *Error) Unwrap() error

type Option

type Option func(*SpanError)

func Spanf

func Spanf(t Type, start, end lexer.Position, format string, a ...interface{}) Option

type PrettyInfo

type PrettyInfo struct {
	NumContext int
}

type PrettyOption

type PrettyOption func(*PrettyInfo)

func WithNumContext

func WithNumContext(num int) PrettyOption

type Span

type Span struct {
	Message string
	Type    Type
	Start   lexer.Position
	End     lexer.Position
}

type SpanError

type SpanError struct {
	Err      error
	Pos, End lexer.Position
	Spans    []Span
}

func SourcesToSpans

func SourcesToSpans(ctx context.Context, srcs []*errdefs.Source, err error) (spans []*SpanError)

func Spans

func Spans(err error) (spans []*SpanError)

func (*SpanError) Error

func (se *SpanError) Error() string

func (*SpanError) Pretty

func (se *SpanError) Pretty(ctx context.Context, opts ...PrettyOption) string

func (*SpanError) Unwrap

func (se *SpanError) Unwrap() error

type Type

type Type int
const (
	Primary Type = iota
	Secondary
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL