MCPcopy Create free account
hub / github.com/google/gapid / node

Method node

gapil/template/functions.go:284–310  ·  view source on GitHub ↗
(writer io.Writer, prefix string, node semantic.Node, arguments ...interface{})

Source from the content-addressed store, hash-verified

282}
283
284func (f *Functions) node(writer io.Writer, prefix string, node semantic.Node, arguments ...interface{}) error {
285 // Collect the arguments to the template
286 args, err := f.buildArgs(arguments...)
287 if err != nil {
288 return err
289 }
290 args["Node"] = node
291 try := make([]string, 0, 4)
292 ty, err := f.TypeOf(node)
293 if node != nil && err == nil {
294 args["Type"] = ty
295 try = append(try,
296 prefix+"#"+ty.Name(),
297 prefix+"."+nodename(ty),
298 )
299 }
300 if node != ty {
301 try = append(try, prefix+"."+nodename(node))
302 }
303 try = append(try, prefix+"_Default")
304 for _, name := range try {
305 if tmpl := f.templates.Lookup(name); tmpl != nil {
306 return f.execute(tmpl, writer, args)
307 }
308 }
309 return fmt.Errorf(`Cannot find templates "%s"`, strings.Join(try, `","`))
310}
311
312// Node dispatches to the template that matches the node best, writing the
313// result to the current output writer.

Callers 2

NodeMethod · 0.95
SNodeMethod · 0.95

Calls 7

buildArgsMethod · 0.95
TypeOfMethod · 0.95
executeMethod · 0.95
nodenameFunction · 0.85
NameMethod · 0.65
LookupMethod · 0.65
JoinMethod · 0.45

Tested by

no test coverage detected