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 ¶
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.
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 ¶
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 ¶
Explain writes the explanation of a code as `sysml -explain` prints it. The error names a code the registry does not know.
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.
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 Lookup ¶
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 ¶
IsFamily reports whether the entry stands for a family of codes `Code-<kind>`.
func (Entry) MemberSeverity ¶ added in v0.12.0
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 ¶
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.
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.