MCPcopy Index your code
hub / github.com/sqlc-dev/sqlc / applyList

Method applyList

internal/sql/astutils/rewrite.go:1249–1271  ·  view source on GitHub ↗
(parent ast.Node, name string)

Source from the content-addressed store, hash-verified

1247}
1248
1249func (a *application) applyList(parent ast.Node, name string) {
1250 // avoid heap-allocating a new iterator for each applyList call; reuse a.iter instead
1251 saved := a.iter
1252 a.iter.index = 0
1253 for {
1254 // must reload parent.name each time, since cursor modifications might change it
1255 v := reflect.Indirect(reflect.ValueOf(parent)).FieldByName(name)
1256 if a.iter.index >= v.Len() {
1257 break
1258 }
1259
1260 // element x may be nil in a bad AST - be cautious
1261 var x ast.Node
1262 if e := v.Index(a.iter.index); e.IsValid() {
1263 x = e.Interface().(ast.Node)
1264 }
1265
1266 a.iter.step = 1
1267 a.apply(parent, name, &a.iter, x)
1268 a.iter.index += a.iter.step
1269 }
1270 a.iter = saved
1271}

Callers 1

applyMethod · 0.95

Calls 2

applyMethod · 0.95
IndexMethod · 0.80

Tested by

no test coverage detected