diag

package
v0.10.1 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2026 License: Apache-2.0 Imports: 3 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package diag holds the diagnostic type every layer reports findings in, the quick-fix edits a diagnostic carries, and the conformance mode that decides how strictly findings are judged.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConformanceMode

type ConformanceMode int

ConformanceMode is how strictly a document is judged against the pinned SysML v2 and KerML grammars. It is threaded explicitly through the analysis pipeline — no global, no environment read — so every entry point states the question it is asking.

const (
	// ConformanceDefault accepts the OpenSysML notation extensions, reporting each as a
	// warning. It is the zero value: a caller that says nothing gets it.
	ConformanceDefault ConformanceMode = iota
	// ConformanceStrict answers "is this conforming SysML v2?": notation no pinned
	// production admits is an error, so a file using it is rejected.
	ConformanceStrict
)

func ConformanceModeOf

func ConformanceModeOf(strict bool) ConformanceMode

ConformanceModeOf maps a boolean surface (a CLI flag, an LSP setting, a request field) onto the mode it selects.

func ParseConformanceMode

func ParseConformanceMode(s string) (ConformanceMode, error)

ParseConformanceMode reads a mode by name, as the CLI and the REPL spell it. The empty string is the default mode, so an unset setting is not an error.

func (ConformanceMode) IsStrict

func (m ConformanceMode) IsStrict() bool

IsStrict reports whether extension notation is an error in this mode.

func (ConformanceMode) String

func (m ConformanceMode) String() string

String returns the mode's spelling, the same one every entry point accepts.

type Diagnostic

type Diagnostic struct {
	Severity Severity
	Span     source.Span
	Message  string
	Code     string // stable identifier for filtering / quick-fix selection
	Source   string // the pass ID that produced this diagnostic
	// Fixes are the unambiguous edits resolving the diagnostic, offered by an
	// editor as quick fixes.
	Fixes []Fix
	// Notation marks a finding about how the model is written rather than about
	// what it means: the document still reads, so it does not gate higher tiers.
	Notation bool
}

Diagnostic is a single validation finding produced by a pass.

func Clone added in v0.9.2

func Clone(ds []Diagnostic) []Diagnostic

Clone returns a copy of ds sharing no slice with it.

func (Diagnostic) Blocking

func (d Diagnostic) Blocking() bool

Blocking reports whether the finding stops what depends on the model being readable — a higher validation tier, a summary of what a submission declared. A notation error is about the writing, not the meaning, so it stops neither.

type Edit

type Edit struct {
	Span    source.Span
	NewText string
	// OwnLine makes the edit a whole line inserted before Span.Offset, indented
	// like the line that offset sits on (see Render).
	OwnLine bool
}

Edit replaces the text a span covers. A zero-length span is an insertion at its offset.

func Insert

func Insert(offset int, text string) Edit

Insert returns an insertion of text at offset.

func InsertLine

func InsertLine(offset int, text string) Edit

InsertLine returns an insertion of text as its own line before offset.

func Replace

func Replace(span source.Span, text string) Edit

Replace returns a replacement of the text span covers with text.

func (Edit) Render

func (e Edit) Render(content []byte) (source.Span, string)

Render resolves an edit against its document, returning the span to replace and the replacement. An own-line edit keeps the line it precedes on its own line.

type Fix

type Fix struct {
	Title     string
	Edits     []Edit
	Preferred bool
}

Fix is one unambiguous way to resolve a diagnostic, within the document that diagnostic belongs to. Preferred marks a fix an editor may apply unprompted.

type Severity

type Severity int

Severity classifies the impact of a Diagnostic.

const (
	SeverityError Severity = iota
	SeverityWarning
	SeverityInfo
	SeverityHint
)

func (Severity) String

func (s Severity) String() string

String returns the lowercase name of the severity, or "unknown".

Jump to

Keyboard shortcuts

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