Documentation
¶
Index ¶
- func BoundText(b semantics.Bound) string
- func LookupNamed(idx *symbols.Index, id string) []*symbols.Symbol
- func LookupNamedMember(idx *symbols.Index, model *semantics.Model, id string) []*symbols.Symbol
- func MemberChain(idx *symbols.Index, model *semantics.Model, name string) (*symbols.Symbol, string)
- func UnquotedName(id string) (string, bool)
- type Attribute
- type Context
- func (sc *Context) ElementIdentity(sym *symbols.Symbol) string
- func (sc *Context) FormID(sym *symbols.Symbol) string
- func (sc *Context) Identity(sym *symbols.Symbol) string
- func (sc *Context) Lock() func()
- func (sc *Context) Lookup(id string) []*symbols.Symbol
- func (sc *Context) LookupDeclared(id string) []*symbols.Symbol
- func (sc *Context) LookupDeclaredMember(id string) []*symbols.Symbol
- func (sc *Context) LookupElement(id string) []*symbols.Symbol
- func (sc *Context) LookupID(id string) []*symbols.Symbol
- func (sc *Context) LookupMember(id string) []*symbols.Symbol
- func (sc *Context) OwnIdentity(sym *symbols.Symbol) string
- func (sc *Context) Resolve(id string) []*symbols.Symbol
- func (sc *Context) ResolveElement(id string, sem *semantics.Model) []*symbols.Symbol
- func (sc *Context) ResolveMember(id string) []*symbols.Symbol
- func (sc *Context) ResolveMemberName(name string) []*symbols.Symbol
- func (sc *Context) ResolveName(name string) []*symbols.Symbol
- type ElementForm
- type Info
- type Member
- type Multiplicity
- type Options
- type Positional
- type PositionalDocument
- type Specialization
- type TypeInfo
- type TypeRef
- type Value
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LookupNamed ¶
LookupNamed resolves a symbol ID written in either spelling: the quoted, notation-legal form a model author writes ('My Pkg'::Car), or the unquoted spelling the index records (My Pkg::Car), which keeps working as it did. Model elements come before library homonyms: an ID naming both denotes the model's own element, which is what the client asked about.
func LookupNamedMember ¶ added in v0.10.1
LookupNamedMember is LookupNamed for an ID the index registers no declaration under because its last segments name members the type of the segment before them contributes: a member a subtype inherits (Sub::inherited) or one reached through a feature's type (Outer::inner::b). Such a name is walked through the model's member lookup, so the member a redefinition replaces is answered by the redefinition, as a reference in the notation resolves.
func MemberChain ¶ added in v0.10.1
MemberChain resolves a qualified name, in the unquoted spelling the index records, whose later segments are members of the type of the segment before them: the longest prefix one declaration answers to is the chain's root, and the rest is walked through model's member lookup, which follows typing and specialization. A prefix the model declares shadows a library declaration of the same name, as the notation resolves the name. The second result is the fully-qualified name the member is declared under; nil and "" when no prefix is a declaration the rest walks from.
func UnquotedName ¶
UnquotedName is the name a notation-legal qualified name states, with the quoting of its unrestricted segments removed, or false for an ID the notation does not read as one whole name.
Types ¶
type Context ¶
type Context struct {
Index *symbols.Index
Resolver *resolve.Resolver
Semantics *semantics.Model
// Positional names the symbols no qualified name identifies; nil when the
// host derives none, which leaves such symbols without an id.
Positional *Positional
// ElementForm is the element form's ids, which name the elements the
// semantic side tables synthesize; nil when the host converts no form.
ElementForm func() ElementForm
// contains filtered or unexported fields
}
Context holds what converting a symbol to proto needs besides the symbol: its index, and the resolver and semantic model that answer what its declared names refer to. Their memoization is why it is shared per model.
The resolver and semantic model memoize into plain maps, so a shared context must be used by one goroutine at a time; Lock serializes concurrent conversions of the same model.
func NewContext ¶
NewContext builds a conversion context over a symbol index.
func (*Context) ElementIdentity ¶ added in v0.13.0
ElementIdentity is the id a client keeps for any element sym, a metaobject's on the wire: Identity when sym has one, else the element form's `@id`.
func (*Context) FormID ¶ added in v0.13.0
FormID is the `@id` the element form gives sym, "" when the host converts no form.
func (*Context) Identity ¶ added in v0.13.0
Identity is the id SymbolInfo carries for sym: its own identity, or the element form's `@id` when another element's generated id is spelled like it, so no two elements share an id.
func (*Context) Lock ¶
func (sc *Context) Lock() func()
Lock takes exclusive use of the context's resolver and semantic model, and returns the function releasing it.
func (*Context) Lookup ¶ added in v0.13.0
Lookup reads id the way a request without a lookup kind states it: a qualified name first, whatever its visibility, then the element form's `@id` of an element.
func (*Context) LookupDeclared ¶ added in v0.13.0
LookupDeclared reads a symbol id an RPC takes as a qualified name: a declared name first, else the id the element is reported under, so an id the service reports names its element.
func (*Context) LookupDeclaredMember ¶ added in v0.13.0
LookupDeclaredMember is LookupDeclared with a member chain (LookupMember) read as a name too, before the string is read as a reported id.
func (*Context) LookupElement ¶ added in v0.13.0
LookupElement resolves an id a Symbol is reported under: as Lookup reads it, else an unnamed connector end's element id (ownedIdentity). A declaration named like that id is what it answers.
func (*Context) LookupID ¶ added in v0.13.0
LookupID finds the element reported under id — its ElementIdentity, else the element form's `@id` — whatever its visibility; id is never resolved as a name.
func (*Context) LookupMember ¶ added in v0.13.0
LookupMember is Lookup, with a name no declaration answers to walked as a chain of members (see LookupNamedMember).
func (*Context) OwnIdentity ¶ added in v0.13.0
OwnIdentity is the identity sym is declared under: its qualified identity, a declared `@N` quoted (naming.Declared), else its positional one.
func (*Context) Resolve ¶ added in v0.13.0
Resolve reads id the way a request without a lookup kind asks for name resolution: as a qualified name (ResolveName) first, then as the id of the element reported under it.
func (*Context) ResolveElement ¶ added in v0.13.0
ResolveElement is the symbols of sem an ElementIdentity names: qualified or positional as Lookup reads it, and a form `@id` under the nearest such owner.
func (*Context) ResolveMember ¶ added in v0.13.0
ResolveMember is Resolve with an alias answered as the alias membership its namespace holds rather than as the element it names.
func (*Context) ResolveMemberName ¶ added in v0.13.0
ResolveMemberName is ResolveName with an alias answered as the alias membership its namespace holds rather than as the element it names.
func (*Context) ResolveName ¶ added in v0.13.0
ResolveName resolves name as a qualified name from the root (resolve.Resolver.ResolveGlobal), or as the declared name of a public member of a non-visible namespace; an id is never read as one.
type ElementForm ¶ added in v0.13.0
type ElementForm interface {
// ID is the form's `@id` of sym, "" where the form writes none.
ID(sc *Context, sym *symbols.Symbol) string
// Owner decodes an `@id` into the qualified name it is written under and how
// many elements deep below that the element can lie; false for no `@id`.
Owner(id string) (owner string, depth int, ok bool)
// LibraryName is the qualified name of the standard-library element the form references
// under id, the normative id no name can be decoded from.
LibraryName(id string) (name string, ok bool)
}
ElementForm is the element form's ids, which a host that links the exporter supplies; this package spells none itself but an unnamed connector end's (composedEndID).
type Info ¶
type Info struct {
Id string
Name string
Kind string
Metadata map[string]string
ChildIds []string
TypeInfo *TypeInfo
Multiplicity *Multiplicity
Specializations []*Specialization
Attributes []*Attribute
WithheldLibraryAttributes int32
// Members is every member the element has, own then inherited, with
// library-inherited ones withheld and counted unless asked for.
Members []*Member
WithheldLibraryMembers int32
// AnnotatingMetadataIds are the metadata usages annotating the element,
// its own prefix and body ones and those naming it with `about` elsewhere.
AnnotatingMetadataIds []string
}
Info contains protobuf-independent facts about a symbol.
type Member ¶ added in v0.13.0
type Member struct {
// Id is what a symbol lookup takes: the member's qualified name, or the
// positional id (`Owner::@3`) of an unnamed one.
Id string
Name string
Kind string
// Inherited is true when the symbol inherits the member rather than
// declaring it.
Inherited bool
// InheritedFrom is the FQN of the type declaring an inherited member; empty
// for an own member.
InheritedFrom string
// Library is true when the member is declared in standard-library content.
Library bool
}
Member is one member of a symbol, own or inherited, as the service reports it.
type Multiplicity ¶
Multiplicity contains the lower and upper bounds of a symbol's multiplicity.
type Options ¶ added in v0.13.0
type Options struct {
// IncludeLibraryMembers lists the members inherited from standard-library
// content in Members, each marked Library, instead of counting them.
IncludeLibraryMembers bool
// MemberOf is the type the symbol is read as a feature of; the direction
// reported is then the one relative to it (Type::directionOf).
MemberOf *symbols.Symbol
}
Options select what Of reports beyond the facts every caller gets.
type Positional ¶ added in v0.13.0
type Positional struct {
// contains filtered or unexported fields
}
Positional lazily derives the positional identities (`Owner::@N`) of the declarations no qualified identity names, the way the export names them.
func NewPositional ¶ added in v0.13.0
func NewPositional(idx *symbols.Index, docs func() []PositionalDocument) *Positional
NewPositional prepares the positional identities of the documents docs lists; nothing is derived until an identity is asked for.
func (*Positional) Of ¶ added in v0.13.0
func (p *Positional) Of(sym *symbols.Symbol) string
Of is the positional identity of sym, empty when it has none.
func (*Positional) Symbol ¶ added in v0.13.0
func (p *Positional) Symbol(id string) *symbols.Symbol
Symbol is the symbol a positional identity names, nil when none does.
func (*Positional) WithLibrary ¶ added in v0.13.0
func (p *Positional) WithLibrary(read func(name string) ([]byte, error)) *Positional
WithLibrary also names the unnamed declarations of the index's library documents, each document derived when first asked about, its text from read.
type PositionalDocument ¶ added in v0.13.0
type PositionalDocument struct {
File *source.SourceFile
Root *ast.RootNamespace
Scope *symbols.Scope
}
PositionalDocument pairs a document's source and tree with its root scope, for the positional identities of its unnamed declarations.
type Specialization ¶
type Specialization struct {
Kind string
Declared string
TargetId string
TargetQualifiedName string
TargetKind string
}
Specialization describes a declared generalization relationship.
type TypeInfo ¶
type TypeInfo struct {
Declared string
ResolvedId string
ResolvedQualifiedName string
ResolvedKind string
Primitive string
PrimitiveSource string
Quantity bool
Unit string
Types []*TypeRef
}
TypeInfo describes a symbol's written, derived and primitive type. Declared, ResolvedId and ResolvedKind are the typing the declaration writes; Types is the feature's semantic type (Feature::type), which subsetting, reference subsetting and redefinition contribute to.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package elementform gives the symbol facts the exporter's element form ids, for the frontends that link the exporter.
|
Package elementform gives the symbol facts the exporter's element form ids, for the frontends that link the exporter. |