check

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2026 License: Apache-2.0 Imports: 5 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateErrorMessage added in v0.6.26

func GenerateErrorMessage(node *ts.Node, src string) (msg string, code rl.Error, suggestion *string)

GenerateErrorMessage creates a specific error message for an invalid node. Returns the message, error code, and optional suggestion.

Types

type Diagnostic

type Diagnostic struct {
	OriginalSrc string // Complete original src
	Range       Range
	RangedSrc   string // Src for just the Range
	LineSrc     string // Src for the line at the start of Range
	Severity    Severity
	Message     string
	Code        *rl.Error
	Suggestion  *string // Optional suggestion for fixing the error (rendered as "Try: ...")
}

Diagnostic represents a static analysis diagnostic. This is the canonical diagnostic type for the check system; both lsp.Diagnostic and core.Diagnostic are derived from it. Severity levels align with the LSP protocol (4 levels); core collapses Hint/Info into Note for its 3-level Rust-style CLI output.

func NewDiagnosticError

func NewDiagnosticError(node *ts.Node, originalSrc string, msg string, code rl.Error) Diagnostic

func NewDiagnosticErrorFromSpan added in v0.9.0

func NewDiagnosticErrorFromSpan(span rl.Span, originalSrc string, msg string, code rl.Error) Diagnostic

func NewDiagnosticErrorWithSuggestion added in v0.6.26

func NewDiagnosticErrorWithSuggestion(node *ts.Node, originalSrc string, msg string, code rl.Error, suggestion *string) Diagnostic

func NewDiagnosticFromNode

func NewDiagnosticFromNode(
	node *ts.Node,
	originalSrc string,
	severity Severity,
	msg string,
	code *rl.Error,
) Diagnostic

func NewDiagnosticFromSpan added in v0.9.0

func NewDiagnosticFromSpan(
	span rl.Span,
	originalSrc string,
	severity Severity,
	msg string,
	code *rl.Error,
) Diagnostic

NewDiagnosticFromSpan creates a Diagnostic from an AST span instead of a CST node.

func NewDiagnosticHint added in v0.6.15

func NewDiagnosticHint(node *ts.Node, originalSrc string, msg string, code rl.Error) Diagnostic

func NewDiagnosticHintFromSpan added in v0.9.0

func NewDiagnosticHintFromSpan(span rl.Span, originalSrc string, msg string, code rl.Error) Diagnostic

func NewDiagnosticWarn added in v0.6.17

func NewDiagnosticWarn(node *ts.Node, originalSrc string, msg string, code rl.Error) Diagnostic

func NewDiagnosticWarnFromSpan added in v0.9.0

func NewDiagnosticWarnFromSpan(span rl.Span, originalSrc string, msg string, code rl.Error) Diagnostic

type Opts

type Opts struct {
	Errors bool
	Warns  bool
	Lints  bool
}

todo mostly unused atm

func NewOpts

func NewOpts() Opts

type Pos

type Pos struct {
	Line      int `json:"line"`      // Zero-indexed
	Character int `json:"character"` // Zero-indexed
}

type RadChecker

type RadChecker interface {
	UpdateSrc(src string)
	Update(tree *rts.RadTree, src string, ast *rl.SourceFile)
	CheckDefault() (Result, error)
	Check(Opts) (Result, error)
}

func NewChecker

func NewChecker() (RadChecker, error)

func NewCheckerWithTree

func NewCheckerWithTree(tree *rts.RadTree, parser *rts.RadParser, src string, ast *rl.SourceFile) RadChecker

type RadCheckerImpl

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

func (*RadCheckerImpl) Check

func (c *RadCheckerImpl) Check(opts Opts) (Result, error)

todo use opts

func (*RadCheckerImpl) CheckDefault

func (c *RadCheckerImpl) CheckDefault() (Result, error)

func (*RadCheckerImpl) Update added in v0.9.0

func (c *RadCheckerImpl) Update(tree *rts.RadTree, src string, ast *rl.SourceFile)

func (*RadCheckerImpl) UpdateSrc

func (c *RadCheckerImpl) UpdateSrc(src string)

type Range

type Range struct {
	Start Pos `json:"start"`
	End   Pos `json:"end"`
}

type Result

type Result struct {
	// todo Rad versions
	Diagnostics []Diagnostic
}

type Severity

type Severity int
const (
	Hint Severity = iota
	Warning
	Info
	Error
)

func (Severity) String

func (s Severity) String() string

Jump to

Keyboard shortcuts

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