123456789_123456789_123456789_123456789_123456789_

Class: RuboCop::AST::SendNode

Relationships & Source Files
Extension / Inclusion / Inheritance Descendants
Subclasses:
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
self, Node, NodePattern::Macros, Parser::AST::Node
Instance Chain:
Inherits: RuboCop::AST::Node
Defined in: lib/rubocop/ast/node/send_node.rb

Overview

A node extension for send nodes. This will be used in place of a plain node when the builder constructs the AST, making its methods available to all send nodes within RuboCop.

Constant Summary

Node - Inherited

ASSIGNMENTS, BASIC_CONDITIONALS, BASIC_LITERALS, COMPARISON_OPERATORS, COMPOSITE_LITERALS, CONDITIONALS, EMPTY_CHILDREN, EMPTY_PROPERTIES, EQUALS_ASSIGNMENTS, FALSEY_LITERALS, GROUP_FOR_TYPE, IMMUTABLE_LITERALS, KEYWORDS, LITERALS, LITERAL_RECURSIVE_METHODS, LITERAL_RECURSIVE_TYPES, LOOP_TYPES, MUTABLE_LITERALS, OPERATOR_KEYWORDS, POST_CONDITION_LOOP_TYPES, REFERENCES, SHORTHAND_ASSIGNMENTS, SPECIAL_KEYWORDS, TRUTHY_LITERALS, VARIABLES

ParameterizedNode::RestArguments - Included

EMPTY_ARGUMENTS

MethodIdentifierPredicates - Included

ENUMERABLE_METHODS, ENUMERATOR_METHODS, NONMUTATING_ARRAY_METHODS, NONMUTATING_BINARY_OPERATOR_METHODS, NONMUTATING_HASH_METHODS, NONMUTATING_OPERATOR_METHODS, NONMUTATING_STRING_METHODS, NONMUTATING_UNARY_OPERATOR_METHODS, OPERATOR_METHODS

MethodDispatchNode - Included

ARITHMETIC_OPERATORS, SPECIAL_MODIFIERS

Class Method Summary

Node - Inherited

.new,
.def_recursive_literal_predicate

Define a recursive_? predicate method for the given node kind.

NodePattern::Macros - Extended

def_node_matcher

Define a method which applies a pattern to an AST node.

def_node_search

Define a method which recurses over the descendants of an AST node, checking whether any of them match the provided pattern.

Instance Attribute Summary

MethodDispatchNode - Included

#access_modifier?

Checks whether the dispatched method is an access modifier.

#arithmetic_operation?

Checks whether this node is an arithmetic operation.

#assignment?
#bare_access_modifier?

Checks whether the dispatched method is a bare access modifier that affects all methods defined after the macro.

#binary_operation?

Checks whether this is a binary operation.

#block_literal?

Whether this method dispatch has an explicit block.

#const_receiver?

Checks whether the explicit receiver of this method dispatch is a const node.

#dot?

Checks whether the dispatched method uses a dot to connect the receiver and the method name.

#double_colon?

Checks whether the dispatched method uses a double colon to connect the receiver and the method name.

#implicit_call?

Checks whether the method dispatch is the implicit form of #call, e.g.

#lambda?

Checks whether this is a lambda.

#lambda_literal?

Checks whether this is a lambda literal (stabby lambda.).

#macro?

Checks whether the dispatched method is a macro method.

#non_bare_access_modifier?

Checks whether the dispatched method is a non-bare access modifier that affects only the method it receives.

#safe_navigation?

Checks whether the dispatched method uses a safe navigation operator to connect the receiver and the method name.

#self_receiver?

Checks whether the explicit receiver of this method dispatch is self.

#setter_method?

Checks whether the dispatched method is a setter method.

#special_modifier?

Checks whether the dispatched method is a bare private or protected access modifier that affects all methods defined after the macro.

#unary_operation?

Checks whether this is a unary operation.

MethodIdentifierPredicates - Included

#assignment_method?

Checks whether the method is an assignment method.

#bang_method?

Checks whether the method is a bang method.

#camel_case_method?

Checks whether the method is a camel case method, e.g.

#comparison_method?

Checks whether the method is a comparison method.

#const_receiver?

Checks whether the explicit receiver of node is a const node.

#enumerable_method?

Checks whether the method is an Enumerable method.

#enumerator_method?

Checks whether the method is an enumerator method.

#negation_method?

Checks whether this is a negation method, i.e.

#nonmutating_array_method?

Checks whether the method is a nonmutating Array method.

#nonmutating_binary_operator_method?

Checks whether the method is a nonmutating binary operator method.

#nonmutating_hash_method?

Checks whether the method is a nonmutating Hash method.

#nonmutating_operator_method?

Checks whether the method is a nonmutating operator method.

#nonmutating_string_method?

Checks whether the method is a nonmutating String method.

#nonmutating_unary_operator_method?

Checks whether the method is a nonmutating unary operator method.

#operator_method?

Checks whether the method is an operator method.

#predicate_method?

Checks whether the method is a predicate method.

#prefix_bang?

Checks whether this is a prefix bang method, e.g.

#prefix_not?

Checks whether this is a prefix not method, e.g.

#self_receiver?

Checks whether the explicit receiver of this node is self.

ParameterizedNode::RestArguments - Included

#arguments,
#arguments?

Checks whether this node has any arguments.

ParameterizedNode - Included

#arguments?

Checks whether this node has any arguments.

#block_argument?

Whether the last argument of the node is a block pass, i.e.

#parenthesized?

