//Walk a ServiceDefinition hierarchy and call the Visit function at each ServiceDefinition. Returns error if any Visit
// returns an error
540767
func Walk(sd *ServiceDefinition, visit Visit) error {
	if err := visit(sd); err != nil {
		return err
	}
	for _, def := range sd.Services {
		if err := Walk(&def, visit); err != nil {
			return err
		}
	}
	return nil
}
1321111
func (n *Parameter) Walk(v walker.Visitor) {
	if v.EnterNode(n) == false {
		return
	}

	if n.VariableType != nil {
		v.EnterChildNode("VariableType", n)
		n.VariableType.Walk(v)
		v.LeaveChildNode("VariableType", n)
	}

	if n.Variable != nil {
		v.EnterChildNode("Variable", n)
		n.Variable.Walk(v)
		v.LeaveChildNode("Variable", n)
	}

	if n.DefaultValue != nil {
		v.EnterChildNode("DefaultValue", n)
		n.DefaultValue.Walk(v)
		v.LeaveChildNode("DefaultValue", n)
	}

	v.LeaveNode(n)
}
338014
func lambdaWalker(lambda func(string) error, ext string) filepath.WalkFunc {
	walk := func(path string, f os.FileInfo, err error) error {
		// if error occurs during traversal to path, exit and crash
		if err != nil {
			return err
		}
		// skip anything that is a directory
		if f.IsDir() {
			return nil
		}

		if filepath.Ext(path) == ext {
			return lambda(path)
		}

		// ignore anything else
		return nil
	}
	return walk
}
582475
func (n *ArgumentList) Walk(v walker.Visitor) {
	if v.EnterNode(n) == false {
		return
	}

	if n.Arguments != nil {
		v.EnterChildList("Arguments", n)
		for _, nn := range n.Arguments {
			if nn != nil {
				nn.Walk(v)
			}
		}
		v.LeaveChildList("Arguments", n)
	}

	v.LeaveNode(n)
}
790247
func Walk(fs http.FileSystem, root string, walkFn filepath.WalkFunc) error {
	info, err := Stat(fs, root)
	if err != nil {
		return walkFn(root, nil, err)
	}
	return walk(fs, root, info, walkFn)
}
492636
func (vi *VersionInfo) Walk() {
	// Create a buffer
	var b bytes.Buffer
	w := binutil.Writer{W: &b}

	// Write to the buffer
	binutil.Walk(vi.Structure, func(v reflect.Value, path string) error {
		if binutil.Plain(v.Kind()) {
			w.WriteLE(v.Interface())
		}
		return nil
	})

	vi.Buffer = b
}
358793
func (n *Interface) Walk(v walker.Visitor) {
	if v.EnterNode(n) == false {
		return
	}

	if n.InterfaceName != nil {
		v.EnterChildNode("InterfaceName", n)
		n.InterfaceName.Walk(v)
		v.LeaveChildNode("InterfaceName", n)
	}

	if n.Extends != nil {
		v.EnterChildNode("Extends", n)
		n.Extends.Walk(v)
		v.LeaveChildNode("Extends", n)
	}

	if n.Stmts != nil {
		v.EnterChildList("Stmts", n)
		for _, nn := range n.Stmts {
			if nn != nil {
				nn.Walk(v)
			}
		}
		v.LeaveChildList("Stmts", n)
	}

	v.LeaveNode(n)
}
938819
func (v *typeSpecVisitor) Visit(n ast.Node) ast.Visitor {
	switch rn := n.(type) {
	default:
		return v
	case *ast.Ident:
		if v.name == nil {
			v.name = rn
		}
		return v
	case *ast.InterfaceType:
		return &interfaceTypeVisitor{ts: v, methods: []method{}}
	case nil:
		if v.iface != nil {
			v.iface.name = v.name
			sn := *v.name
			v.iface.stubname = &sn
			v.iface.stubname.Name = v.name.String()
			v.src.interfaces = append(v.src.interfaces, *v.iface)
		}
		return nil
	}
}
676045
func (l EagerVisitorList) Visit(fn VisitorFunc) error {
	errs := []error(nil)
	for i := range l {
		if err := l[i].Visit(func(info *Info, err error) error {
			if err != nil {
				errs = append(errs, err)
				return nil
			}
			if err := fn(info, nil); err != nil {
				errs = append(errs, err)
			}
			return nil
		}); err != nil {
			errs = append(errs, err)
		}
	}
	return utilerrors.NewAggregate(errs)
}
314356
func Walk(root string, walkFn filepath.WalkFunc) error {
	w := Walker{}
	return w.Walk(root, walkFn)
}
1244160
func (c *Columns) Visit(f func(c *Column) error) error {
	for i := range c.columns {
		err := f(c.columns[i])
		if err != nil {
			return err
		}
	}
	return nil
}
658326
func (a *AttributeDefinition) Walk(walker func(*AttributeDefinition) error) error {
	return walk(a, walker, make(map[string]bool))
}
331320
func (h *fs) Walk(root string, walkFn filepath.WalkFunc) error {
	wrapper := func(path string, info os.FileInfo, err error) error {
		if runtime.GOOS == "windows" && err == nil {
			info = h.enrichFileInfo(path, info)
		}
		return walkFn(path, info, err)
	}
	return filepath.Walk(root, wrapper)
}
1056438
func (vis *VarVisitor) Visit(v interface{}) Visitor {
	if vis.params.SkipObjectKeys {
		if o, ok := v.(Object); ok {
			o.Foreach(func(_, v *Term) {
				Walk(vis, v)
			})
			return nil
		}
	}
	if vis.params.SkipRefHead {
		if r, ok := v.(Ref); ok {
			for _, t := range r[1:] {
				Walk(vis, t)
			}
			return nil
		}
	}
	if vis.params.SkipClosures {
		switch v.(type) {
		case *ArrayComprehension, *ObjectComprehension, *SetComprehension:
			return nil
		}
	}
	if vis.params.SkipWithTarget {
		if v, ok := v.(*With); ok {
			Walk(vis, v.Value)
			return nil
		}
	}
	if vis.params.SkipSets {
		if _, ok := v.(Set); ok {
			return nil
		}
	}
	if vis.params.SkipRefCallHead {
		switch v := v.(type) {
		case *Expr:
			if terms, ok := v.Terms.([]*Term); ok {
				for _, t := range terms[0].Value.(Ref)[1:] {
					Walk(vis, t)
				}
				for i := 1; i < len(terms); i++ {
					Walk(vis, terms[i])
				}
				for _, w := range v.With {
					Walk(vis, w)
				}
				return nil
			}
		case Call:
			operator := v[0].Value.(Ref)
			for i := 1; i < len(operator); i++ {
				Walk(vis, operator[i])
			}
			for i := 1; i < len(v); i++ {
				Walk(vis, v[i])
			}
			return nil
		}
	}
	if v, ok := v.(Var); ok {
		vis.vars.Add(v)
	}
	return vis
}
423908
func (n *TraitUseAlias) Walk(v walker.Visitor) {
	if v.EnterNode(n) == false {
		return
	}

	if n.Ref != nil {
		v.EnterChildNode("Ref", n)
		n.Ref.Walk(v)
		v.LeaveChildNode("Ref", n)
	}

	if n.Modifier != nil {
		v.EnterChildNode("Modifier", n)
		n.Modifier.Walk(v)
		v.LeaveChildNode("Modifier", n)
	}

	if n.Alias != nil {
		v.EnterChildNode("Alias", n)
		n.Alias.Walk(v)
		v.LeaveChildNode("Alias", n)
	}

	v.LeaveNode(n)
}
1356627
func (l VisitorList) Visit(fn VisitorFunc) error {
	for i := range l {
		if err := l[i].Visit(fn); err != nil {
			return err
		}
	}
	return nil
}
1125219
func Walk(vis Visitor, x interface{}) error {
	impl := walkerImpl{
		vis: vis,
	}
	impl.walk(x)
	return impl.err
}