{"modulePath":"github.com/Open-MBEE/OpenSysML","version":"v0.13.0","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package objref\n\nPackage objref reads the references every surface names a held object by — \\`#\\\u003cid\u003e\\`, 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.\n\n## Functions\n\n```go\nfunc CollectionElements(rt *runtime.Context, val runtime.Value) ([]runtime.Value, error)\n```\nCollectionElements is what a multi-valued feature holds, in order; its contents are either a sequence or a set. Listing more required members than rt's element budget allows is ErrElementLimitExceeded.\n\n```go\nfunc CutSeparator(text string) (sep, rest string, ok bool)\n```\nCutSeparator splits the segment separator text starts with from what follows.\n\n```go\nfunc DeclaredRun(segments []Segment) string\n```\nDeclaredRun is the \\`::\\`-joined registered names of segments that may all name a declaration — none reached through \\`.\\` or an index — or \"\" when one is not.\n\n```go\nfunc Head(segments []Segment) int\n```\nHead 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.\n\n```go\nfunc IsID(text string) bool\n```\nIsID reports whether text is an id alone, \\`#\\` followed by digits.\n\n```go\nfunc IsNamespace(sym *symbols.Symbol) bool\n```\nIsNamespace reports whether sym is a package or namespace, which holds members but is never an object.\n\n```go\nfunc JoinTyped(segments []Segment) string\n```\nJoinTyped spells segments as the qualified name they were written as.\n\n```go\nfunc LeadingDigits(text string) string\n```\nLeadingDigits returns the run of ASCII digits text starts with.\n\n```go\nfunc LooksLikePath(text string) bool\n```\nLooksLikePath 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.\n\n```go\nfunc NamespaceKind(sym *symbols.Symbol) string\n```\nNamespaceKind names what a namespace symbol is for a message.\n\n## Types\n\n```go\ntype PathError struct {\n\tObject  string\n\tSegment string\n\tDetail  string\n\t// Err is what kept the segment's feature value from materializing, nil when\n\t// the segment reached a value that is no object or no feature at all.\n\tErr error\n}\n```\nPathError 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.\n\n```go\nfunc (e *PathError) Error() string\n```\n\n```go\nfunc (e *PathError) Unwrap() error\n```\n\n```go\ntype Ref struct {\n\tText     string\n\tID       int64 // the root object's id, 0 when the root is a declared name\n\tSegments []Segment\n}\n```\nRef is a parsed object reference.\n\n```go\nfunc Parse(text string) (Ref, error)\n```\nParse reads an object reference, reporting what makes text none.\n\n```go\ntype RefError struct {\n\tRef    string\n\tDetail string\n\t// Named is the `::`-joined run of names read before a character no unquoted\n\t// name holds stopped the text: `T::SA` in `T::SA-506`.\n\tNamed string\n\t// Hint is what Named may have meant, appended to the report.\n\tHint string\n}\n```\nRefError reports text that is no object reference at all.\n\n```go\nfunc (e *RefError) Error() string\n```\n\n```go\ntype Segment struct {\n\tText   string // as written, quotes kept, so a lookup reads the notation\n\tName   string // the declaration or feature it names\n\tDotted bool   // written after a `.` rather than `::`\n\tIndex  int    // 1-based element of a multi-valued feature, 0 for none\n}\n```\nSegment is one segment of an object reference.\n\n```go\ntype Walker struct {\n\tRuntime *runtime.Context\n\t// Index, when set, tells library-declared features apart in an unknown-feature\n\t// hint, which counts them rather than listing them.\n\tIndex *symbols.Index\n\t// Format spells a value a path reached in place of an object; nil formats\n\t// as the runtime does.\n\tFormat func(runtime.Value) string\n}\n```\nWalker walks object paths through the feature values of a runtime's objects.\n\n```go\nfunc (w Walker) DeclaredFeatureHint(features []runtime.EffectiveFeature) string\n```\nDeclaredFeatureHint is featureListHint for the features an object of a declaration will have, before one is materialized.\n\n```go\nfunc (w Walker) Walk(inst *runtime.Instance, label string, segments []Segment) (*runtime.Instance, string, error)\n```\nWalk 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.\n\n","path":"github.com/Open-MBEE/OpenSysML/internal/exec/objref","name":"objref","synopsis":"Package objref reads the references every surface names a held object by — `#\u003cid\u003e`, 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.","isRedistributable":true}
