diagnostic

package
v0.11.0-a.13 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Context

func Context(message string, err error) error

func Report

func Report(r Reporter, d Diagnostic)

func WriteText

func WriteText(out io.Writer, d Diagnostic) error

Types

type Collector

type Collector struct {
	// contains filtered or unexported fields
}

func (*Collector) Diagnostics

func (c *Collector) Diagnostics() []Diagnostic

func (*Collector) HasErrors

func (c *Collector) HasErrors() bool

func (*Collector) Report

func (c *Collector) Report(d Diagnostic)

type ConvertOptions

type ConvertOptions struct {
	DefaultCode string
	Path        func(string) string
}

type Diagnostic

type Diagnostic struct {
	Code     string   `json:"code"               ub:"code"`
	Severity Severity `json:"severity"           ub:"severity"`
	Message  string   `json:"message"            ub:"message"`
	Hint     string   `json:"hint,omitempty"     ub:"hint,omitempty"`
	Path     string   `json:"path,omitempty"     ub:"path,omitempty"`
	Span     *Span    `json:"span,omitempty"     ub:"span,omitempty"`
}

func FromError

func FromError(err error, opts ConvertOptions) []Diagnostic

func Merge

func Merge(groups ...[]Diagnostic) []Diagnostic

func Normalize

func Normalize(ds []Diagnostic) []Diagnostic

type PathMapper

type PathMapper struct {
	WorkingDir  string
	ProjectDir  string
	Mappings    []PathMapping
	HiddenRoots []string
}

func (PathMapper) Display

func (m PathMapper) Display(path string) string

func (PathMapper) ReplaceKnownPrefixes

func (m PathMapper) ReplaceKnownPrefixes(message string) string

type PathMapping

type PathMapping struct {
	AbsoluteRoot string
	DisplayRoot  string
}

type Position

type Position struct {
	Line   int `json:"line"   ub:"line"`
	Column int `json:"column" ub:"column"`
	Offset int `json:"offset" ub:"offset"`
}

type Reporter

type Reporter interface {
	Report(Diagnostic)
}

type Severity

type Severity string
const (
	SeverityError   Severity = "error"
	SeverityWarning Severity = "warning"
	SeverityInfo    Severity = "info"
)

type Span

type Span struct {
	Start Position  `json:"start"         ub:"start"`
	End   *Position `json:"end,omitempty" ub:"end,omitempty"`
}

Jump to

Keyboard shortcuts

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