// Walk traverses nodes
// Walk is invoked recursively until v.EnterNode returns true
481315
func (n *Concat) Walk(v walker.Visitor) {
	if v.EnterNode(n) == false {
		return
	}

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

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

	v.LeaveNode(n)
}
1165355
func (n *StaticPropertyFetch) Walk(v walker.Visitor) {
	if v.EnterNode(n) == false {
		return
	}

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

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

	v.LeaveNode(n)
}
307558
func (n *Yield) Walk(v walker.Visitor) {
	if v.EnterNode(n) == false {
		return
	}

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

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

	v.LeaveNode(n)
}
806114
func (l Local) Walk(_ context.Context, path string, fn WalkFn) error {
	return filepath.Walk(l.fullPath(path), func(path string, f os.FileInfo, err error) error {
		if err != nil {
			return err
		}

		if !f.IsDir() {
			path = strings.TrimPrefix(path, string(l))
			return fn(path)
		}
		return nil
	})
}
771777
func (n *Assign) Walk(v walker.Visitor) {
	if v.EnterNode(n) == false {
		return
	}

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

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

	v.LeaveNode(n)
}
1346052
func Walk(v Visitor, x interface{}) {
	wrapped, ok := v.(BeforeAndAfterVisitor)
	if !ok {
		wrapped = noopBeforeAndAfterVisitor{v}
	}
	WalkBeforeAndAfter(wrapped, x)
}
217228
func (n *AltFor) Walk(v walker.Visitor) {
	if v.EnterNode(n) == false {
		return
	}

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

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

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

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

	v.LeaveNode(n)
}
889519
func (s *state) walk(node ast.Node) {
	s.at(node)
	switch node := node.(type) {
	case *ast.SoyFileNode:
		s.visitSoyFile(node)
	case *ast.NamespaceNode:
		s.visitNamespace(node)
	case *ast.SoyDocNode:
		return
	case *ast.TemplateNode:
		s.visitTemplate(node)
	case *ast.ListNode:
		s.visitChildren(node)

		// Output nodes ----------
	case *ast.RawTextNode:
		s.writeRawText(node.Text)
	case *ast.PrintNode:
		s.visitPrint(node)
	case *ast.MsgNode:
		s.visitMsg(node)
	case *ast.MsgHtmlTagNode:
		s.writeRawText(node.Text)
	case *ast.CssNode:
		if node.Expr != nil {
			s.jsln(s.bufferName, " += ", node.Expr, " + '-';")
		}
		s.writeRawText([]byte(node.Suffix))
	case *ast.DebuggerNode:
		s.jsln("debugger;")
	case *ast.LogNode:
		s.bufferName += "_"
		s.jsln("var ", s.bufferName, " = '';")
		s.walk(node.Body)
		s.jsln("console.log(", s.bufferName, ");")
		s.bufferName = s.bufferName[:len(s.bufferName)-1]

	// Control flow ----------
	case *ast.IfNode:
		s.visitIf(node)
	case *ast.ForNode:
		s.visitFor(node)
	case *ast.SwitchNode:
		s.visitSwitch(node)
	case *ast.CallNode:
		s.visitCall(node)
	case *ast.LetValueNode:
		s.jsln("var ", s.scope.makevar(node.Name), " = ", node.Expr, ";")
	case *ast.LetContentNode:
		var oldBufferName = s.bufferName
		s.bufferName = s.scope.makevar(node.Name)
		s.jsln("var ", s.bufferName, " = '';")
		s.walk(node.Body)
		s.bufferName = oldBufferName

	// Values ----------
	case *ast.NullNode:
		s.js("null")
	case *ast.StringNode:
		s.js("'")
		template.JSEscape(s.wr, []byte(node.Value))
		s.js("'")
	case *ast.IntNode:
		s.js(node.String())
	case *ast.FloatNode:
		s.js(node.String())
	case *ast.BoolNode:
		s.js(node.String())
	case *ast.GlobalNode:
		s.visitGlobal(node)
	case *ast.ListLiteralNode:
		s.js("[")
		for i, item := range node.Items {
			if i != 0 {
				s.js(",")
			}
			s.walk(item)
		}
		s.js("]")
	case *ast.MapLiteralNode:
		s.js("{")
		var (
			first = true
			keys  = make([]string, len(node.Items))
			i     = 0
		)
		for k := range node.Items {
			keys[i] = k
			i++
		}
		sort.Strings(keys)
		for _, k := range keys {
			if !first {
				s.js(",")
			}
			first = false
			s.js("\"", k, "\"", ":")
			s.walk(node.Items[k])
		}
		s.js("}")
	case *ast.FunctionNode:
		s.visitFunction(node)
	case *ast.DataRefNode:
		s.visitDataRef(node)

	// Arithmetic operators ----------
	case *ast.NegateNode:
		s.js("(-", node.Arg, ")")
	case *ast.AddNode:
		s.op("+", node)
	case *ast.SubNode:
		s.op("-", node)
	case *ast.DivNode:
		s.op("/", node)
	case *ast.MulNode:
		s.op("*", node)
	case *ast.ModNode:
		s.op("%", node)

		// Arithmetic comparisons ----------
	case *ast.EqNode:
		s.op("==", node)
	case *ast.NotEqNode:
		s.op("!=", node)
	case *ast.LtNode:
		s.op("<", node)
	case *ast.LteNode:
		s.op("<=", node)
	case *ast.GtNode:
		s.op(">", node)
	case *ast.GteNode:
		s.op(">=", node)

	// Boolean operators ----------
	case *ast.NotNode:
		s.js("!(", node.Arg, ")")
	case *ast.AndNode:
		s.op("&&", node)
	case *ast.OrNode:
		s.op("||", node)
	case *ast.ElvisNode:
		// ?: is specified to check for null.
		s.js("((", node.Arg1, ") != null ? ", node.Arg1, " : ", node.Arg2, ")")
	case *ast.TernNode:
		s.js("((", node.Arg1, ") ?", node.Arg2, ":", node.Arg3, ")")

	default:
		s.errorf("unknown node (%T): %v", node, node)
	}
}
42654
func (n *RequireOnce) Walk(v walker.Visitor) {
	if v.EnterNode(n) == false {
		return
	}

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

	v.LeaveNode(n)
}
565413
func (n *ArrayItem) Walk(v walker.Visitor) {
	if v.EnterNode(n) == false {
		return
	}

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

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

	v.LeaveNode(n)
}
881281
func (n *ClassMethod) Walk(v walker.Visitor) {
	if v.EnterNode(n) == false {
		return
	}

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

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

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

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

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

	v.LeaveNode(n)
}
765199
func (n *TraitUsePrecedence) 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.Insteadof != nil {
		v.EnterChildList("Insteadof", n)
		for _, nn := range n.Insteadof {
			if nn != nil {
				nn.Walk(v)
			}
		}
		v.LeaveChildList("Insteadof", n)
	}

	v.LeaveNode(n)
}
1266946
func (n *Array) Walk(v walker.Visitor) {
	if v.EnterNode(n) == false {
		return
	}

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

	v.LeaveNode(n)
}
1153493
func Walk(v Visitor, n Node) {
	visitor{Visitor: v}.visit(nil, n)
}
270977
func (b *BinaryTree) Walk() []Comparable {
	walked := make([]Comparable, 0, b.size)
	return walkInOrder(b.root, walked)
}
555778
func (t Tree) Walk(f func(*exphtml.Node)) {
	WalkNodes(t.n, f)
}
829584
func walk(node ast.Node) ([]string, error) {
	var l []string

	switch n := node.(type) {
	case *ast.IndexExpr:
		ret, err := walk(n.X)
		if err != nil {
			return nil, err
		}
		l = append(l, ret...)

		ret, err = walk(n.Index)
		if err != nil {
			return nil, err
		}
		l = append(l, ret...)
	case *ast.SelectorExpr:
		ret, err := walk(n.X)
		if err != nil {
			return nil, err
		}
		l = append(l, ret...)

		ret, err = walk(n.Sel)
		if err != nil {
			return nil, err
		}
		l = append(l, ret...)
	case *ast.Ident:
		return []string{n.Name}, nil
	case *ast.BasicLit:
		value, err := strconv.Unquote(n.Value)
		if err != nil {
			return nil, err
		}
		return []string{value}, nil
	default:
		return nil, trace.BadParameter("unknown node type: %T", n)
	}

	return l, nil
}