Checks whether this node’s arguments are wrapped in parentheses.

#rest_argument?
#splat_argument?

Checks whether any argument of the node is a splat argument, i.e.

Node - Inherited

#any_block_type?, #any_def_type?, #any_match_pattern_type?, #argument?, #argument_type?, #assignment?, #basic_conditional?, #basic_literal?, #boolean_type?, #call_type?, #chained?, #complete?, #conditional?, #empty_source?, #equals_asgn?, #falsey_literal?, #guard_clause?, #immutable_literal?, #keyword?, #literal?,
#loop_keyword?
Note
loop { } is a normal method call and thus not a loop keyword.
#multiline?

Predicates.

#mutable_literal?, #numeric_type?, #operator_keyword?,
#parent

Returns the parent node, or nil if the receiver is a root node.

#parent?, #parenthesized_call?, #post_condition_loop?,
#pure?

Some expressions are evaluated for their value, some for their side effects, and some for both.

#range_type?, #reference?, #root?,
#send_type?

Most nodes are of 'send' type, so this method is defined separately to make this check as fast as possible.

#shorthand_asgn?, #single_line?, #special_keyword?, #truthy_literal?,
#value_used?

Some expressions are evaluated for their value, some for their side effects, and some for both If we know that an expression is useful only for its side effects, that means we can transform it in ways which preserve the side effects, but change the return value So, does the return value of this node matter? If we changed it to (…​; nil), might that affect anything?

#variable?, #begin_value_used?, #case_if_value_used?, #for_value_used?, #while_until_value_used?

Instance Method Summary

MethodDispatchNode - Included

#block_node

The block, numblock, or itblock node associated with this method dispatch, if any.

#command?

Checks whether the name of the dispatched method matches the argument and has an implicit receiver.

#def_modifier

Checks if this node is part of a chain of def or defs modifiers.

#def_modifier?

Checks if this node is part of a chain of def or defs modifiers.

#method_name

The name of the dispatched method as a symbol.

#receiver

The receiving node of the method dispatch.

#selector

The source range for the method name or keyword that dispatches this call.

#adjacent_def_modifier?, #bare_access_modifier_declaration?, #in_macro_scope?, #non_bare_access_modifier_declaration?

MethodIdentifierPredicates - Included

#method?

Checks whether the method name matches the argument.

ParameterizedNode::RestArguments - Included

#first_argument

A shorthand for getting the first argument of the node.

#last_argument

A shorthand for getting the last argument of the node.

ParameterizedNode - Included

#first_argument

A shorthand for getting the first argument of the node.

#last_argument

A shorthand for getting the last argument of the node.

Node - Inherited

#ancestors

Returns an array of ancestor nodes.

#assignment_or_similar?

Some cops treat the shovel operator as a kind of assignment.

#class_constructor?, #class_definition?, #complete!, #const_name, #defined_module, #defined_module_name,
#each_ancestor

Calls the given block for each ancestor node from parent to root.

#first_line, #global_const?, #lambda?, #lambda_or_proc?, #last_line,
#left_sibling

Use is discouraged, this is a potentially slow method and can lead to even slower algorithms.

#left_siblings

Use is discouraged, this is a potentially slow method and can lead to even slower algorithms.

#line_count,
#loc?

Shortcut to safely check if a location is present.

#loc_is?

Shortcut to safely test a particular location, even if this location does not exist or is nil.

#match_guard_clause?, #module_definition?,
#node_parts

Common destructuring method.

#nonempty_line_count,
#parent_module_name

Searching the AST.

#proc?, #receiver, #recursive_basic_literal?, #recursive_literal?,
#right_sibling

Use is discouraged, this is a potentially slow method and can lead to even slower algorithms.

#right_siblings

Use is discouraged, this is a potentially slow method and can lead to even slower algorithms.

#sibling_index

Returns the index of the receiver node in its siblings.

#source
Note
Some rare nodes may have no source, like s(:args) in foo {}.
#source_length, #source_range, #str_content, #struct_constructor?,
#type?

Determine if the node is one of several node types in a single query Allows specific single node types, as well as "grouped" types (e.g.

#updated

Override Node#updated so that AST::Processor does not try to mutate our ASTs.

#defined_module0, #new_class_or_module_block?, #parent_module_name_for_block, #parent_module_name_for_sclass, #parent_module_name_part, #visit_ancestors

Descendence - Included

#child_nodes

Returns an array of child nodes.

#descendants

Returns an array of descendant nodes.

#each_child_node

Calls the given block for each child node.

#each_descendant

Calls the given block for each descendant node with depth first order.

#each_node

Calls the given block for the receiver and each descendant node in depth-first order.

Sexp - Included

#s

Creates a Node with type type and children children.

Constructor Details

This class inherits a constructor from RuboCop::AST::Node

Instance Attribute Details

#send_type?Boolean (readonly)

[ GitHub ]

  
# File 'lib/rubocop/ast/node/send_node.rb', line 18

def send_type?
  true
end

Instance Method Details

#attribute_accessor?(node = self)

[ GitHub ]

  
# File 'lib/rubocop/ast/node/send_node.rb', line 13

def_node_matcher :attribute_accessor?, <<~PATTERN
  [(send nil? ${:attr_reader :attr_writer :attr_accessor :attr} $...)
   (_    _    _                                                 _ ...)]
PATTERN

#first_argument_index (private)

[ GitHub ]

  
# File 'lib/rubocop/ast/node/send_node.rb', line 24

def first_argument_index
  2
end