Introduce RuboCop::Ast::MethodDispatchNode#selector #267
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
If you need to manipulate the call-site of a method dispatch, you have to use
node.loc.selector
for regular methods andnode.loc.keyword
for syntax nodes that behave like method invocations. Super and yield nodes are nodes are examples.This forces us to check if
node.loc
responds to#keyword
in a few places in rubocop proper and we can make it easier if we expose a single method called#selector
(the name is up for debate) and use it for method dispatch nodes.As an example, see HashSyntaxShorthand where I had to define a struct to hide away the selector detection.