diagnostics

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2024 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// SeverityUnspecified is the undefined severity
	SeverityUnspecified Severity = ""
	// SeverityWarning is a warning
	SeverityWarning = "WARNING"
	// SeverityError is an error
	SeverityError = "ERROR"
	// SeverityFatal is a fatal error
	SeverityFatal = "FATAL"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CompilerOutputParserCB

type CompilerOutputParserCB func(cmdline []string, out []byte)

CompilerOutputParserCB is a callback function that is called to feed a parser with the plain-text compiler output.

type Context

type Context struct {
	Message string `json:"message"`
	File    string `json:"file,omitempty"`
	Line    int    `json:"line,omitempty"`
	Column  int    `json:"col,omitempty"`
}

Context represents a context, i.e. a reference to a file, line and column or a part of the code that a Diagnostic refers to.

func (*Context) ToRPC

func (d *Context) ToRPC() *rpc.CompileDiagnosticContext

ToRPC converts a Context to a rpc.CompileDiagnosticContext

type DetectedCompiler

type DetectedCompiler struct {
	Name            string
	Family          string
	Version         *semver.Version
	DetailedVersion []string
}

DetectedCompiler represents a compiler detected from a given command line

func DetectCompilerFromCommandLine

func DetectCompilerFromCommandLine(args []string, probeCompiler bool) *DetectedCompiler

DetectCompilerFromCommandLine tries to detect a compiler from a given command line. If probeCompiler is true, the compiler may be executed with different flags to infer the version or capabilities.

type Diagnostic

type Diagnostic struct {
	Severity    Severity    `json:"severity,omitempty"`
	Message     string      `json:"message"`
	File        string      `json:"file,omitempty"`
	Line        int         `json:"line,omitempty"`
	Column      int         `json:"col,omitempty"`
	Context     FullContext `json:"context,omitempty"`
	Suggestions Notes       `json:"suggestions,omitempty"`
}

Diagnostic represents a diagnostic (a compiler error, warning, note, etc.)

func ParseCompilerOutput

func ParseCompilerOutput(compiler *DetectedCompiler, out []byte) ([]*Diagnostic, error)

ParseCompilerOutput parses the output of a compiler and returns a list of diagnostics.

func (*Diagnostic) ToRPC

func (d *Diagnostic) ToRPC() *rpc.CompileDiagnostic

ToRPC converts a Diagnostic to a rpc.CompileDiagnostic

type Diagnostics

type Diagnostics []*Diagnostic

Diagnostics represents a list of diagnostics

func (Diagnostics) ToRPC

func (d Diagnostics) ToRPC() []*rpc.CompileDiagnostic

ToRPC converts a Diagnostics to a slice of rpc.CompileDiagnostic

type FullContext

type FullContext []*Context

FullContext represents a list of Context

func (FullContext) ToRPC

ToRPC converts a FullContext to a slice of rpc.CompileDiagnosticContext

type Note

type Note struct {
	Message string `json:"message"`
	File    string `json:"file,omitempty"`
	Line    int    `json:"line,omitempty"`
	Column  int    `json:"col,omitempty"`
}

Note represents a compiler annotation or suggestion

func (*Note) ToRPC

func (s *Note) ToRPC() *rpc.CompileDiagnosticNote

ToRPC converts a Note to a rpc.CompileDiagnosticNote

type Notes

type Notes []*Note

Notes represents a list of Note

func (Notes) ToRPC

func (s Notes) ToRPC() []*rpc.CompileDiagnosticNote

ToRPC converts a Notes to a slice of rpc.CompileDiagnosticNote

type Severity

type Severity string

Severity is a diagnostic severity

type Store

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

func NewStore

func NewStore() *Store

func (*Store) Diagnostics

func (m *Store) Diagnostics() Diagnostics

func (*Store) Parse

func (m *Store) Parse(cmdline []string, out []byte)

Parse parses the output coming from a compiler. It then stores the parsed diagnostics in a slice of Diagnostic.

Jump to

Keyboard shortcuts

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