MCPcopy
hub / github.com/sqlc-dev/sqlc / Apply

Function Apply

internal/sql/astutils/rewrite.go:42–53  ·  view source on GitHub ↗

Apply traverses a syntax tree recursively, starting with root, and calling pre and post for each node as described below. Apply returns the syntax tree, possibly modified. If pre is not nil, it is called for each node before the node's children are traversed (pre-order). If pre returns false, no ch

(root ast.Node, pre, post ApplyFunc)

Source from the content-addressed store, hash-verified

40// respective node's struct definition. A package's files are
41// traversed in the filenames' alphabetical order.
42func Apply(root ast.Node, pre, post ApplyFunc) (result ast.Node) {
43 parent := &struct{ ast.Node }{root}
44 defer func() {
45 if r := recover(); r != nil && r != abort {
46 panic(r)
47 }
48 result = parent.Node
49 }()
50 a := &application{pre: pre, post: post}
51 a.apply(parent, "Node", nil, root)
52 return
53}
54
55var abort = new(int) // singleton, to signal termination of Apply
56

Callers 3

EmbedsFunction · 0.92
NamedParametersFunction · 0.92
TestApplyFunction · 0.92

Calls 1

applyMethod · 0.95

Tested by 1

TestApplyFunction · 0.74