Documentation
¶
Index ¶
- func ApplyAccessorsDetailed(value ResolvedValue, accessors []ValueAccessor) (ResolvedValue, AccessError)
- func GetArgNameFromCompCallArg(compCallArg Node) string
- func GetArgValueFromCompCallArg(compCallArg Node) string
- func GetCompValueFrameArgNames(node Node) []string
- func GetContextKey(node Node) string
- func GetIndexesFromRaw(raw string) []int
- func GetNameFromIndexedRaw(raw string) string
- func GetParamDefValFromCompParam(compParam Node) string
- func GetParamNameFromCompParam(compParam Node) string
- func GetParamRefIndexes(node Node) []int
- func GetParamRefName(node Node) string
- func GetParamRefRaw(node Node) string
- func GetTypeFromCompCallArg(compCallArg Node) string
- func GetTypeFromCompParam(compParam Node) string
- func IsFrameNode(node Node) bool
- func IsRequiredCompParam(compParam Node) bool
- func IsRuleName(node Node, name string) bool
- func IsRuleNameOneOf(node Node, names []string) bool
- type AccessError
- type AccessErrorKind
- type BoundArgs
- type Node
- func DefaultEmptyNode() Node
- func DefaultRootNode() Node
- func FilterNodes(nodes []Node, filter func(Node) bool) []Node
- func FilterNodesInDefContent(node Node, filter func(Node) bool) []Node
- func FilterNodesInTree(node Node, filter func(Node) bool) []Node
- func FindBuiltinCompDef(root Node, name string) Node
- func FindCompDef(root Node, compCallNode Node, name string) Node
- func FindCompDefInScope(root Node, scope Node, node Node, name string) Node
- func FindFrameCompDef(root Node, frame Node, invokerAncestors []Node) Node
- func FindGlobalCompDef(root Node, from Node, name string) Node
- func FindLocalCompDef(srcNode Node, name string) Node
- func FindNode(nodes []Node, filter func(Node) bool) Node
- func FindNodeByRuleName(nodes []Node, name string) Node
- func GetAncestors(node Node) []Node
- func GetCompCallArgByParamName(compCallArgs []Node, paramName string) Node
- func GetCompCallArgsFromCompCall(compCall Node) []Node
- func GetCompDefHeadFromCompDef(compDef Node) Node
- func GetCompParamsFromCompDef(compDef Node) []Node
- func GetCompParamsFromCompHead(head Node) []Node
- func GetLocalCompSourceFromNode(node Node, root Node) Node
- func NewCompValueFrame(value ResolvedValue, parent Node) Node
- func NewCompValueFrameWithArgs(value ResolvedValue, parent Node, args map[string]ResolvedValue) Node
- type Position
- type Range
- type ResolvedValue
- func ApplyAccessors(value ResolvedValue, accessors []ValueAccessor) ResolvedValue
- func ApplyIndexes(value ResolvedValue, indexes []int) ResolvedValue
- func GetCompValueFrameArg(node Node, name string) (ResolvedValue, bool)
- func GetCompValueFromFrame(node Node) (ResolvedValue, bool)
- func ResolveBoundArg(root Node, value ResolvedValue, name string) (ResolvedValue, bool)
- func ResolveCompCallArgValue(root Node, compCallArg Node, invokerAncestors []Node, currentCompCall Node) ResolvedValue
- func ResolveCompParamDefaultFromCompDef(root Node, compDef Node, paramName string) ResolvedValue
- func ResolveContextReferenceValue(root Node, node Node) ResolvedValue
- func ResolveContextValue(root Node, key string) ResolvedValue
- func ResolveFrameArg(root Node, frame Node, paramName string, invokerAncestors []Node) (ResolvedValue, bool)
- func ResolveFrameCompValue(root Node, frame Node, invokerAncestors []Node) ResolvedValue
- func ResolveFrameParam(root Node, frame Node, paramName string, invokerAncestors []Node) ResolvedValue
- func ResolveParamDefaultFromCompCall(root Node, compCallNode Node, paramName string) ResolvedValue
- func ResolveParamFromAncestors(root Node, paramName string, accessors []ValueAccessor, ...) ResolvedValue
- type ValueAccessor
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ApplyAccessorsDetailed ¶ added in v0.3.0
func ApplyAccessorsDetailed(value ResolvedValue, accessors []ValueAccessor) (ResolvedValue, AccessError)
func GetArgNameFromCompCallArg ¶ added in v0.2.0
func GetArgValueFromCompCallArg ¶ added in v0.2.0
func GetCompValueFrameArgNames ¶ added in v0.7.1
GetCompValueFrameArgNames returns the sorted names of the arguments given to the component value by the comp-value-frame node itself, nil if node is not such a frame or has no arguments.
func GetContextKey ¶ added in v0.4.0
func GetIndexesFromRaw ¶ added in v0.3.0
func GetNameFromIndexedRaw ¶ added in v0.3.0
func GetParamDefValFromCompParam ¶ added in v0.2.0
func GetParamNameFromCompParam ¶ added in v0.2.0
func GetParamRefIndexes ¶ added in v0.3.0
func GetParamRefName ¶ added in v0.3.0
func GetParamRefRaw ¶ added in v0.3.0
func GetTypeFromCompCallArg ¶ added in v0.2.0
func GetTypeFromCompParam ¶ added in v0.2.0
func IsFrameNode ¶ added in v0.7.0
IsFrameNode reports whether the node renders the content of a component.
func IsRequiredCompParam ¶ added in v0.7.0
IsRequiredCompParam reports whether the given component parameter definition marks its parameter as required with a '!' glued to the parameter name, e.g. `title! = ""`. The parameter name itself never contains the '!'.
func IsRuleName ¶
func IsRuleNameOneOf ¶
Types ¶
type AccessError ¶ added in v0.3.0
type AccessError struct {
Kind AccessErrorKind
Key string
}
type AccessErrorKind ¶ added in v0.4.2
type AccessErrorKind string
const ( AccessErrorUnknownRecordKey AccessErrorKind = "unknown_record_key" AccessErrorArrayIndexOutOfRange AccessErrorKind = "array_index_out_of_range" AccessErrorInvalidKeyAccess AccessErrorKind = "invalid_key_access" AccessErrorInvalidIndexAccess AccessErrorKind = "invalid_index_access" )
type BoundArgs ¶ added in v0.7.0
type BoundArgs struct {
// contains filtered or unexported fields
}
BoundArgs are the arguments bound to a component value, e.g. menu = menu in MAIN_MENU(menu = menu). They are resolved lazily, in the frame they were written in, no matter where the component value is rendered.
type Node ¶
type Node interface {
Rule() rule.Rule
SetRule(rule.Rule)
Parent() Node
SetParent(Node)
Children() []Node
SetChildren([]Node)
HasChildren() bool
Raw() []byte
SetRaw([]byte)
Range() Range
SetRange(Range)
}
func DefaultEmptyNode ¶
func DefaultEmptyNode() Node
func DefaultRootNode ¶
func DefaultRootNode() Node
func FilterNodesInDefContent ¶ added in v0.7.0
FilterNodesInDefContent returns nodes matching filter within a definition's content, without entering nested sub-component definitions.
func FindBuiltinCompDef ¶ added in v0.3.0
func FindCompDefInScope ¶ added in v0.7.0
FindCompDefInScope finds the component a value refers to. Local components are looked up in the scope the value was written in, falling back to the locals of the global component the node belongs to.
func FindFrameCompDef ¶ added in v0.7.0
FindFrameCompDef returns the definition of the component rendered by the frame. invokerAncestors are the invoker ancestors after the frame.
func FindGlobalCompDef ¶
FindGlobalCompDef searches the scope chain starting from the enclosing globals of from (innermost first, then their inner scopes), stopping at isolated scopes, and finally checking root.
func FindLocalCompDef ¶
func FindNodeByRuleName ¶
func GetAncestors ¶
func GetCompCallArgByParamName ¶ added in v0.2.0
func GetCompCallArgsFromCompCall ¶ added in v0.2.0
func GetCompDefHeadFromCompDef ¶ added in v0.2.0
func GetCompParamsFromCompDef ¶ added in v0.2.0
func GetCompParamsFromCompHead ¶ added in v0.2.0
func GetLocalCompSourceFromNode ¶ added in v0.3.0
func NewCompValueFrame ¶ added in v0.7.0
func NewCompValueFrame(value ResolvedValue, parent Node) Node
func NewCompValueFrameWithArgs ¶ added in v0.7.0
func NewCompValueFrameWithArgs(value ResolvedValue, parent Node, args map[string]ResolvedValue) Node
NewCompValueFrameWithArgs is NewCompValueFrame with arguments given to the component value by the frame itself, such as the item that LIST gives to its item component.
type Position ¶ added in v0.7.0
Position is a point in a source: a 0-based byte offset, a 1-based line and a 1-based column counted in runes.
func PositionAt ¶ added in v0.7.0
PositionAt returns the position of the byte offset in source. Lines are separated by \n.
type Range ¶ added in v0.7.0
Range is the [Start, End) byte range of a node in the source it was parsed from. Nodes that were not parsed have the zero Range.
type ResolvedValue ¶ added in v0.3.0
type ResolvedValue struct {
Type string
Raw string
Items []ResolvedValue
Fields map[string]ResolvedValue
Scope Node
MissingContextKey string
Bound *BoundArgs
}
func ApplyAccessors ¶ added in v0.3.0
func ApplyAccessors(value ResolvedValue, accessors []ValueAccessor) ResolvedValue
func ApplyIndexes ¶ added in v0.3.0
func ApplyIndexes(value ResolvedValue, indexes []int) ResolvedValue
func GetCompValueFrameArg ¶ added in v0.7.0
func GetCompValueFrameArg(node Node, name string) (ResolvedValue, bool)
GetCompValueFrameArg returns the argument the comp-value-frame gives to its component value.
func GetCompValueFromFrame ¶ added in v0.7.0
func GetCompValueFromFrame(node Node) (ResolvedValue, bool)
func ResolveBoundArg ¶ added in v0.7.0
func ResolveBoundArg(root Node, value ResolvedValue, name string) (ResolvedValue, bool)
ResolveBoundArg resolves the argument bound to a component value.
func ResolveCompCallArgValue ¶ added in v0.3.0
func ResolveCompCallArgValue(root Node, compCallArg Node, invokerAncestors []Node, currentCompCall Node) ResolvedValue
func ResolveCompParamDefaultFromCompDef ¶ added in v0.3.0
func ResolveCompParamDefaultFromCompDef(root Node, compDef Node, paramName string) ResolvedValue
func ResolveContextReferenceValue ¶ added in v0.4.0
func ResolveContextReferenceValue(root Node, node Node) ResolvedValue
func ResolveContextValue ¶ added in v0.4.0
func ResolveContextValue(root Node, key string) ResolvedValue
func ResolveFrameArg ¶ added in v0.7.0
func ResolveFrameArg(root Node, frame Node, paramName string, invokerAncestors []Node) (ResolvedValue, bool)
ResolveFrameArg resolves the argument given to the component rendered by the frame, either by the frame itself or bound to the rendered component value. invokerAncestors are the invoker ancestors after the frame.
func ResolveFrameCompValue ¶ added in v0.7.0
func ResolveFrameCompValue(root Node, frame Node, invokerAncestors []Node) ResolvedValue
ResolveFrameCompValue resolves the component value rendered by a param-ref or comp-value-frame frame. invokerAncestors are the invoker ancestors after the frame.
func ResolveFrameParam ¶ added in v0.7.0
func ResolveFrameParam(root Node, frame Node, paramName string, invokerAncestors []Node) ResolvedValue
ResolveFrameParam resolves a parameter of the component rendered by the frame: the argument given by the frame, the argument bound to the rendered component value or the default value of the parameter. invokerAncestors are the invoker ancestors after the frame.
func ResolveParamDefaultFromCompCall ¶ added in v0.3.0
func ResolveParamDefaultFromCompCall(root Node, compCallNode Node, paramName string) ResolvedValue
func ResolveParamFromAncestors ¶ added in v0.3.0
func ResolveParamFromAncestors(root Node, paramName string, accessors []ValueAccessor, invokerAncestors []Node) ResolvedValue
ResolveParamFromAncestors resolves a parameter of the component rendered by the nearest frame in invokerAncestors. There is no parameter inheritance: the lookup never goes past that frame.
func (ResolvedValue) IsZero ¶ added in v0.3.0
func (rv ResolvedValue) IsZero() bool
type ValueAccessor ¶ added in v0.3.0
func GetContextAccessors ¶ added in v0.4.0
func GetContextAccessors(node Node) []ValueAccessor
func GetContextPathFromRaw ¶ added in v0.4.0
func GetContextPathFromRaw(raw string) (string, []ValueAccessor)
func GetParamRefAccessors ¶ added in v0.3.0
func GetParamRefAccessors(node Node) []ValueAccessor
func GetValuePathFromRaw ¶ added in v0.3.0
func GetValuePathFromRaw(raw string) (string, []ValueAccessor)