Skip to content

package diagnostic

import "github.com/cloudboss/unobin/pkg/diagnostic"

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

type Span

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