check

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package check runs the language server's diagnostic pipeline over files without an editor: the high-level boundary for non-LSP frontends. Config discovery belongs to the caller — Run takes resolved inputs — and so does presentation: results are data, printing is the CLI's job.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Diagnostic

type Diagnostic struct {
	Line, Col       int
	EndLine, EndCol int
	Severity        Severity
	Code            string
	Message         string
}

Diagnostic is one finding in 1-based file coordinates with UTF-16 columns: ready to print, with no editor-protocol vocabulary.

type FixSummary

type FixSummary struct {
	// Applied is the number of fixes applied across all passes.
	Applied int
	// Files lists the fixed files' absolute paths.
	Files []string
	// Passes is the number of pipeline runs.
	Passes int
	// Skipped lists the fixes that could not apply.
	Skipped []SkippedFix
}

FixSummary reports a fix run.

type Request

type Request struct {
	// Files are the absolute thrift paths to check.
	Files []string
	// Folder is the absolute resolution root. Empty derives from the
	// first file's directory.
	Folder string
	// IncludePaths are the compiler-equivalent include roots, authoritative
	// for the run.
	IncludePaths []string
	// Lint tunes the pipeline. Nil means defaults.
	Lint *options.LintConfig
	// Analyzers are appended to the built-in pipeline.
	Analyzers []sema.Analyzer
	// Fix rewrites files in place until nothing applies, preserving file
	// permissions.
	Fix bool
}

Request is one check run over materialized files.

type Result

type Result struct {
	Diagnostics map[string][]Diagnostic
	Fix         *FixSummary
}

Result is one check run. Diagnostics are keyed by absolute path. Without Fix they hold everything found; with Fix they hold what remains unfixed. Fix is nil unless Request.Fix.

func Run

func Run(ctx context.Context, req Request) (Result, error)

Run checks req.Files through the same store and checker pipeline the LSP uses, and returns the diagnostics per file. It exits no process and prints nothing; severity gating (failing CI on errors) belongs to the caller.

type Severity

type Severity string

Severity is a diagnostic's display weight.

const (
	SeverityError   Severity = "error"
	SeverityWarning Severity = "warning"
	SeverityInfo    Severity = "info"
	SeverityHint    Severity = "hint"
)

type SkippedFix

type SkippedFix struct {
	// File is the absolute path of the file carrying the fix.
	File string
	// Title names the fix.
	Title string
	// Reason explains why it was skipped.
	Reason string
}

SkippedFix is a fix that could not apply.

Jump to

Keyboard shortcuts

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