MCPcopy
hub / github.com/purpleidea/mgmt / Apply

Method Apply

lang/ast/structs.go:1953–1963  ·  view source on GitHub ↗

Apply is a general purpose iterator method that operates on any AST node. It is not used as the primary AST traversal function because it is less readable and easy to reason about than manually implementing traversal for each node. Nevertheless, it is a useful facility for operations that might only

(fn func(interfaces.Node) error)

Source from the content-addressed store, hash-verified

1951// Nevertheless, it is a useful facility for operations that might only apply to
1952// a select number of node types, since they won't need extra noop iterators...
1953func (obj *StmtResEdge) Apply(fn func(interfaces.Node) error) error {
1954 if obj.Condition != nil {
1955 if err := obj.Condition.Apply(fn); err != nil {
1956 return err
1957 }
1958 }
1959 if err := obj.EdgeHalf.Apply(fn); err != nil {
1960 return err
1961 }
1962 return fn(obj)
1963}
1964
1965// Init initializes this branch of the AST, and returns an error if it fails to
1966// validate.

Callers

nothing calls this directly

Calls 1

ApplyMethod · 0.65

Tested by

no test coverage detected