passes

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2026 License: Apache-2.0 Imports: 11 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

Index

Constants

View Source
const CodeEndpointNotOfMachine = "endpoint-not-of-machine"

CodeEndpointNotOfMachine marks a transition endpoint naming a vertex the machine the transition belongs to does not own (UML 2.5.1 §14.2.3.9).

View Source
const CodeNoOutgoingTransition = "no-outgoing-transition"

CodeNoOutgoingTransition marks a routing pseudostate no transition leaves, which a transition reaching it terminates nowhere at (UML 2.5.1 §15.7.18).

Variables

This section is empty.

Functions

This section is empty.

Types

type ConstraintPass

type ConstraintPass struct{}

ConstraintPass runs the depth-C semantic constraint checks over a document's symbol tree: specialization-cycle detection, multiplicity-range validity, and subsetting multiplicity conformance (design §4.1). It runs at LevelConstraint, after type checking; it relies on the shared semantic model for the resolved specialization graph and extracted multiplicities.

func (ConstraintPass) Level

func (ConstraintPass) Level() PassLevel

func (ConstraintPass) Run

func (ConstraintPass) Run(ctx *Context, name string, root *ast.RootNamespace) []Diagnostic

type Context

type Context struct {
	Name             string
	Index            *symbols.Index
	ParseDiagnostics []Diagnostic
	// contains filtered or unexported fields
}

Context carries shared state made available to every pass in a run: the document name, the global symbol index, a lazily-created shared resolver, and the syntax diagnostics produced by the caller's parse (passes must not import the parser, so these enter here).

func NewContext

func NewContext(name string, idx *symbols.Index, parseDiags []Diagnostic) *Context

NewContext builds a Context for a document.

func (*Context) Model

func (c *Context) Model() *semantics.Model

Model returns the shared semantic model (specialization graph, multiplicity, inherited members, evaluator) for this context, creating it on first use over the shared resolver so constraint passes reuse one memoized instance.

func (*Context) Resolver

func (c *Context) Resolver() *resolve.Resolver

Resolver returns the shared resolver for this context, creating it on first use so multiple passes reuse one memoized instance.

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 []quickfix.Fix
}

Diagnostic is a single validation finding produced by a pass.

func Analyze

func Analyze(name string, root *ast.RootNamespace, parseDiags []Diagnostic, idx *symbols.Index) []Diagnostic

Analyze runs the default validation passes over a single parsed document and returns diagnostics sorted by span offset, then source, then message. parseDiags are the parser's diagnostics, already adapted to passes.Diagnostic by the caller.

type ElementFilterPass

type ElementFilterPass struct{}

ElementFilterPass checks the element-filter conditions a document writes: the `filter` members of a namespace (KerML 8.2.4) and the `[...]` clause of an import or expose (SysML v2 7.4.4). A condition is a predicate over one candidate element, so it has to be boolean-valued and it has to be a form the filter evaluator can decide; a condition that is neither selects nothing, and name resolution keeps every candidate rather than hiding model content on a verdict it could not reach.

It runs at LevelType: deciding what a condition yields needs the elements it names to have resolved, and adds nothing over the unresolved-reference diagnostics when they have not.

func (ElementFilterPass) Level

func (ElementFilterPass) Level() PassLevel

func (ElementFilterPass) Run

func (ElementFilterPass) Run(ctx *Context, name string, root *ast.RootNamespace) []Diagnostic

type NameResolutionPass

type NameResolutionPass struct{}

NameResolutionPass resolves every reference in a document via the Plan-3 resolver and reports unresolved / ambiguous references.

func (NameResolutionPass) Level

func (NameResolutionPass) Level() PassLevel

Level reports the name-resolution dependency level.

func (NameResolutionPass) Run

func (NameResolutionPass) Run(ctx *Context, name string, root *ast.RootNamespace) []Diagnostic

Run resolves the document and adapts resolver diagnostics.

type Pass

type Pass interface {
	Level() PassLevel
	Run(ctx *Context, name string, root *ast.RootNamespace) []Diagnostic
}

Pass is a single validation rule. Level reports its dependency tier; Run executes it over a whole document and returns any diagnostics found.

type PassLevel

type PassLevel int

PassLevel is the dependency tier of a validation pass. Passes at a higher level are skipped when a lower level produced an error, avoiding cascade noise (e.g. no type-check on an unresolved reference).

const (
	LevelSyntax PassLevel = iota
	LevelNameResolution
	LevelType
	LevelConstraint
)

func (PassLevel) String

func (l PassLevel) String() string

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

type Registry

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

Registry holds an ordered set of validation passes.

func DefaultRegistry

func DefaultRegistry() *Registry

DefaultRegistry returns the default pass registry: syntax, name resolution, state transitions, type checking, and semantic constraints.

func NewRegistry

func NewRegistry() *Registry

NewRegistry returns an empty registry.

func (*Registry) Register

func (r *Registry) Register(p Pass)

Register adds a pass to the registry.

func (*Registry) Run

func (r *Registry) Run(ctx *Context, name string, root *ast.RootNamespace) []Diagnostic

Run executes all registered passes in ascending PassLevel order and returns their accumulated diagnostics. If a pass at some level emits an Error-severity diagnostic, passes at strictly higher levels are skipped to avoid cascade noise. Passes at the same level always run.

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".

type StateTransitionPass

type StateTransitionPass struct{}

StateTransitionPass checks that every transition names one source and one target vertex of its own machine (UML 2.5.1 §14.2.3.9), and that a routing pseudostate is left by one (§15.7.18).

func (StateTransitionPass) Level

Level reports the name-resolution level: resolved endpoints are all it reads.

func (StateTransitionPass) Run

func (StateTransitionPass) Run(ctx *Context, name string, root *ast.RootNamespace) []Diagnostic

Run checks every state machine the document declares.

type SyntaxPass

type SyntaxPass struct{}

SyntaxPass surfaces the parser-produced diagnostics carried on the Context. The passes package does not import parser; the caller adapts parser diagnostics into passes.Diagnostic and stores them on Context.ParseDiagnostics.

func (SyntaxPass) Level

func (SyntaxPass) Level() PassLevel

Level reports that syntax is the lowest dependency level.

func (SyntaxPass) Run

func (SyntaxPass) Run(ctx *Context, name string, root *ast.RootNamespace) []Diagnostic

Run returns the parse diagnostics carried on the context.

type TypeCheckPass

type TypeCheckPass struct{}

TypeCheckPass validates that each def/usage relationship target has a symbol kind compatible with the source node and relationship kind (spec §6.3), and types expressions (operands, bound values, invocation arguments) against the stdlib scalar lattice. It runs at LevelType, after name resolution; unresolved targets are skipped.

func (TypeCheckPass) Level

func (TypeCheckPass) Level() PassLevel

func (TypeCheckPass) Run

func (TypeCheckPass) Run(ctx *Context, name string, root *ast.RootNamespace) []Diagnostic

Jump to

Keyboard shortcuts

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