ruby-syntax-tree / syntax_tree

Interact with the Ruby syntax tree

Home Page:https://ruby-syntax-tree.github.io/syntax_tree/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

MutationVisitor doesn't follow assignment value

ryanb opened this issue · comments

Looks like the MutationVisitor#visit_assign doesn't follow the node's value.

def visit_assign(node)
  node.copy(target: visit(node.target))
end

Is this intentional? Here's a fix.

def visit_assign(node)
  node.copy(target: visit(node.target), value: visit(node.value))
end

I can make a PR if you need.

Looks like there are other nodes which don't visit the child nodes. Such as visit_assoc and visit_binary. Likely quite a few more.

Is there a reason the entire tree isn't traversed?

My use case here is I'm migrating from key-based i18n to GetText and using SyntaxTree to convert t("some.key") to _("Some Text") and variations on this.