class SyntaxTree::Parser
def on_args_add_block(arguments, block)
Experimental RBS support (using type sampling data from the type_fusion
project).
def on_args_add_block: (SyntaxTree::Args arguments, false block) -> untyped
This signature was generated using 18 samples from 1 application.
(false | untyped) block
Args arguments,
on_args_add_block: (
:call-seq:
def on_args_add_block(arguments, block) end_char = arguments.parts.any? && arguments.location.end_char # First, see if there is an & operator that could potentially be # associated with the block part of this args_add_block. If there is not, # then just return the arguments. index = tokens.rindex do |token| # If there are any arguments and the operator we found from the list # is not after them, then we're going to return the arguments as-is # because we're looking at an & that occurs before the arguments are # done. return arguments if end_char && token.location.start_char < end_char token.is_a?(Op) && (token.name == :&) end return arguments unless index # Now we know we have an & operator, so we're going to delete it from the # list of tokens to make sure it doesn't get confused with anything else. operator = tokens.delete_at(index) # Construct the location that represents the block argument. location = operator.location location = operator.location.to(block.location) if block # Otherwise, we're looking at an actual block argument (with or without a # block, which could be missing because it could be a bare & since 3.1.0). arg_block = ArgBlock.new(value: block, location: location) Args.new( parts: arguments.parts << arg_block, location: arguments.location.to(location) ) end