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 ¶
const CodeRule = "self-check-rule"
CodeRule is the registered diagnostic code of a failing model rule.
Variables ¶
var ErrPackageNotFound = errors.New("self-check package not found")
ErrPackageNotFound is wrapped by ResolvePackages when a rule package name resolves to no package.
Functions ¶
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.
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.
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 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 )