codes

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2026 License: Apache-2.0 Imports: 7 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 codes is the registry of diagnostic codes: every code a diagnostic of the parser, the semantic layer, the checker or the runtime carries, with the rule it names, how to satisfy the rule and the specification clause or validation constraint behind it. The CLI (-explain), the REPL (%explain-code), the MCP server and the language server's code descriptions read it, and the catalogue in docs/reference/diagnostics.md is generated from it.

Index

Constants

View Source
const (
	BeginMarker = "<!-- diagnostics-catalogue:begin -->"
	EndMarker   = "<!-- diagnostics-catalogue:end -->"
)

Markers delimit the generated catalogue in docs/reference/diagnostics.md: what lies between them is written by Catalogue and checked against it.

View Source
const CatalogueURL = "https://runtime.opensysml.org/reference/diagnostics/"

CatalogueURL is the published catalogue every code is a section of.

Variables

This section is empty.

Functions

func Anchor

func Anchor(code string) string

Anchor is the heading anchor of a code's catalogue section, as the site's slugger makes it: lower case, letters, digits, dashes and underscores kept, so `runtime.materialize` is `runtimematerialize`.

func Catalogue

func Catalogue() string

Catalogue renders every registered code as Markdown, grouped by tier in catalogue order, each under a heading whose anchor is the code itself, so `sysml -explain <code>`, the editor's code description and this page agree.

func Codes

func Codes() []string

Codes lists every code the registry knows, families expanded, sorted.

func Explain

func Explain(code string) (string, error)

Explain writes the explanation of a code as `sysml -explain` prints it. The error names a code the registry does not know.

func Known

func Known(code string) bool

Known reports whether code is registered, a family member included.

func List

func List() string

List writes every code with its one-line summary, as `sysml -explain` with no code prints them: grouped by tier, in catalogue order.

func Splice

func Splice(page []byte) ([]byte, error)

Splice returns page with the text between the markers replaced by the catalogue, or an error when the page lacks a marker.

func URL

func URL(code string) string

URL is the catalogue section of a code, what an editor opens from a diagnostic's code; a member of a family opens the family's section.

Types

type Entry

type Entry struct {
	// Code is the stable identifier a diagnostic carries, kebab-case.
	Code string
	// Tier is the pass family that reports it.
	Tier Tier
	// Severity is the severity the diagnostic is reported with: "error" or
	// "warning". A code reported at both is listed at the more severe.
	Severity string
	// Summary is the one-line description the listings show.
	Summary string
	// Meaning explains what the diagnostic means and how to satisfy the rule.
	Meaning string
	// Spec names the specification clause or validation constraint the rule
	// comes from, empty for a rule of OpenSysML's own.
	Spec string
	// Kinds, for a family code, are the suffixes the emitted code appends to
	// Code after a dash, each naming one rule of the family.
	Kinds []string
	// KindSeverities, for a family code, are the severities of the members
	// that are not reported at the family's Severity, by kind.
	KindSeverities map[string]string
}

Entry describes one diagnostic code.

func All

func All() []Entry

All lists the entries in catalogue order: by tier, then by code.

func ByTier

func ByTier(t Tier) []Entry

ByTier lists the entries of one tier, by code.

func Lookup

func Lookup(code string) (entry Entry, kind string, ok bool)

Lookup finds the entry of a code. A member of a family (`document-plan-missing-title`) finds the family's entry with kind set to the member's suffix; kind is empty otherwise. The second result is false for a code the registry does not know.

func (Entry) IsFamily

func (e Entry) IsFamily() bool

IsFamily reports whether the entry stands for a family of codes `Code-<kind>`.

func (Entry) MemberSeverity added in v0.12.0

func (e Entry) MemberSeverity(kind string) string

MemberSeverity is the severity the member of the family named kind is reported with; the empty kind is the family's base code.

type Row

type Row struct {
	Code     string
	Severity string
	Tier     Tier
	Summary  string
}

Row is one line of a listing: an emitted code with its severity, tier and summary. A family contributes one row per member, named after the rule.

func Rows

func Rows() []Row

Rows lists every code in catalogue order, each family as its base code and then its members, so a listing names each code `sysml -explain <code>` accepts.

type Tier

type Tier string

Tier names the pass family that reports a code, in pipeline order.

const (
	TierSyntax     Tier = "syntax"
	TierNameRes    Tier = "name-resolution"
	TierType       Tier = "type"
	TierConstraint Tier = "constraint"
	TierLint       Tier = "lint"
	TierMethod     Tier = "method"
	TierDocument   Tier = "document"
	TierWorkspace  Tier = "workspace"
	TierRuntime    Tier = "runtime"
)

The tiers, in the order the catalogue lists them.

func Tiers

func Tiers() []Tier

Tiers lists the tiers in catalogue order.

func (Tier) Title

func (t Tier) Title() string

Title is the catalogue heading of a tier.

Jump to

Keyboard shortcuts

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