Documentation
¶
Index ¶
- Constants
- func ActionGeneralBodies(scope *symbols.Scope) []*symbols.Scope
- func ActionGeneralization(scope *symbols.Scope, typing bool) (bodies []*symbols.Scope, cyclic bool)
- func ActionNodeDeclaringScope(scope *symbols.Scope, decl ast.Node) *symbols.Scope
- func ActionNodeInScope(scope *symbols.Scope, qn *ast.QualifiedName) (ast.Node, *symbols.Scope, bool, bool)
- func ActionNodeOfBody(body *symbols.Scope, name string) (ast.Node, bool)
- func ActionNodeRedefinitionTargets(body *symbols.Scope, decl ast.Node, subsets bool) []ast.Node
- func FeatureSymbolInScope(scope *symbols.Scope, segments []string) (*symbols.Symbol, bool)
- func GatherFrame(doc string) string
- func GatheredDoc(frame string) (string, bool)
- func GeneralBodies(body *symbols.Scope) []*symbols.Scope
- func ImplicitlyRedefined(sym *symbols.Symbol) bool
- func IsAssertion(u *ast.Usage) bool
- func IsVertex(decl ast.Node) bool
- func JournalNew[K comparable, V any](r *Resolver, m map[K]V, k K, node ast.Node)
- func MissingRedefinedActionNode(body *symbols.Scope, usage *ast.Usage) string
- func ParameterizedByName(sym *symbols.Symbol) bool
- func RedefinesActionNode(body *symbols.Scope, node *ast.Usage, decl ast.Node) bool
- func TypeDeclInScope(scope *symbols.Scope, qn *ast.QualifiedName) (ast.Node, *symbols.Scope, bool)
- func UnresolvedSubject(message string) (subject string, ok bool)
- func VertexInScope(scope *symbols.Scope, target ast.Node) (ast.Node, bool)
- type Diagnostic
- type HeadRelationship
- type MemberLookup
- type Reading
- type Reads
- type Reference
- type Regatherer
- type Resolver
- func (r *Resolver) AdmittedChildrenOf(scope *symbols.Scope, fqn string, children []*symbols.Symbol) []*symbols.Symbol
- func (r *Resolver) AdmittedTopLevel(doc string, bindings []symbols.RootBinding) []*symbols.Symbol
- func (r *Resolver) AliasNamesNothing(sym *symbols.Symbol) bool
- func (r *Resolver) AliasTarget(sym *symbols.Symbol) (*symbols.Symbol, bool)
- func (r *Resolver) AliasedElement(sym *symbols.Symbol) *symbols.Symbol
- func (r *Resolver) BindsName(sym *symbols.Symbol) bool
- func (r *Resolver) CutShort(depth int)
- func (r *Resolver) DeclarationTraits(sym *symbols.Symbol) symbols.Modifiers
- func (r *Resolver) Depend(doc string)
- func (r *Resolver) Dependents(doc string) []string
- func (r *Resolver) DistinguishableByMetaclass(a, b *symbols.Symbol) bool
- func (r *Resolver) DistinguishableMembers(scope *symbols.Scope) (owned, aliases []*symbols.Symbol)
- func (r *Resolver) EndSymbol(qn *ast.QualifiedName) (*symbols.Symbol, bool)
- func (r *Resolver) Endpoint(scope *symbols.Scope, target ast.Node) (ast.Node, bool)
- func (r *Resolver) EndpointSymbol(scope *symbols.Scope, target ast.Node) (*symbols.Symbol, bool)
- func (r *Resolver) Enter() int
- func (r *Resolver) EnterDoc(doc string)
- func (r *Resolver) FeaturedMembersOf(scope *symbols.Scope, sym *symbols.Symbol) []*symbols.Symbol
- func (r *Resolver) Gather(doc string, f func())
- func (r *Resolver) ImportTarget(scope *symbols.Scope, imp *ast.Import) (*symbols.Symbol, bool)
- func (r *Resolver) ImportedBeside(scope *symbols.Scope, name string, sym *symbols.Symbol) (*symbols.Symbol, bool)
- func (r *Resolver) ImportedElements(scope *symbols.Scope, imp *ast.Import) []*symbols.Symbol
- func (r *Resolver) ImportedElementsInto(into, scope *symbols.Scope, imp *ast.Import) []*symbols.Symbol
- func (r *Resolver) ImportedMembersInto(into, scope *symbols.Scope, imp *ast.Import) []*symbols.Symbol
- func (r *Resolver) ImportedMembersUnfiltered(scope *symbols.Scope, imp *ast.Import, includeUnnamed bool) []*symbols.Symbol
- func (r *Resolver) InCondition(f func())
- func (r *Resolver) InDocument(doc string, f func())
- func (r *Resolver) Index() *symbols.Index
- func (r *Resolver) InheritedMemberVisible(owner, member *symbols.Symbol) bool
- func (r *Resolver) InitialSymbol(n *ast.InitialNode) (*symbols.Symbol, bool)
- func (r *Resolver) Invalidate(ch symbols.Changes) []string
- func (r *Resolver) InvalidateAll()
- func (r *Resolver) InvocationCandidates(scope *symbols.Scope, qn *ast.QualifiedName) []*symbols.Symbol
- func (r *Resolver) IsBaseThat(sym *symbols.Symbol) bool
- func (r *Resolver) IsOccurrenceThis(sym *symbols.Symbol) bool
- func (r *Resolver) Journal(node ast.Node, drop func())
- func (r *Resolver) Journaling() bool
- func (r *Resolver) Leave() bool
- func (r *Resolver) LeaveDoc()
- func (r *Resolver) LibraryFeature(sym *symbols.Symbol) bool
- func (r *Resolver) LinkMetadataBodies(name string)
- func (r *Resolver) LocalBinding(scope *symbols.Scope, name string) (*symbols.Symbol, bool)
- func (r *Resolver) LocalBindings(scope *symbols.Scope, name string) []*symbols.Symbol
- func (r *Resolver) LookupName(scope *symbols.Scope, name string) (*symbols.Symbol, bool)
- func (r *Resolver) LookupNameExcluding(scope *symbols.Scope, name string, decl ast.Node) (*symbols.Symbol, bool)
- func (r *Resolver) MachineStateVertex(scope *symbols.Scope, qn *ast.QualifiedName, sym *symbols.Symbol) bool
- func (r *Resolver) MemoSize() int
- func (r *Resolver) MetadataBodyOwner(scope *symbols.Scope) *symbols.Symbol
- func (r *Resolver) Owned(doc string) int
- func (r *Resolver) PartAlias(qn *ast.QualifiedName, i int) (*symbols.Symbol, bool)
- func (r *Resolver) PartName(qn *ast.QualifiedName, i int) (*symbols.Symbol, bool)
- func (r *Resolver) PartSymbol(qn *ast.QualifiedName, i int) (*symbols.Symbol, bool)
- func (r *Resolver) PrefixScope(scope *symbols.Scope, decl ast.Node) *symbols.Scope
- func (r *Resolver) ProbeReading(ref Reference) Reading
- func (r *Resolver) ProbeRedefinitionTarget(scope *symbols.Scope, decl ast.Node, target ast.Node) (*symbols.Symbol, bool)
- func (r *Resolver) ProbeReference(ref Reference) (*symbols.Symbol, bool)
- func (r *Resolver) Query(doc string, f func())
- func (r *Resolver) ReadAllNames()
- func (r *Resolver) ReadDocument(name string)
- func (r *Resolver) ReadName(fqn string)
- func (r *Resolver) ReadNamespace(fqn string)
- func (r *Resolver) ReadQualified(scope *symbols.Scope, qn *ast.QualifiedName) Reading
- func (r *Resolver) ReadSegment(name string)
- func (r *Resolver) ReadSpellings()
- func (r *Resolver) ReadsOf(doc string) (reads Reads, ok bool)
- func (r *Resolver) RecordedElement(ref symbols.ElementRef) *symbols.Symbol
- func (r *Resolver) RedefinitionTarget(scope *symbols.Scope, decl ast.Node, target ast.Node) (*symbols.Symbol, bool)
- func (r *Resolver) ReferringNamespaceFQN(scope *symbols.Scope) string
- func (r *Resolver) RelationshipScope(parent, header *symbols.Scope, rel *ast.Relationship) *symbols.Scope
- func (r *Resolver) ResolveAliasTarget(sym *symbols.Symbol) (*symbols.Symbol, bool)
- func (r *Resolver) ResolveDocument(name string, root *ast.RootNamespace)
- func (r *Resolver) ResolveEndpoint(scope *symbols.Scope, qn *ast.QualifiedName) (*symbols.Symbol, bool)
- func (r *Resolver) ResolveEndpointRef(scope *symbols.Scope, target ast.Node) (*symbols.Symbol, bool)
- func (r *Resolver) ResolveInvocationName(scope *symbols.Scope, qn *ast.QualifiedName) (*symbols.Symbol, bool)
- func (r *Resolver) ResolveName(scope *symbols.Scope, name string, at ast.Node) (*symbols.Symbol, bool)
- func (r *Resolver) ResolveQualified(scope *symbols.Scope, qn *ast.QualifiedName) (*symbols.Symbol, bool)
- func (r *Resolver) ResolveRedefinitionTarget(scope *symbols.Scope, decl ast.Node, target ast.Node) (*symbols.Symbol, bool)
- func (r *Resolver) ResolveReference(ref Reference) (*symbols.Symbol, bool)
- func (r *Resolver) ResolveReferenceTarget(scope *symbols.Scope, decl ast.Node, target ast.Node) (*symbols.Symbol, bool)
- func (r *Resolver) ResolveTarget(scope *symbols.Scope, target ast.Node) (*symbols.Symbol, bool)
- func (r *Resolver) Scratch(transient map[ast.Node]bool, f func())
- func (r *Resolver) SetModel(model MemberLookup)
- func (r *Resolver) ShareCollisions(shared *SharedCollisions)
- func (r *Resolver) SuggestName(msg string, scope *symbols.Scope, name string, at ast.Node, ...) string
- func (r *Resolver) ThisContext(scope *symbols.Scope) *symbols.Symbol
- func (r *Resolver) Track()
- func (r *Resolver) Tracking() bool
- func (r *Resolver) TypeDecl(scope *symbols.Scope, qn *ast.QualifiedName) (ast.Node, *symbols.Scope, bool)
- func (r *Resolver) UnresolvedMember(scope *symbols.Scope, qn *ast.QualifiedName, owner *symbols.Symbol, i int) string
- func (r *Resolver) UnresolvedName(scope *symbols.Scope, name string, at ast.Node) string
- func (r *Resolver) Untracked(f func())
- func (r *Resolver) ViewExposureConditions(view *symbols.Symbol) []symbols.ElementFilter
- type SharedCollisions
Constants ¶
const CodeAmbiguous = "ambiguous"
CodeAmbiguous marks a name several elements answer to with equal standing.
const CodeNameConflict = "name-conflict"
CodeNameConflict marks a name declared twice in one namespace, counting the members it inherits (SysML 7.6.1, KerML 7.3.2.1).
const CodeNotAVertex = "not-a-vertex"
CodeNotAVertex marks an endpoint naming an element no transition can start or end at (SysML 7.19.2).
const CodeUnresolved = "unresolved"
CodeUnresolved marks a name, or a segment of a qualified name, that resolves to no element visible where it is written.
Variables ¶
This section is empty.
Functions ¶
func ActionGeneralBodies ¶
ActionGeneralBodies returns the bodies of the actions the action enclosing scope specializes or is typed by, nearest first and each once.
func ActionGeneralization ¶ added in v0.10.0
ActionGeneralization returns the bodies of the actions the action enclosing scope specializes, subsets, redefines, or is typed by, nearest first and each once, found from the scope tree alone — where a member the action inherits was declared. cyclic reports a generalization cycle; a diamond is not a cycle.
func ActionNodeDeclaringScope ¶ added in v0.10.0
ActionNodeDeclaringScope returns the action body that declares an inherited action node.
func ActionNodeInScope ¶
func ActionNodeInScope(scope *symbols.Scope, qn *ast.QualifiedName) (ast.Node, *symbols.Scope, bool, bool)
ActionNodeInScope finds an inherited action node from the scope tree alone. The final bool reports an unresolved generalization that makes absence uncertain.
func ActionNodeOfBody ¶
ActionNodeOfBody finds the action node a name written in an action's body names there: one the body declares, else one its declaration inherits.
func ActionNodeRedefinitionTargets ¶ added in v0.10.0
ActionNodeRedefinitionTargets returns inherited action nodes named by a member's redefines and, when subsets is true, subsets relationships.
func FeatureSymbolInScope ¶
FeatureSymbolInScope resolves a dotted feature path from the scope tree alone, innermost scope first, so a local declaration shadows an outer one — for lowering a send target without a resolver over its document. At each scope, a member the scope's declaration inherits from its generalizations counts as the scope's own, so an inherited port shadows like a declared one.
func GatherFrame ¶
GatherFrame names the frame doc's gather runs in: apart from the frame of doc's analysis, so a judgment dropped for an answer it read does not take the gather it had no part in with it.
func GatheredDoc ¶
GatheredDoc is the document whose gather frame the name is, if it is one.
func GeneralBodies ¶ added in v0.11.0
GeneralBodies returns the bodies of the types the declaration owning body specializes, subsets, redefines or is typed by, nearest first and each once: where a member the declaration inherits was declared.
func ImplicitlyRedefined ¶
ImplicitlyRedefined reports whether a member takes an inherited feature's name by implicitly redefining it: a behavior parameter matched by position, and the subject, actors, stakeholders and objective of a requirement or case (KerML 7.3.4.5, SysML 7.18.4).
func IsAssertion ¶ added in v0.10.0
IsAssertion reports whether u is an `assert constraint`, which a succession may order between an action's steps.
func IsVertex ¶
IsVertex reports whether decl is a vertex a transition may name: a state, a pseudostate, a control node standing in for one (SysML 7.19.2), or a terminate action ending the machine (SysML 7.18.3 `then stop; action stop terminate;`).
func JournalNew ¶
func JournalNew[K comparable, V any](r *Resolver, m map[K]V, k K, node ast.Node)
JournalNew journals the deletion of m[k], about to be written for node the first time, with the innermost frame: in that frame's ledger for m.
func MissingRedefinedActionNode ¶ added in v0.10.0
MissingRedefinedActionNode returns the name of a target a nested action usage says it redefines but which is not an inherited action node.
func ParameterizedByName ¶
ParameterizedByName reports whether sym is a case or requirement — including a concern or viewpoint, which are requirements — whose subject, actors and stakeholders redefine the inherited ones by name (SysML 7.18.4, 7.19.4). That is not modelled and not distinguishable from an ordinary feature here, so the conflict rule skips such a body entirely.
func RedefinesActionNode ¶
RedefinesActionNode reports whether node, declared in body, redefines decl — directly or through a node it redefines that does — from the scope tree alone.
func TypeDeclInScope ¶
TypeDeclInScope is TypeDecl from the scope tree alone, for a machine lowered without a resolver over its document.
func UnresolvedSubject ¶ added in v0.12.0
UnresolvedSubject is the reference an unresolved-reference message is about, as written, with whatever hint follows it cut off; ok is false for a message about anything else.
func VertexInScope ¶
VertexInScope finds the vertex an endpoint names from the scope tree alone, innermost scope first, for a machine lowered without a resolver over its document (lower.ToStateGraph): no index is consulted, so nothing outside the scopes the endpoint was written in can answer it.
Types ¶
type Diagnostic ¶
type Diagnostic struct {
Span source.Span
Message string
// Code names the kind of problem; empty leaves it to the message.
Code string
// Fixes are the unambiguous edits resolving the diagnostic, offered by an
// editor as quick fixes.
Fixes []diag.Fix
// Warning reports a well-formedness rule the reference states as a warning:
// the model still resolves, so validation continues past it.
Warning bool
// IllFormed marks a Warning the specification states as a validation
// constraint, so strict conformance reports it as an error.
IllFormed bool
}
Diagnostic is a name-resolution problem tied to a source span.
type HeadRelationship ¶
type HeadRelationship struct {
Scope *symbols.Scope
Kind ast.RelationshipKind
// Member is the chain member the reference is a segment of; nil when the
// reference is the name decided on.
Member *ast.QualifiedName
}
HeadRelationship places a reference in a declaration's head relationship: its target resolves in Scope, the declaration's own, when it opens with a member there.
type MemberLookup ¶
type MemberLookup interface {
// LookupMember searches for a member by name in sym's scope and inherited scopes.
LookupMember(sym *symbols.Symbol, name string) (*symbols.Symbol, bool)
// LookupContributedMember searches the inherited scopes only, skipping
// what sym itself declares.
LookupContributedMember(sym *symbols.Symbol, name string) (*symbols.Symbol, bool)
}
MemberLookup interface abstracts semantic model for inheritance-aware member resolution. Implemented by *semantics.Model.
type Reading ¶
type Reading struct {
// contains filtered or unexported fields
}
Reading is what a qualified name named when read in a chosen scope, with the per-segment records and ambiguity a consumer of ResolveQualified would ask the resolver for afterwards: see ReadQualified.
func (Reading) Alias ¶
Alias returns the alias membership segment i was written as, as PartAlias does.
func (Reading) Ambiguity ¶
Ambiguity returns how many elements the name named when it failed for naming several, as Ambiguity does for a written name.
type Reads ¶ added in v0.9.2
type Reads struct {
// Names, Namespaces and Segments are what the index answered about, sorted.
Names []string
Namespaces []string
Segments []string
// All is set once a frame enumerated the whole name table.
All bool
// Spellings is set once a frame read the set of names spelled, as a
// suggestion for an unresolved name does (Resolver.ReadSpellings).
Spellings bool
// Docs are the documents whose roots or kinds were read or whose frames
// were entered, sorted; the document itself is not among them.
Docs []string
}
Reads is what a document's analysis read of the index: its frame's read set (see frame) closed over the frames it entered, since an entry it used may have been computed in one of them. A record carries it so a workspace can tell whether an index still answers those reads as the analysis saw them.
type Reference ¶
type Reference struct {
Scope *symbols.Scope
QN *ast.QualifiedName
// Via marks a relationship route, whose chained segments resolve from its
// leading name rather than as namespace qualifiers.
Via bool
// Referrer owns the reference subsetting QN is the target of, if any.
Referrer ast.Node
// Chain is set when QN is the member of a feature chain, whose segments are
// members of the operand rather than of Scope (SysML 7.6.6).
Chain *ast.FeatureChainExpr
// Constructed is set when QN labels a constructor argument: a simple name is
// a feature of the instantiated type Constructed names, a qualified one is
// resolved in Scope.
Constructed *ast.QualifiedName
// Redefines is set when QN is the target of a redefinition, which names a
// feature of Scope's generals rather than a member of Scope itself.
Redefines bool
// Condition is set when QN is a name inside an element-filter condition, which
// its own namespace's filters do not restrict (see InCondition).
Condition bool
// Invocation is set when QN is the name an invocation calls, which overload
// selection may resolve to one of several declarations (see ResolveInvocationName).
Invocation *ast.InvocationExpr
// Performed is set when Invocation is the value of an action usage, which
// runs the action it names rather than evaluating a calc of that name.
Performed bool
// Endpoint is set when QN is a transition end, which names a vertex of the
// enclosing machine ahead of anything else it reaches (see ResolveEndpoint).
Endpoint bool
// Import is the import QN is the target of, if any; an `import all` reaches
// private members the visibility rule would otherwise hide.
Import *ast.Import
// Subsetting is the declaration QN subsets, if any; its spelling decides
// whether it is read as a redefinition, as a sibling redefining the name, or
// as the declaration's own name.
Subsetting ast.Node
// Member is the declaration whose text QN is written in, when known.
Member ast.Node
// Within is set when Member is declared inside an expression body: the
// namespace member whose declaration holds the outermost such body.
Within ast.Node
// Head is set when QN is written in a head relationship of a declaration
// with a scope of its own, where the target may resolve ahead of Scope.
Head *HeadRelationship
}
Reference describes one occurrence of a name to resolve on its own, outside a document walk: which scope it is written in, the declaration that refers to it when it is a reference subsetting's target, and the feature chain it is the member segment of. Used by the editor layer, which resolves a single name under the cursor and must reach the same symbol the document walk did.
func ExpressionReferences ¶
ExpressionReferences gathers the references of one expression written on its own, each with scope to resolve in — the names References finds in a body.
func References ¶
func References(root *ast.RootNamespace, rootScope *symbols.Scope) []Reference
References walks a document's scope tree and AST, gathering every QualifiedName reference with the scope it resolves in. It mirrors document.go's traversal: a form handled there but not here is a reference a consumer walking the document — the editor's navigation and highlighting — cannot find.
func RunReferences ¶
func RunReferences(root *ast.RootNamespace, rootScope *symbols.Scope) []Reference
RunReferences is References with the bare names of signal triggers (`accept Halt`), which a run resolves as signal types where the document walk leaves them as event names.
type Regatherer ¶
Regatherer is a model keeping per-document gathers: Regather recomputes those of the documents that changed and names the shared state whose readers have to be dropped (see Invalidate).
type Resolver ¶
type Resolver struct {
Diagnostics []Diagnostic
// contains filtered or unexported fields
}
Resolver performs lazy name resolution over a symbol index, memoizing results keyed by the reference AST node and collecting diagnostics.
func NewRecording ¶ added in v0.9.2
NewRecording is a tracking resolver over a view of idx whose reads report to it alone: for an analysis run beside others over one index, whose reads the record it writes carries (see ReadsOf).
func (*Resolver) AdmittedChildrenOf ¶
func (r *Resolver) AdmittedChildrenOf(scope *symbols.Scope, fqn string, children []*symbols.Symbol) []*symbols.Symbol
AdmittedChildrenOf keeps the members of the namespace fqn that a lookup made in scope can reach, so an enumeration of a namespace (completion) offers only names resolution then admits.
func (*Resolver) AdmittedTopLevel ¶
AdmittedTopLevel keeps the root-level names a lookup made in doc reaches, so an enumeration of them (completion) offers only names resolution then admits: a name another document's import borrowed, or one this document's import filter rejects, is no member of this document's root namespace.
func (*Resolver) AliasNamesNothing ¶
AliasNamesNothing reports whether the name an alias binds reaches no element, because the alias's own target reference is unresolved (KerML 8.2.3.2). A cyclic alias is excluded: its target reference does name an element. A record holds the target the reference named, zero when it named none.
func (*Resolver) AliasTarget ¶ added in v0.9.2
AliasTarget resolves one alias's own target — an alias itself when the alias names one — by the qualified name resolved from the alias's scope; ok is false when the name resolves to nothing.
func (*Resolver) AliasedElement ¶
AliasedElement is the element a name bound to sym reaches: an alias names an existing element rather than being one (KerML 8.2.3.2). An alias whose target is unresolvable stays itself, so its own diagnostic still fires.
func (*Resolver) BindsName ¶
BindsName reports whether sym binds the name it is registered under. A feature with no declared name takes the name of the feature it redefines or references, so it binds none when that target resolves to nothing, or to no feature (KerML 7.3.4.5).
func (*Resolver) CutShort ¶
CutShort records that a guard cut a query short for the lookup at depth.
func (*Resolver) DeclarationTraits ¶ added in v0.9.2
DeclarationTraits answers, for a loaded symbol, what this package asks of a declaration, as the bits its interface record carries: a recorded symbol answers the same predicates from these bits.
func (*Resolver) Depend ¶
Depend records that the enclosing document depends on doc: a symbol of doc was read, so doc's replacement invalidates what was computed from it.
func (*Resolver) Dependents ¶
Dependents reports the documents whose state was computed from doc's, directly; for tests and diagnostics of the relation.
func (*Resolver) DistinguishableByMetaclass ¶ added in v0.10.0
DistinguishableByMetaclass reports whether neither member's element has a metaclass conforming to the other's (KerML 8.3.2.4.3); unknown is never distinguishable.
func (*Resolver) DistinguishableMembers ¶
DistinguishableMembers splits the members of scope whose names the distinguishability rules compare into owned members and aliases: those that bind a name, as LocalBinding finds them. Exported for the library-base half of the rule in internal/check/passes.
func (*Resolver) EndSymbol ¶
EndSymbol returns what the edge end qn resolved to: the vertex a transition end was judged as, or otherwise its last segment's symbol.
func (*Resolver) Endpoint ¶
Endpoint returns the declaration an endpoint names, which lowering builds its edges from (lower.EndpointResolver); the lookup itself reports nothing, since this tier reports an endpoint naming no vertex when it resolves the document.
func (*Resolver) EndpointSymbol ¶
EndpointSymbol returns the resolved symbol for a transition endpoint.
func (*Resolver) Enter ¶
Enter begins a lookup that memoizes its answer and returns its depth, which the guard protecting it passes to CutShort. A nil resolver has no lookups to cut short, so its every answer is settled.
func (*Resolver) EnterDoc ¶
EnterDoc makes doc the owner of what is memoized until the matching LeaveDoc, and records that the enclosing document depends on doc. It is a no-op outside Track, so callers pair it with LeaveDoc unconditionally.
func (*Resolver) FeaturedMembersOf ¶ added in v0.10.0
FeaturedMembersOf lists the features visible in scope that a feature chain written there reads as members of sym through their `featured by` (see featuredMember), for completion on the chain.
func (*Resolver) Gather ¶
Gather runs f, the gathering of doc's facts for a workspace-wide judgment: in doc's gather frame, quiet like a Query, and no dependency of the enclosing document, whose judgment reads the union of gathers by name instead. Invalidate names the gather frames it drops, for the gathers to be redone.
func (*Resolver) ImportTarget ¶
ImportTarget is the namespace or membership an import names, as the import itself reaches it.
func (*Resolver) ImportedBeside ¶ added in v0.11.0
func (r *Resolver) ImportedBeside(scope *symbols.Scope, name string, sym *symbols.Symbol) (*symbols.Symbol, bool)
ImportedBeside reports an element another import of the namespace sym is imported into, along scope's lookup path, brings under name and that sym read as name would be indistinguishable from: both would be hidden there (KerML 7.2.5.4). Nothing where sym is not imported, where the namespace owns the name, or where every other is sym itself (an alias of it) or another metaclass.
func (*Resolver) ImportedElements ¶
ImportedElements enumerates the elements imp surfaces into scope, with the same admission a lookup through imp makes: the import's filter clause and the `filter` members of the declaring namespace (see importAdmitsInto). A membership scope hides (KerML 7.2.5.4) is left out: an import brings nothing under a name another import of scope brings a distinct element under.
func (*Resolver) ImportedElementsInto ¶
func (r *Resolver) ImportedElementsInto(into, scope *symbols.Scope, imp *ast.Import) []*symbols.Symbol
ImportedElementsInto enumerates the elements imp, declared in scope, surfaces into the namespace owning into, which inherits it: an inherited `expose` is admitted against the inheriting view's conditions too (see importAdmitsInto).
func (*Resolver) ImportedMembersInto ¶ added in v0.10.0
func (r *Resolver) ImportedMembersInto(into, scope *symbols.Scope, imp *ast.Import) []*symbols.Symbol
ImportedMembersInto enumerates the named and unnamed members imp surfaces into into, applying the same visibility and filter admission as a lookup.
func (*Resolver) ImportedMembersUnfiltered ¶ added in v0.11.0
func (r *Resolver) ImportedMembersUnfiltered(scope *symbols.Scope, imp *ast.Import, includeUnnamed bool) []*symbols.Symbol
ImportedMembersUnfiltered enumerates the members imp reaches before any element filter is applied — what a filter had to choose from — the unnamed ones too when asked, as ImportedMembersInto lists them.
func (*Resolver) InCondition ¶
func (r *Resolver) InCondition(f func())
InCondition runs the resolution of a filter condition's own names, which its namespace's filters do not restrict: a condition naming a metadata type the namespace imports would otherwise be filtered by itself (KerML 8.2.4). Nothing resolved meanwhile is memoized, so the bypass reaches no other lookup.
func (*Resolver) InDocument ¶
InDocument runs f, the analysis of doc: what it memoizes about doc's own nodes is owned by doc, and the documents it reads are doc's dependencies. Failures resolved here are reported to f and memoized as reported, so the analysis must be the first to resolve doc's references (see Query).
func (*Resolver) InheritedMemberVisible ¶ added in v0.11.0
InheritedMemberVisible reports whether member is visible to owner as inherited.
func (*Resolver) InitialSymbol ¶
InitialSymbol returns the member the initial node's name resolved to: the one a start marker binds to, or the source a succession's `first` refers to; false where the name is a label the node itself declares.
func (*Resolver) Invalidate ¶
Invalidate drops what the documents ch touched own, and what every document depending on them owns, transitively. It returns the documents dropped, sorted; each is analyzed afresh on its next request.
func (*Resolver) InvalidateAll ¶
func (r *Resolver) InvalidateAll()
InvalidateAll drops every document's entries.
func (*Resolver) InvocationCandidates ¶
func (r *Resolver) InvocationCandidates(scope *symbols.Scope, qn *ast.QualifiedName) []*symbols.Symbol
InvocationCandidates returns every declaration a called name may denote from scope, in lookup order (ResolveInvocationName reaches the first), an alias standing for its target; library functions need an import.
func (*Resolver) IsBaseThat ¶
IsBaseThat reports whether sym is the implicit `that` feature of the base usage: it names the object featuring a usage's values, so it is reachable in any usage body and its declared type Anything is not what a chain reads.
func (*Resolver) IsOccurrenceThis ¶
IsOccurrenceThis reports whether sym is the context occurrence feature `this`, whose members a chain reads from the object it denotes (see ThisContext).
func (*Resolver) Journal ¶
Journal registers drop to run when the frame owning node ends: the Scratch that disowns node, else the innermost document frame. It is how a side table keyed by node joins the resolver's lifecycle.
func (*Resolver) Journaling ¶
Journaling reports whether a memo write now would be journaled, so a side table can skip building the drop closure when it would not.
func (*Resolver) Leave ¶
Leave ends the innermost lookup and reports whether its answer is settled: no guard cut a query short for a lookup outside it, so it saw every member.
func (*Resolver) LibraryFeature ¶
LibraryFeature reports whether sym is declared by bundled library content, so a model's own declaration under a library name is not mistaken for the library's.
func (*Resolver) LinkMetadataBodies ¶ added in v0.9.2
LinkMetadataBodies sets every annotation body scope's owner as resolving the document would, so resolving it afterwards writes nothing to the scope tree.
func (*Resolver) LocalBinding ¶
LocalBinding returns the first of LocalBindings.
func (*Resolver) LocalBindings ¶
LocalBindings returns the members scope declares under name that bind it, declared names first.
func (*Resolver) LookupName ¶
LookupName resolves an unqualified reference from scope the way a written one resolves — the enclosing scope chain, inherited members, imports, then the global index — but records no diagnostic when it finds nothing.
It is what an evaluator asks: the names it looks up are not all references the source wrote down (a value bound at run time is looked up the same way), and a miss is for the evaluator to report against the value it was reading.
func (*Resolver) LookupNameExcluding ¶
func (r *Resolver) LookupNameExcluding(scope *symbols.Scope, name string, decl ast.Node) (*symbols.Symbol, bool)
LookupNameExcluding resolves name from scope as LookupName does, with decl's own binding hidden: what the name resolves to where decl does not declare it.
func (*Resolver) MachineStateVertex ¶
func (r *Resolver) MachineStateVertex(scope *symbols.Scope, qn *ast.QualifiedName, sym *symbols.Symbol) bool
MachineStateVertex reports whether sym is a vertex of the state machine enclosing scope, using the same inherited-member predicate as endpoint resolution.
func (*Resolver) MetadataBodyOwner ¶
MetadataBodyOwner returns the type whose features a metadata body implicitly redefines (KerML 7.4.7): the metadata type of `@M { … }` / `metadata m : M { … }`, or the redefined feature for a body nested in one; nil when it does not resolve.
func (*Resolver) PartAlias ¶
PartAlias returns the alias membership the i-th segment of qn was written as, where the name it wrote is an alias of the element PartSymbol reports.
func (*Resolver) PartName ¶
PartName returns the symbol whose name the i-th segment of qn wrote: the alias membership when it was written as an alias name, else the element it reached.
func (*Resolver) PartSymbol ¶
PartSymbol returns the symbol the i-th segment of qn resolved to during a previous resolution by this resolver. Callers that need intermediate resolutions of a qualified name (a hover over `A::B` in `A::B::C`, say) read them here.
func (*Resolver) PrefixScope ¶ added in v0.9.2
PrefixScope returns the scope in which prefix metadata on decl resolves.
func (*Resolver) ProbeReading ¶
ProbeReading is ProbeReference with what each segment of ref.QN reached, a failed reading's segments included. ref.QN should be a fresh node (see Reference.Spelled): its segment records are read off and left cleared.
func (*Resolver) ProbeRedefinitionTarget ¶ added in v0.9.2
func (r *Resolver) ProbeRedefinitionTarget(scope *symbols.Scope, decl ast.Node, target ast.Node) (*symbols.Symbol, bool)
ProbeRedefinitionTarget is ResolveRedefinitionTarget for a semantic query: what a feature inherits is asked while other names resolve, some of them imports whose members are suspended meanwhile. A miss there is not the redefinition's to report or remember; the document walk resolves it itself.
func (*Resolver) ProbeReference ¶
ProbeReference resolves ref as a trial reading: what a name spelled differently at the same place would denote. Its diagnostics are suppressed.
func (*Resolver) Query ¶
Query runs f, a query made from doc — a hover, a reference, a completion — quietly: a failure it resolves is neither reported nor memoized, so doc's analysis still reports it. "" is the frame for a query made from no document.
func (*Resolver) ReadAllNames ¶
func (r *Resolver) ReadAllNames()
func (*Resolver) ReadDocument ¶
func (*Resolver) ReadName ¶
ReadName, ReadNamespace, ReadDocument, ReadAllNames and ReadSegment implement symbols.ReadRecorder: what the index answered is what the frame depends on.
func (*Resolver) ReadNamespace ¶
func (*Resolver) ReadQualified ¶
ReadQualified resolves qn as if it were written in scope, the way an expression evaluated in a chosen scope reads its names. A written name is read in one scope, so ResolveQualified memoizes by node; an expression may be evaluated in several, so a reading is memoized by scope and node, and leaves the node's own records untouched.
func (*Resolver) ReadSegment ¶
ReadSegment records that the frame's lookups consulted the symbols registered under last-name segment name (Index.ShortNamed).
func (*Resolver) ReadSpellings ¶ added in v0.10.0
func (r *Resolver) ReadSpellings()
ReadSpellings records that the frame read the set of names the index registers, as a suggestion does: a change to that set invalidates it, a name registered again as spelled before does not.
func (*Resolver) ReadsOf ¶ added in v0.9.2
ReadsOf reports the read set of doc's analysis: its frame's, with those of every frame reachable through its dependencies. ok is false when the resolver does not track or owns nothing for doc.
func (*Resolver) RecordedElement ¶ added in v0.9.2
func (r *Resolver) RecordedElement(ref symbols.ElementRef) *symbols.Symbol
RecordedElement restores the element a record fact names, nil for none.
func (*Resolver) RedefinitionTarget ¶
func (r *Resolver) RedefinitionTarget(scope *symbols.Scope, decl ast.Node, target ast.Node) (*symbols.Symbol, bool)
RedefinitionTarget returns the feature a redefinition owned by decl, declared in scope, targets — an alias followed to what it names. It reports nothing itself.
func (*Resolver) ReferringNamespaceFQN ¶
ReferringNamespaceFQN returns the fully-qualified name of the namespace a reference made in scope belongs to, or "" for one made outside any namespace. It is the context a qualified lookup is answered in: a name a private wildcard import brought into a namespace is a member of it but visible only from within (KerML 8.2.3.3), so `Mid::Hidden` resolves inside Mid and nowhere else.
func (*Resolver) RelationshipScope ¶ added in v0.9.2
func (r *Resolver) RelationshipScope(parent, header *symbols.Scope, rel *ast.Relationship) *symbols.Scope
RelationshipScope returns the scope a head relationship target resolves in.
func (*Resolver) ResolveAliasTarget ¶
ResolveAliasTarget follows an alias symbol to its ultimate non-alias target. Non-alias symbols resolve to themselves. Cycles yield (nil, false).
func (*Resolver) ResolveDocument ¶
func (r *Resolver) ResolveDocument(name string, root *ast.RootNamespace)
ResolveDocument walks the document's references and resolves each, recording diagnostics on the Resolver. name identifies the document in the index.
func (*Resolver) ResolveEndpoint ¶
func (r *Resolver) ResolveEndpoint(scope *symbols.Scope, qn *ast.QualifiedName) (*symbols.Symbol, bool)
ResolveEndpoint resolves the vertex a transition endpoint names, reporting one that names nothing or no vertex. A nil name is the sourceless form: legal.
func (*Resolver) ResolveEndpointRef ¶
func (r *Resolver) ResolveEndpointRef(scope *symbols.Scope, target ast.Node) (*symbols.Symbol, bool)
ResolveEndpointRef resolves an endpoint however a connector end writes it: a name, or a feature chain (`c.c1`) whose member segments read from the vertex its operand names. A nil name is the sourceless form: legal.
func (*Resolver) ResolveInvocationName ¶
func (r *Resolver) ResolveInvocationName(scope *symbols.Scope, qn *ast.QualifiedName) (*symbols.Symbol, bool)
ResolveInvocationName resolves a called name as ResolveQualified does, except that several declarations under a qualified name denote the first: overload selection picks the one run. Hiding is in force as for any name (KerML 7.2.5.4): a name two imports bring as distinct functions is no member, so the call is unresolved there.
func (*Resolver) ResolveName ¶
func (r *Resolver) ResolveName(scope *symbols.Scope, name string, at ast.Node) (*symbols.Symbol, bool)
ResolveName resolves a single-segment (unqualified) reference from the given scope. The at node keys the memo table.
func (*Resolver) ResolveQualified ¶
func (r *Resolver) ResolveQualified(scope *symbols.Scope, qn *ast.QualifiedName) (*symbols.Symbol, bool)
ResolveQualified resolves a qualified-name reference against the given scope. scope may be nil to resolve purely from the global index / document root. Later tasks implement the walk; this skeleton reports unresolved.
func (*Resolver) ResolveRedefinitionTarget ¶
func (r *Resolver) ResolveRedefinitionTarget(scope *symbols.Scope, decl ast.Node, target ast.Node) (*symbols.Symbol, bool)
ResolveRedefinitionTarget resolves the target of a redefinition owned by decl: the feature decl's owner inherits, which decl's own redefinition does not mask (KerML 8.3.3.3.6), whatever name decl borrowed from it.
func (*Resolver) ResolveReference ¶
ResolveReference resolves a single name occurrence, honoring both the reference-subsetting and feature-chain rules.
func (*Resolver) ResolveReferenceTarget ¶
func (r *Resolver) ResolveReferenceTarget(scope *symbols.Scope, decl ast.Node, target ast.Node) (*symbols.Symbol, bool)
ResolveReferenceTarget resolves the target of a reference subsetting owned by decl, which is declared in scope.
func (*Resolver) ResolveTarget ¶
ResolveTarget resolves a relationship target to the feature it names. A target is either a qualified name (`references takePicture`) or a feature chain (`perform providePower.generateTorque`), and the chain's segments are members of the previous segment rather than of the enclosing scope (SysML 7.6.6).
Unlike resolveFeatureChain, this reports nothing: the target of a declared relationship is already resolved — and diagnosed — while walking the document, and this is the query side of that result.
func (*Resolver) Scratch ¶
Scratch runs f, then forgets what f memoized about the transient nodes, so syntax the model does not own (a request expression) is not retained.
func (*Resolver) SetModel ¶
func (r *Resolver) SetModel(model MemberLookup)
func (*Resolver) ShareCollisions ¶ added in v0.11.0
func (r *Resolver) ShareCollisions(shared *SharedCollisions)
ShareCollisions has r read and settle import collisions through shared.
func (*Resolver) SuggestName ¶ added in v0.9.2
func (r *Resolver) SuggestName(msg string, scope *symbols.Scope, name string, at ast.Node, candidates []string) string
SuggestName appends to msg, about the unqualified name written at in scope, the spellings it may mean: first the candidates the caller offers, then the names reachable from scope that an unresolved reference would suggest.
func (*Resolver) ThisContext ¶
ThisContext returns the object `this` denotes where scope was written: the innermost enclosing object, since an owned performance and its subperformances take their owner's `this` ([KerML] Objects::ownedPerformances, Performances::subperformances; [SysML] Parts::Part::ownedActions::this, Actions::Action::subactions). The walk continues through behavior usages and definitions alike. Nil in a standalone behavior, where `this` is the performance itself.
func (*Resolver) Track ¶
func (r *Resolver) Track()
Track makes the resolver keep what it memoizes by owning document, so Invalidate can drop a document's entries and its dependents' when the index changes. The resolver records what it reads from the index from here on.
func (*Resolver) TypeDecl ¶
func (r *Resolver) TypeDecl(scope *symbols.Scope, qn *ast.QualifiedName) (ast.Node, *symbols.Scope, bool)
TypeDecl returns the declaration a type name reaches and the scope of that declaration's body, which is what a usage typed by it inherits its content from. It reports nothing itself: the tier reported the name already.
func (*Resolver) UnresolvedMember ¶
func (r *Resolver) UnresolvedMember(scope *symbols.Scope, qn *ast.QualifiedName, owner *symbols.Symbol, i int) string
UnresolvedMember is the text after "unresolved reference: " for a qualified name read from scope whose segment i names no member of owner: as written, plus `T::'SA-506'` for `T::SA` when that spelling would resolve from scope.
func (*Resolver) UnresolvedName ¶
UnresolvedName is the text after "unresolved reference: " for an unqualified name written at in scope that resolves to nothing: the name and the spellings it may mean.
func (*Resolver) Untracked ¶
func (r *Resolver) Untracked(f func())
Untracked runs f with no frame current: what it reads is recorded nowhere and what it memoizes is owned by no document. For reads whose answer is kept current by other means, such as the list of documents a gather covers.
func (*Resolver) ViewExposureConditions ¶ added in v0.10.0
func (r *Resolver) ViewExposureConditions(view *symbols.Symbol) []symbols.ElementFilter
ViewExposureConditions returns the view's own and inherited filters and the filter clauses on each expose those views state.
type SharedCollisions ¶ added in v0.11.0
type SharedCollisions struct {
// contains filtered or unexported fields
}
SharedCollisions is the import-collision memo (importedCollisions) the documents of one batch share: each is analyzed in a resolver of its own, and without it each walked the chain of namespaces its imports re-export from, so a batch did quadratic work in the chain's depth. An entry is what one resolver settled, with what it read of the index to settle it, which a resolver taking the entry reads again so its document's record still depends on all of it. The index is fixed for a batch, so what one namespace's imports bring is the same from every document.
func NewSharedCollisions ¶ added in v0.11.0
func NewSharedCollisions() *SharedCollisions
NewSharedCollisions returns an empty memo for one batch to share.
Source Files
¶
- accept_payload.go
- alias.go
- diagnostic.go
- distinguishability.go
- document.go
- edge.go
- featured.go
- filter.go
- fixes.go
- frames.go
- invocation.go
- metadata_scope.go
- qualified.go
- reading.go
- reads.go
- redefined_nesting.go
- references.go
- resolver.go
- shared.go
- state_type.go
- suggest.go
- target.go
- this_context.go
- traits.go
- transition.go
- unqualified.go
- visibility.go