-
-
Notifications
You must be signed in to change notification settings - Fork 54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support node groups in Node#each_descendant
and similar traversal methods
#357
Conversation
@@ -98,7 +95,7 @@ class Node < Parser::AST::Node # rubocop:disable Metrics/ClassLength | |||
kwrestarg: :argument, | |||
blockarg: :argument, | |||
forward_arg: :argument, | |||
shardowarg: :argument, | |||
shadowarg: :argument, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo since this was added, tests caught it when I started using each_descendant(:argument)
lib/rubocop/ast/node.rb
Outdated
@@ -528,6 +525,14 @@ def range_type? | |||
GROUP_FOR_TYPE[type] == :range | |||
end | |||
|
|||
def type_or_group_type?(type) | |||
type == self.type || GROUP_FOR_TYPE[self.type] == type | |||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm uncertain whether the behavior indicated by the name type_or_group_type?
is clear. Since it currently seems to be called only from yield_for_types
, how about not publishing type_or_group_type?
and making it a private method instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I took another look and seems like I just reimplemented the existing type?
method. So, I removed both of these new methods instead.
…ethods Sometimes it would be nice to do `each_child_node(:call)` instead of `each_child_node(:send, :csend)`. This nicely mirrors that you can already use these aliases when writing node patterns
871144b
to
d6908ad
Compare
Totally! ❤️ |
Sometimes it would be nice to do
each_child_node(:call)
instead ofeach_child_node(:send, :csend)
. This nicely mirrors that you can already use these aliases when writing node patterns