diagnostic

package
v0.3.26 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const JSONSchemaVersion = 1

Variables

This section is empty.

Functions

This section is empty.

Types

type Code added in v0.2.4

type Code string

Code is a stable, machine-readable diagnostic identifier. Messages may be improved without changing integrations that use the code.

const (
	SyntaxError        Code = "TRB1000"
	ResolutionError    Code = "TRB2000"
	TypeError          Code = "TRB3000"
	DuplicateBinding   Code = "TRB3001"
	UnusedBinding      Code = "TRB3002"
	ProjectError       Code = "TRB4000"
	ProjectIntegration Code = "TRB4001"
	BackendError       Code = "TRB5000"
)

type Diagnostic

type Diagnostic struct {
	Code     Code
	Severity Severity
	Message  string
	Path     string
	Span     token.Span
	Related  []RelatedInformation
	Fixes    []Fix
}

func Normalize added in v0.2.4

func Normalize(items []Diagnostic, path string, fallback Code) []Diagnostic

Normalize fills phase and source defaults without replacing more specific information recorded at the diagnostic's origin.

func (Diagnostic) String

func (d Diagnostic) String() string

type Fix added in v0.2.4

type Fix struct {
	Message string
	Edits   []TextEdit
}

Fix describes one coherent source change. A fix may contain multiple edits so refactors such as adding an import and replacing a name remain atomic.

type JSONDiagnostic added in v0.2.4

type JSONDiagnostic struct {
	Code               Code                     `json:"code"`
	Severity           Severity                 `json:"severity"`
	Message            string                   `json:"message"`
	Location           *JSONLocation            `json:"location,omitempty"`
	RelatedInformation []JSONRelatedInformation `json:"relatedInformation,omitempty"`
	Fixes              []JSONFix                `json:"fixes,omitempty"`
}

type JSONFix added in v0.2.4

type JSONFix struct {
	Message string         `json:"message"`
	Edits   []JSONTextEdit `json:"edits"`
}

type JSONLocation added in v0.2.4

type JSONLocation struct {
	Path string   `json:"path"`
	Span JSONSpan `json:"span"`
}

type JSONPosition added in v0.2.4

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

type JSONRelatedInformation added in v0.2.4

type JSONRelatedInformation struct {
	Message  string       `json:"message"`
	Location JSONLocation `json:"location"`
}

type JSONReport added in v0.2.4

type JSONReport struct {
	SchemaVersion int              `json:"schemaVersion"`
	ToolVersion   string           `json:"toolVersion,omitempty"`
	Diagnostics   []JSONDiagnostic `json:"diagnostics"`
	Summary       JSONSummary      `json:"summary"`
}

func NewJSONReport added in v0.2.4

func NewJSONReport(items []Diagnostic) JSONReport

type JSONSpan added in v0.2.4

type JSONSpan struct {
	Start JSONPosition `json:"start"`
	End   JSONPosition `json:"end"`
}

type JSONSummary added in v0.2.4

type JSONSummary struct {
	Errors   int `json:"errors"`
	Warnings int `json:"warnings"`
}

type JSONTextEdit added in v0.2.4

type JSONTextEdit struct {
	Location    JSONLocation `json:"location"`
	Replacement string       `json:"replacement"`
}

type Location added in v0.2.4

type Location struct {
	Path string
	Span token.Span
}

type RelatedInformation added in v0.2.4

type RelatedInformation struct {
	Message  string
	Location Location
}

type Severity

type Severity string
const (
	Error   Severity = "error"
	Warning Severity = "warning"
)

type TextEdit added in v0.2.4

type TextEdit struct {
	Location    Location
	Replacement string
}

Jump to

Keyboard shortcuts

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