Closed marcandre closed 3 years ago
Good call, and I can definitely see a case for deconstruct
here. Maybe not deconstruct_keys
as mentioned except that it may expose the public API of the node itself in a downstream like Rubocop does.
A HashNode
, for instance, might expose deconstruct_keys
for its public API like keys, values
and others to be used as:
node in { class_name: 'HashNode', keys: [*, :our_key, *], values: [*, 42, *] }
So in the context of WhiteQuark's parser not quite. In the context of the downstream extensions on it? Perhaps.
Right. Note that RuboCop has it's own pattern matching (NodePattern
) that is more adapted and powerful.
@marcandre Sorry for delay and thanks! Looks like we don't run Ruby 3.0 on CI, and we still run on Travis, I'll migrate to Github actions.
ast
2.4.2 has been released
Thanks ♥️
It would be helpful to be able to use pattern matching with
Node
s.I'm not sure we should define
deconstruct_keys
, butdeconstruct
seems clearer so the following is a match:cc/ @baweaver and https://bugs.ruby-lang.org/issues/17551