gazayas / masamune-ast

A covenience wrapper around Prism, a Ruby source code parser
MIT License
13 stars 1 forks source link

Use singular form for `type` in the `replace` function #34

Closed gazayas closed 1 year ago

gazayas commented 1 year ago
code = <<~CODE
  :project
CODE

msmn = Masamune::AbstractSyntaxTree.new(code)
msmn.replace(type: :symbols, old_token: "project", new_token: "folder"

We send :symbols to the Masamune::AbstractSyntaxTree object in replace: https://github.com/gazayas/masamune-ast/blob/28d5ffb464148dea699620bebb3c8a33e0ebee98/lib/masamune/slasher.rb#L7

Writing msmn.symbols makes sense to return an Array of Symbols, but as for the type here in replace, it's more natural to write these in their singular form:

msmn.replace(type: :symbol, old_token: "project", new_token: "folder"