Documentation
¶
Overview ¶
Package objref reads the references every surface names a held object by — `#<id>`, a declared name, or either followed by the features walked from it (`car.wheels[2]`) — and walks such a path through an object's feature values. The REPL's commands and the gRPC service's document-query bindings share it, so one spelling reaches one object on both.
Index ¶
- func CollectionElements(val runtime.Value) []runtime.Value
- func CutSeparator(text string) (sep, rest string, ok bool)
- func DeclaredRun(segments []Segment) string
- func Head(segments []Segment) int
- func IsID(text string) bool
- func IsNamespace(sym *symbols.Symbol) bool
- func JoinTyped(segments []Segment) string
- func LeadingDigits(text string) string
- func LooksLikePath(text string) bool
- func NamespaceKind(sym *symbols.Symbol) string
- type PathError
- type Ref
- type RefError
- type Segment
- type Walker
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CollectionElements ¶
CollectionElements is what a multi-valued feature holds, in order; its contents are either a sequence or a set.
func CutSeparator ¶
CutSeparator splits the segment separator text starts with from what follows.
func DeclaredRun ¶
DeclaredRun is the `::`-joined registered names of segments that may all name a declaration — none reached through `.` or an index — or "" when one is not.
func Head ¶
Head is the count of leading segments that may name a declaration: the run before the first `.` or index, since a segment after `.` is only ever a feature.
func IsNamespace ¶
IsNamespace reports whether sym is a package or namespace, which holds members but is never an object.
func LeadingDigits ¶
LeadingDigits returns the run of ASCII digits text starts with.
func LooksLikePath ¶
LooksLikePath reports whether text can only be an object reference — it starts with an id or walks a feature with `.` or an index — so a failure to resolve it is reported as such rather than tried as a declaration's name.
func NamespaceKind ¶
NamespaceKind names what a namespace symbol is for a message.
Types ¶
type PathError ¶
type PathError struct {
Object string
Segment string
Detail string
// Err is what kept the segment's feature value from materializing, nil when
// the segment reached a value that is no object or no feature at all.
Err error
}
PathError reports a segment of an object reference that names no object of the one before it: Object is that object as the surface reports it, Segment the offending segment as written.
type Ref ¶
type Ref struct {
Text string
ID int64 // the root object's id, 0 when the root is a declared name
Segments []Segment
}
Ref is a parsed object reference.
type RefError ¶
type RefError struct {
Ref string
Detail string
// Named is the `::`-joined run of names read before a character no unquoted
// name holds stopped the text: `T::SA` in `T::SA-506`.
Named string
// Hint is what Named may have meant, appended to the report.
Hint string
}
RefError reports text that is no object reference at all.
type Segment ¶
type Segment struct {
Text string // as written, quotes kept, so a lookup reads the notation
Name string // the declaration or feature it names
Dotted bool // written after a `.` rather than `::`
Index int // 1-based element of a multi-valued feature, 0 for none
}
Segment is one segment of an object reference.
type Walker ¶
type Walker struct {
Runtime *runtime.Context
// Index, when set, tells library-declared features apart in an unknown-feature
// hint, which counts them rather than listing them.
Index *symbols.Index
// Format spells a value a path reached in place of an object; nil formats
// as the runtime does.
Format func(runtime.Value) string
}
Walker walks object paths through the feature values of a runtime's objects.
func (Walker) DeclaredFeatureHint ¶
func (w Walker) DeclaredFeatureHint(features []runtime.EffectiveFeature) string
DeclaredFeatureHint is featureListHint for the features an object of a declaration will have, before one is materialized.
func (Walker) Walk ¶
func (w Walker) Walk(inst *runtime.Instance, label string, segments []Segment) (*runtime.Instance, string, error)
Walk follows segments through feature values from inst, labelled label, to the object they reach. Each segment must name a feature of the object before it that holds an object — one, or one picked by index from a multi-valued feature — and the first that does not is a PathError. The label spells walked features after `.`, which only ever reads as a feature.