MCPcopy Index your code
hub / github.com/expr-lang/expr / Visit

Method Visit

test/patch/patch_test.go:15–25  ·  view source on GitHub ↗
(node *ast.Node)

Source from the content-addressed store, hash-verified

13type lengthPatcher struct{}
14
15func (p *lengthPatcher) Visit(node *ast.Node) {
16 switch n := (*node).(type) {
17 case *ast.MemberNode:
18 if prop, ok := n.Property.(*ast.StringNode); ok && prop.Value == "length" {
19 ast.Patch(node, &ast.BuiltinNode{
20 Name: "len",
21 Arguments: []ast.Node{n.Node},
22 })
23 }
24 }
25}
26
27func TestPatch_length(t *testing.T) {
28 program, err := expr.Compile(

Callers

nothing calls this directly

Calls 1

PatchFunction · 0.92

Tested by

no test coverage detected