MCPcopy
hub / github.com/hashicorp/hcl / List

Method List

hclwrite/node.go:219–244  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

217}
218
219func (ns nodeSet) List() []*node {
220 if len(ns) == 0 {
221 return nil
222 }
223
224 ret := make([]*node, 0, len(ns))
225
226 // Determine which list we are working with. We assume here that all of
227 // the nodes belong to the same list, since that is part of the contract
228 // for nodeSet.
229 var list *nodes
230 for n := range ns {
231 list = n.list
232 break
233 }
234
235 // We recover the order by iterating over the whole list. This is not
236 // the most efficient way to do it, but our node lists should always be
237 // small so not worth making things more complex.
238 for n := list.first; n != nil; n = n.after {
239 if ns.Has(n) {
240 ret = append(ret, n)
241 }
242 }
243 return ret
244}
245
246// FindNodeWithContent searches the nodes for a node whose content equals
247// the given content. If it finds one then it returns it. Otherwise it returns

Callers 15

TestApplyPathFunction · 0.80
ValueMethod · 0.80
CurrentMethod · 0.80
VariablesMethod · 0.80
RenameVariablePrefixMethod · 0.80
BlocksMethod · 0.80
type_expr.goFile · 0.80
getTypeFunction · 0.80
TestGetTypeFunction · 0.80
TestGetTypeJSONFunction · 0.80
TestGetTypeDefaultsFunction · 0.80

Calls 1

HasMethod · 0.95

Tested by 8

TestApplyPathFunction · 0.64
TestGetTypeFunction · 0.64
TestGetTypeJSONFunction · 0.64
TestGetTypeDefaultsFunction · 0.64
TestTypeStringFunction · 0.64
TestDefaults_ApplyFunction · 0.64
TestExpandUnknownBodiesFunction · 0.64