MCPcopy Create free account
hub / github.com/expr-lang/expr / Visit

Method Visit

test/patch/change_ident_test.go:47–61  ·  view source on GitHub ↗
(node *ast.Node)

Source from the content-addressed store, hash-verified

45type changeIdent struct{}
46
47func (changeIdent) Visit(node *ast.Node) {
48 id, ok := (*node).(*ast.IdentifierNode)
49 if !ok {
50 return
51 }
52 if id.Value == "foo" {
53 // A correct way to patch the node:
54 //
55 // newNode := &ast.IdentifierNode{Value: "bar"}
56 // ast.Patch(node, newNode)
57 //
58 // But we can do it in a wrong way:
59 id.Value = "bar"
60 }
61}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected