resolve

package
v0.10.1 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2026 License: Apache-2.0 Imports: 12 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 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).

View Source
const CodeNotAVertex = "not-a-vertex"

CodeNotAVertex marks an endpoint naming an element no transition can start or end at (SysML 7.19.2).

Variables

This section is empty.

Functions

func ActionGeneralBodies

func ActionGeneralBodies(scope *symbols.Scope) []*symbols.Scope

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

func ActionGeneralization(scope *symbols.Scope, typing bool) (bodies []*symbols.Scope, cyclic bool)

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

func ActionNodeDeclaringScope(scope *symbols.Scope, decl ast.Node) *symbols.Scope

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

func ActionNodeOfBody(body *symbols.Scope, name string) (ast.Node, bool)

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

func ActionNodeRedefinitionTargets(body *symbols.Scope, decl ast.Node, subsets bool) []ast.Node

ActionNodeRedefinitionTargets returns inherited action nodes named by a member's redefines and, when subsets is true, subsets relationships.

func FeatureSymbolInScope

func FeatureSymbolInScope(scope *symbols.Scope, segments []string) (*symbols.Symbol, bool)

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

func GatherFrame(doc string) string

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

func GatheredDoc(frame string) (string, bool)

GatheredDoc is the document whose gather frame the name is, if it is one.

func ImplicitlyRedefined

func ImplicitlyRedefined(sym *symbols.Symbol) bool

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

func IsAssertion(u *ast.Usage) bool

IsAssertion reports whether u is an `assert constraint`, which a succession may order between an action's steps.

func IsVertex

func IsVertex(decl ast.Node) bool

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

func MissingRedefinedActionNode(body *symbols.Scope, usage *ast.Usage) string

MissingRedefinedActionNode returns the name of a target a nested action usage says it redefines but which is not an inherited action node.

func ParameterizedByName

func ParameterizedByName(sym *symbols.Symbol) bool

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

func RedefinesActionNode(body *symbols.Scope, node *ast.Usage, decl ast.Node) bool

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

func TypeDeclInScope(scope *symbols.Scope, qn *ast.QualifiedName) (ast.Node, *symbols.Scope, bool)

TypeDeclInScope is TypeDecl from the scope tree alone, for a machine lowered without a resolver over its document.

func VertexInScope

func VertexInScope(scope *symbols.Scope, target ast.Node) (ast.Node, bool)

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
}

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

func (rd Reading) Alias(i int) (*symbols.Symbol, bool)

Alias returns the alias membership segment i was written as, as PartAlias does.

func (Reading) Ambiguity

func (rd Reading) Ambiguity() (int, bool)

Ambiguity returns how many elements the name named when it failed for naming several, as Ambiguity does for a written name.

func (Reading) Part

func (rd Reading) Part(i int) (*symbols.Symbol, bool)

Part returns the element segment i named, as PartSymbol does for a written name.

func (Reading) Symbol

func (rd Reading) Symbol() (*symbols.Symbol, bool)

Symbol returns the element the name reached, or false when it reached none.

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.

func (Reads) Clone added in v0.9.2

func (rd Reads) Clone() Reads

Clone returns reads sharing nothing with rd.

func (Reads) Stale added in v0.9.2

func (rd Reads) Stale(ch symbols.Changes) bool

Stale reports whether ch moved anything the reads saw: what frame.stale asks of a live frame, asked of a recorded one.

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

func ExpressionReferences(scope *symbols.Scope, expr ast.Node) []Reference

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.

func (Reference) Spelled

func (ref Reference) Spelled(qn *ast.QualifiedName) Reference

Spelled returns ref as it would be collected had qn been written in its place: the same occurrence, read the way the document walk reads that spelling.

type Regatherer

type Regatherer interface {
	Regather(docs map[string]bool) (changed []string)
}

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 New

func New(idx *symbols.Index) *Resolver

New creates a resolver over the given index.

func NewRecording added in v0.9.2

func NewRecording(idx *symbols.Index) *Resolver

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

func (r *Resolver) AdmittedTopLevel(doc string, bindings []symbols.RootBinding) []*symbols.Symbol

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

func (r *Resolver) AliasNamesNothing(sym *symbols.Symbol) bool

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

func (r *Resolver) AliasTarget(sym *symbols.Symbol) (*symbols.Symbol, bool)

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

func (r *Resolver) AliasedElement(sym *symbols.Symbol) *symbols.Symbol

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

func (r *Resolver) BindsName(sym *symbols.Symbol) bool

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

func (r *Resolver) CutShort(depth int)

CutShort records that a guard cut a query short for the lookup at depth.

func (*Resolver) DeclarationTraits added in v0.9.2

func (r *Resolver) DeclarationTraits(sym *symbols.Symbol) symbols.Modifiers

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

func (r *Resolver) Depend(doc string)

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

func (r *Resolver) Dependents(doc string) []string

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

func (r *Resolver) DistinguishableByMetaclass(a, b *symbols.Symbol) bool

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

func (r *Resolver) DistinguishableMembers(scope *symbols.Scope) (owned, aliases []*symbols.Symbol)

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

func (r *Resolver) EndSymbol(qn *ast.QualifiedName) (*symbols.Symbol, bool)

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

func (r *Resolver) Endpoint(scope *symbols.Scope, target ast.Node) (ast.Node, bool)

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

func (r *Resolver) EndpointSymbol(scope *symbols.Scope, target ast.Node) (*symbols.Symbol, bool)

