selfcheck

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: 10 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 selfcheck applies the reflective SysMLValidation constraints, and those of any rule packages, to every element of a model: the REPL's -self-check and the service's SelfCheck share it.

Index

Constants

View Source
const CodeRule = "self-check-rule"

CodeRule is the registered diagnostic code of a failing model rule.

Variables

View Source
var ErrPackageNotFound = errors.New("self-check package not found")

ErrPackageNotFound is wrapped by ResolvePackages when a rule package name resolves to no package.

Functions

func Sources

func Sources(docs []*model.Document) map[string]*source.SourceFile

Sources maps a model's documents to source files, for Input.Sources.

Types

type Counts

type Counts struct {
	Elements         int
	Checks           int
	Violations       int
	Unevaluated      int
	EvaluationErrors int
	// Applications is how many elements each constraint was applied to, by name.
	Applications map[string]int
}

Counts tallies what the check did.

func (Counts) Summary

func (c Counts) Summary() string

Summary is the one-line total the REPL prints last.

type Finding

type Finding struct {
	Status     Status
	Subject    string // "<constraint> for <element>", or the constraint or package alone
	Location   string // file:line:col of the element, empty when it has none
	Constraint string // the constraint's qualified name, for a constraint applied
	Element    string // the element's name, for a constraint applied
	Message    string // a warning's reason
	Err        error  // why an evaluation failed or could not be made
}

Finding is one thing the check reports: a violation, an evaluation it could not make, or a constraint it skipped.

func (Finding) Line

func (f Finding) Line() string

Line spells the finding the way the REPL prints it.

type Input

type Input struct {
	// Index and Model are the model's symbols and typed semantics; a nil Index
	// has nothing to check.
	Index *symbols.Index
	Model *semantics.Model
	// Sources locates elements by document name, for the findings' locations.
	Sources map[string]*source.SourceFile
	// Runtime makes the context the constraints evaluate in, once, when any applies.
	Runtime func() (*runtime.Context, error)
	// Package is the bundled constraint package, SysMLValidation.
	Package string
	// IncludeWorkspacePackages also collects Package's constraints from the
	// workspace's own documents, not the libraries alone.
	IncludeWorkspacePackages bool
	// RulePackages are the resolved -self-check-package packages, whose
	// constraint defs apply after the bundled ones.
	RulePackages []RulePackage
}

Input is a model to check and how to check it.

type Report

type Report struct {
	Findings []Finding
	Counts   Counts
}

Report is what Run found and counted.

func Run

func Run(in Input) Report

Run applies the bundled and rule constraints to every element of the model.

type RulePackage

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

RulePackage is one distinct -self-check-package name resolved to every package symbol declaring it — a package may be re-opened across files.

func ResolvePackages

func ResolvePackages(idx *symbols.Index, pkgs []string) ([]RulePackage, error)

ResolvePackages resolves each distinct name to every package symbol it declares, in argument order. Quoted segments are read the way the notation reads them, and a name the notation cannot read counts as missing.

type Status

type Status int

Status is what one finding reports about a constraint applied to an element.

const (
	// Fails is a constraint the element answered false.
	Fails Status = iota
	// Unevaluated is a constraint the runtime cannot yet apply reflectively.
	Unevaluated
	// Error is a constraint whose evaluation failed, or a package that could not be collected.
	Error
	// Warning is a rule constraint skipped, or a rule package yielding none.
	Warning
)

func (Status) String

func (s Status) String() string

String spells a status as the wire and the REPL name it.

Jump to

Keyboard shortcuts

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