MCPcopy Create free account
hub / github.com/microsoft/typescript-go / collectChildren

Method collectChildren

internal/api/encoder/decoder.go:120–136  ·  view source on GitHub ↗

collectChildren returns indices of direct children of node i. The returned slice is reused across calls; callers must not retain it.

(i int)

Source from the content-addressed store, hash-verified

118// collectChildren returns indices of direct children of node i.
119// The returned slice is reused across calls; callers must not retain it.
120func (d *astDecoder) collectChildren(i int) []int {
121 d.childBuf = d.childBuf[:0]
122 if i+1 >= d.nodeCount {
123 return d.childBuf
124 }
125 firstChild := i + 1
126 if d.nodeField(firstChild, NodeOffsetParent) != uint32(i) {
127 return d.childBuf
128 }
129 d.childBuf = append(d.childBuf, firstChild)
130 next := int(d.nodeField(firstChild, NodeOffsetNext))
131 for next != 0 {
132 d.childBuf = append(d.childBuf, next)
133 next = int(d.nodeField(next, NodeOffsetNext))
134 }
135 return d.childBuf
136}
137
138func (d *astDecoder) decode() (*ast.Node, error) {
139 if d.nodeCount < 2 {

Callers 1

decodeMethod · 0.95

Calls 3

nodeFieldMethod · 0.95
appendFunction · 0.50
intInterface · 0.50

Tested by

no test coverage detected