EndpointSymbol returns the resolved symbol for a transition endpoint.

func (*Resolver) Enter

func (r *Resolver) Enter() int

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

func (r *Resolver) EnterDoc(doc string)

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

func (r *Resolver) FeaturedMembersOf(scope *symbols.Scope, sym *symbols.Symbol) []*symbols.Symbol

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

func (r *Resolver) Gather(doc string, f func())

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

func (r *Resolver) ImportTarget(scope *symbols.Scope, imp *ast.Import) (*symbols.Symbol, bool)

ImportTarget is the namespace or membership an import names, as the import itself reaches it.

func (*Resolver) ImportedElements

func (r *Resolver) ImportedElements(scope *symbols.Scope, imp *ast.Import) []*symbols.Symbol

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

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) 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

func (r *Resolver) InDocument(doc string, f func())

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) Index

func (r *Resolver) Index() *symbols.Index

Index returns the symbol index this resolver operates over.

func (*Resolver) InitialSymbol

func (r *Resolver) InitialSymbol(n *ast.InitialNode) (*symbols.Symbol, bool)

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

func (r *Resolver) Invalidate(ch symbols.Changes) []string

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

func (r *Resolver) IsBaseThat(sym *symbols.Symbol) bool

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

func (r *Resolver) IsOccurrenceThis(sym *symbols.Symbol) bool

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

func (r *Resolver) Journal(node ast.Node, drop func())

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

func (r *Resolver) Journaling() bool

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

func (r *Resolver) Leave() bool

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) LeaveDoc

func (r *Resolver) LeaveDoc()

LeaveDoc ends the innermost EnterDoc.

func (*Resolver) LibraryFeature

func (r *Resolver) LibraryFeature(sym *symbols.Symbol) bool

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

func (r *Resolver) LinkMetadataBodies(name string)

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

func (r *Resolver) LocalBinding(scope *symbols.Scope, name string) (*symbols.Symbol, bool)

LocalBinding returns the first of LocalBindings.

func (*Resolver) LocalBindings

func (r *Resolver) LocalBindings(scope *symbols.Scope, name string) []*symbols.Symbol

LocalBindings returns the members scope declares under name that bind it, declared names first.

func (*Resolver) LookupName

func (r *Resolver) LookupName(scope *symbols.Scope, name string) (*symbols.Symbol, bool)

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) MemoSize

func (r *Resolver) MemoSize() int

MemoSize is the number of resolutions this resolver retains.

func (*Resolver) MetadataBodyOwner

func (r *Resolver) MetadataBodyOwner(scope *symbols.Scope) *symbols.Symbol

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) Owned

func (r *Resolver) Owned(doc string) int

Owned reports how many entries doc's frame will drop; for tests.

func (*Resolver) PartAlias

func (r *Resolver) PartAlias(qn *ast.QualifiedName, i int) (*symbols.Symbol, bool)

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

func (r *Resolver) PartName(qn *ast.QualifiedName, i int) (*symbols.Symbol, bool)

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

func (r *Resolver) PartSymbol(qn *ast.QualifiedName, i int) (*symbols.Symbol, bool)

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

func (r *Resolver) PrefixScope(scope *symbols.Scope, decl ast.Node) *symbols.Scope

PrefixScope returns the scope in which prefix metadata on decl resolves.

func (*Resolver) ProbeReading

func (r *Resolver) ProbeReading(ref Reference) Reading

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

func (r *Resolver) ProbeReference(ref Reference) (*symbols.Symbol, bool)

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

func (r *Resolver) Query(doc string, f func())

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 (r *Resolver) ReadDocument(name string)

func (*Resolver) ReadName

func (r *Resolver) ReadName(fqn string)

ReadName, ReadNamespace, ReadDocument, ReadAllNames and ReadSegment implement symbols.ReadRecorder: what the index answered is what the frame depends on.

func (*Resolver) ReadNamespace

func (r *Resolver) ReadNamespace(fqn string)

func (*Resolver) ReadQualified

func (r *Resolver) ReadQualified(scope *symbols.Scope, qn *ast.QualifiedName) Reading

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

func (r *Resolver) ReadSegment(name string)

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

func (r *Resolver) ReadsOf(doc string) (reads Reads, ok bool)

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

func (r *Resolver) ReferringNamespaceFQN(scope *symbols.Scope) string

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

func (r *Resolver) ResolveAliasTarget(sym *symbols.Symbol) (*symbols.Symbol, bool)

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.

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

func (r *Resolver) ResolveReference(ref Reference) (*symbols.Symbol, bool)

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

func (r *Resolver) ResolveTarget(scope *symbols.Scope, target ast.Node) (*symbols.Symbol, bool)

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

func (r *Resolver) Scratch(transient map[ast.Node]bool, f func())

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)

SetModel attaches a semantic model for inheritance-aware member resolution. Must be called before resolving feature chains if inherited members are needed.

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

func (r *Resolver) ThisContext(scope *symbols.Scope) *symbols.Symbol

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, [SysML] Parts::Part::this, Actions::Action::subactions). A behavior usage is not its own context — it keeps walking — but a behavior definition is the occurrence it defines, so `this` inside one denotes that definition itself and the walk stops there. 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) Tracking

func (r *Resolver) Tracking() bool

Tracking reports whether memo entries are journaled by owning document.

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

func (r *Resolver) UnresolvedName(scope *symbols.Scope, name string, at ast.Node) string

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.

Jump to

Keyboard shortcuts

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