Documentation
¶
Overview ¶
Package kit contains the reusable validation pass framework.
Index ¶
- Constants
- func BodyScope(scope *symbols.Scope, decl ast.Node) *symbols.Scope
- func DeclarationScope(sym *symbols.Symbol) *symbols.Scope
- func ForEachBodySymbol(body *symbols.Scope, visit func(*symbols.Symbol))
- func IsReference(n ast.Node) bool
- func MemberSymbols(ctx *Context, root *symbols.Scope) []*symbols.Symbol
- func Move[K comparable](s CountSet[K], old, cur map[K]bool, name func(K) string, ...)
- func MultiplicityOf(sym *symbols.Symbol) *ast.Multiplicity
- func ReferenceScope(sym *symbols.Symbol) *symbols.Scope
- func Symbols(ctx *Context, root *symbols.Scope) []*symbols.Symbol
- func UnnamedMetadataBody(scope *symbols.Scope, prefix *ast.PrefixMetadata) *symbols.Scope
- func UnwrapMembership(node ast.Node) ast.Node
- func WalkSymbols(ctx *Context, root *symbols.Scope, visit func(*symbols.Symbol))
- type AboutUnion
- type ChainStep
- type Context
- func (c *Context) DownstreamOfFailure(ref ast.Node) bool
- func (c *Context) DownstreamSpan(span source.Span) bool
- func (c *Context) Gathers() *Gathers
- func (c *Context) Model() *semantics.Model
- func (c *Context) Resolver() *resolve.Resolver
- func (c *Context) SetFailures(spans []source.Span)
- func (c *Context) Share(resolver *resolve.Resolver, model *semantics.Model, gathers *Gathers)
- type CountSet
- type Gathers
- func (g *Gathers) Gather(ctx *Context, doc string, f func(root *symbols.Scope))
- func (g *Gathers) Gathered(doc string) bool
- func (g *Gathers) Has(doc string) bool
- func (g *Gathers) Regather(ctx *Context, docs map[string]bool) []string
- func (g *Gathers) Reset()
- func (g *Gathers) Union(key string) Regatherer
- func (g *Gathers) UnionOf(ctx *Context, key string, build func() Regatherer) Regatherer
- type Options
- type Pass
- type PassLevel
- type Regatherer
- type Walker
Constants ¶
const AboutGather = "\x00identity"
AboutGather names the gather of the `about`-annotated elements no workspace document declares.
Variables ¶
This section is empty.
Functions ¶
func BodyScope ¶
BodyScope returns the scope decl declares into, or scope itself when the scope builder gave it none.
func DeclarationScope ¶
w8cScopeOf returns the scope a declaration's own references resolve in.
func ForEachBodySymbol ¶
forEachBodySymbol visits the symbols a metadata body declares, at any depth.
func IsReference ¶
w8cIsReference reports whether n names a feature rather than computing a value.
func MemberSymbols ¶
w8cSymbols lists the scope tree's symbols once each, in visiting order, and caches the list on ctx for the passes that share it.
func Move ¶
func Move[K comparable](s CountSet[K], old, cur map[K]bool, name func(K) string, changed map[string]bool)
Move replaces one document's contribution and names flipped memberships.
func MultiplicityOf ¶
func MultiplicityOf(sym *symbols.Symbol) *ast.Multiplicity
w8cMultiplicityOf returns the multiplicity a declaration declares, or nil.
func ReferenceScope ¶
ReferenceScope returns the scope a symbol's own references resolve in.
func UnnamedMetadataBody ¶
unnamedMetadataBody is the scope of an unnamed annotation's body, which no symbol owns and the symbol walk therefore never reaches; nil for a named one.
func UnwrapMembership ¶
UnwrapMembership strips the membership a declaration reaches a body wrapped in.
Types ¶
type AboutUnion ¶
type AboutUnion interface {
Regatherer
RegatherAbout(ctx *Context, g *Gathers, changed map[string]bool)
}
AboutUnion also gathers what lies outside the workspace documents.
type ChainStep ¶
w8cChainStep is one chaining feature: the node resolving to it and the span of the segment naming it.
func ChainSteps ¶
w8cChainSteps splits a chain target into chaining features: only a `.` starts a new one, a `::`-qualified name is a single chaining feature.
type Context ¶
type Context struct {
Name string
Kind source.Kind
Index *symbols.Index
ParseDiagnostics []diag.Diagnostic
// Options is what the caller asked for, fixed at construction: a pass reads
// it, and nothing mutates it during a run.
Options Options
// 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, kind source.Kind, idx *symbols.Index, parseDiags []diag.Diagnostic, opts Options, newModel func(*resolve.Resolver) *semantics.Model) *Context
NewContext builds a Context; newModel makes the semantic model on first use of Model().
func (*Context) DownstreamOfFailure ¶
DownstreamOfFailure reports whether a reference an element's meaning rests on — its type, its metaclass — carries a blocking fault from a lower tier, so a pass whose subject is that element has nothing sound to judge.
func (*Context) DownstreamSpan ¶
DownstreamSpan reports whether span contains a blocking failure.
func (*Context) Gathers ¶
Gathers is what the workspace-wide audits gathered per document, shared across analyses by a workspace and made afresh for a context outside one.
func (*Context) 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 ¶
Resolver returns the shared resolver for this context, creating it on first use so multiple passes reuse one memoized instance.
func (*Context) SetFailures ¶
SetFailures records the blocking spans of the tiers below the pass about to run. Only the registry calls it, once per pass.
type Gathers ¶
type Gathers struct {
// contains filtered or unexported fields
}
Gathers holds workspace-wide audit state and the unions built from documents.
func (*Gathers) Gathered ¶
Gathered reports whether doc is among the gathered workspace documents. It is unlocked for unions inside Regather/RegatherAbout, which run under the lock.
func (*Gathers) Has ¶
Has reports whether doc is among the gathered workspace documents, with locking.
func (*Gathers) Regather ¶
Regather updates the requested documents and reports changed union keys. Nothing is gathered for a union no analysis has asked for yet.
func (*Gathers) Union ¶
func (g *Gathers) Union(key string) Regatherer
Union returns the union under key if built, else nil.
func (*Gathers) UnionOf ¶
func (g *Gathers) UnionOf(ctx *Context, key string, build func() Regatherer) Regatherer
UnionOf returns the union under key, built on first use over every gathered document.
type Options ¶
type Options struct {
// Conformance is the strictness the notation is judged at.
Conformance diag.ConformanceMode
}
Options is the analysis configuration of one run. The zero value is what every existing caller gets: today's behavior, unchanged.
type Pass ¶
type Pass interface {
Level() PassLevel
Run(ctx *Context, name string, root *ast.RootNamespace) []diag.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).
type Regatherer ¶
type Regatherer interface {
Regather(ctx *Context, g *Gathers, doc string, changed map[string]bool)
}
Regatherer is one workspace-wide gather, kept per document by Gathers.