123456789_123456789_123456789_123456789_123456789_

Class: YARD::Parser::Ruby::ParameterNode

Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
self, AstNode, ::Array
Instance Chain:
self, AstNode, ::Array
Inherits: YARD::Parser::Ruby::AstNode
Defined in: lib/yard/parser/ruby/ast_node.rb

Constant Summary

AstNode - Inherited

KEYWORDS

Managing node state

Class Method Summary

AstNode - Inherited

.new

Creates a new AST node.

.node_class_for

Finds the node subclass that should be instantiated for a specific node type.

Instance Attribute Summary

Instance Method Summary

AstNode - Inherited

#==, #children, #first_line, #inspect,
#jump

Searches through the node and all descendants and returns the first node with a type matching any of node_types, otherwise returns the original node (self).

#line, #pretty_print, #show,
#traverse

Traverses the object and yields each node (including descendants) in order.

#unfreeze

Resets node state in tree.

#reset_line_info

Resets line information.

::Array - Inherited

#place

Places values before or after another object (by value) in an array.

Constructor Details

This class inherits a constructor from YARD::Parser::Ruby::AstNode

Instance Method Details

#args_forward

[ GitHub ]

  
# File 'lib/yard/parser/ruby/ast_node.rb', line 430

def args_forward
  # shape is (required, optional, rest, more, keyword, keyword_rest, block)
  # Ruby 3.1 moves :args_forward from rest to keyword_rest
  args_index = YARD.ruby31? ? -2 : 2
  self[args_index].type == :args_forward if self[args_index]
end

#block_param

[ GitHub ]

  
# File 'lib/yard/parser/ruby/ast_node.rb', line 426

def block_param
  self[-1] ? self[-1][0] : nil
end

#double_splat_param

[ GitHub ]

  
# File 'lib/yard/parser/ruby/ast_node.rb', line 414

def double_splat_param
  return nil unless YARD.ruby2?
  if (node = self[-2]).is_a?(AstNode)
    if node.type == :ident
      node
    elsif node.type == :kwrest_param
      # See https://bugs.ruby-lang.org/issues/12387
      node.last
    end
  end
end

#named_params

[ GitHub ]

  
# File 'lib/yard/parser/ruby/ast_node.rb', line 396

def named_params
  return @named_params if defined?(@named_params)

  if YARD.ruby2? && self[-3] && self[-3][0] && self[-3][0].type == :named_arg
    @named_params = self[-3]
  else
    @named_params = nil
  end
end

#splat_param

[ GitHub ]

  
# File 'lib/yard/parser/ruby/ast_node.rb', line 406

def splat_param
  self[2] ? self[2][0] : nil
end

#unnamed_end_params

[ GitHub ]

  
# File 'lib/yard/parser/ruby/ast_node.rb', line 410

def unnamed_end_params
  self[3]
end

#unnamed_optional_params

[ GitHub ]

  
# File 'lib/yard/parser/ruby/ast_node.rb', line 385

def unnamed_optional_params
  return @unnamed_optional_params if defined?(@unnamed_optional_params)

  params = self[1] || []
  if self[-3] && self[-3][0] && self[-3][0].type == :unnamed_optional_arg
    params += self[-3]
  end

  @unnamed_optional_params = params.empty? ? nil : params
end

#unnamed_required_params

[ GitHub ]

  
# File 'lib/yard/parser/ruby/ast_node.rb', line 381

def unnamed_required_params
  self[0]
end