Class: Prism::NoKeywordsParameterNode

Inherits:
PrismNode
  • Object
show all
Defined in:
lib/prism/node.rb,
ext/prism/api_node.c

Overview

Represents the use of ‘**nil` inside method arguments.

def a(**nil)
      ^^^^^
end

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source, node_id, location, flags, operator_loc, keyword_loc) ⇒ NoKeywordsParameterNode

Initialize a new NoKeywordsParameterNode node.



14554
14555
14556
14557
14558
14559
14560
14561
# File 'lib/prism/node.rb', line 14554

def initialize(source, node_id, location, flags, operator_loc, keyword_loc)
  @source = source
  @node_id = node_id
  @location = location
  @flags = flags
  @operator_loc = operator_loc
  @keyword_loc = keyword_loc
end

Class Method Details

.typeObject

Return a symbol representation of this node type. See Node::type.



14649
14650
14651
# File 'lib/prism/node.rb', line 14649

def self.type
  :no_keywords_parameter_node
end

Instance Method Details

#===(other) ⇒ Object

Implements case-equality for the node. This is effectively == but without comparing the value of locations. Locations are checked only for presence.



14655
14656
14657
14658
14659
# File 'lib/prism/node.rb', line 14655

def ===(other)
  other.is_a?(NoKeywordsParameterNode) &&
    (operator_loc.nil? == other.operator_loc.nil?) &&
    (keyword_loc.nil? == other.keyword_loc.nil?)
end

#accept(visitor) ⇒ Object

def accept: (Visitor visitor) -> void



14564
14565
14566
# File 'lib/prism/node.rb', line 14564

def accept(visitor)
  visitor.visit_no_keywords_parameter_node(self)
end

#child_nodesObject Also known as: deconstruct

def child_nodes: () -> Array



14569
14570
14571
# File 'lib/prism/node.rb', line 14569

def child_nodes
  []
end

#comment_targetsObject

def comment_targets: () -> Array[Node | Location]



14585
14586
14587
# File 'lib/prism/node.rb', line 14585

def comment_targets
  [operator_loc, keyword_loc] #: Array[Prism::node | Location]
end

#compact_child_nodesObject

def compact_child_nodes: () -> Array



14580
14581
14582
# File 'lib/prism/node.rb', line 14580

def compact_child_nodes
  []
end

#copy(node_id: self.node_id, location: self.location, flags: self.flags, operator_loc: self.operator_loc, keyword_loc: self.keyword_loc) ⇒ Object

def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?operator_loc: Location, ?keyword_loc: Location) -> NoKeywordsParameterNode



14590
14591
14592
# File 'lib/prism/node.rb', line 14590

def copy(node_id: self.node_id, location: self.location, flags: self.flags, operator_loc: self.operator_loc, keyword_loc: self.keyword_loc)
  NoKeywordsParameterNode.new(source, node_id, location, flags, operator_loc, keyword_loc)
end

#deconstruct_keys(keys) ⇒ Object

def deconstruct_keys: (Array keys) -> { node_id: Integer, location: Location, operator_loc: Location, keyword_loc: Location }



14598
14599
14600
# File 'lib/prism/node.rb', line 14598

def deconstruct_keys(keys)
  { node_id: node_id, location: location, operator_loc: operator_loc, keyword_loc: keyword_loc }
end

#each_child_nodeObject

def each_child_node: () { (Prism::node) -> void } -> void | () -> Enumerator



14574
14575
14576
14577
# File 'lib/prism/node.rb', line 14574

def each_child_node
  return to_enum(:each_child_node) unless block_given?

end

#inspectObject

def inspect -> String



14639
14640
14641
# File 'lib/prism/node.rb', line 14639

def inspect
  InspectVisitor.compose(self)
end

#keywordObject

def keyword: () -> String



14634
14635
14636
# File 'lib/prism/node.rb', line 14634

def keyword
  keyword_loc.slice
end

#keyword_locObject

attr_reader keyword_loc: Location



14616
14617
14618
14619
14620
# File 'lib/prism/node.rb', line 14616

def keyword_loc
  location = @keyword_loc
  return location if location.is_a?(Location)
  @keyword_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF)
end

#operatorObject

def operator: () -> String



14629
14630
14631
# File 'lib/prism/node.rb', line 14629

def operator
  operator_loc.slice
end

#operator_locObject

attr_reader operator_loc: Location



14603
14604
14605
14606
14607
# File 'lib/prism/node.rb', line 14603

def operator_loc
  location = @operator_loc
  return location if location.is_a?(Location)
  @operator_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF)
end

#save_keyword_loc(repository) ⇒ Object

Save the keyword_loc location using the given saved source so that it can be retrieved later.



14624
14625
14626
# File 'lib/prism/node.rb', line 14624

def save_keyword_loc(repository)
  repository.enter(node_id, :keyword_loc)
end

#save_operator_loc(repository) ⇒ Object

Save the operator_loc location using the given saved source so that it can be retrieved later.



14611
14612
14613
# File 'lib/prism/node.rb', line 14611

def save_operator_loc(repository)
  repository.enter(node_id, :operator_loc)
end

#typeObject

Return a symbol representation of this node type. See ‘Node#type`.



14644
14645
14646
# File 'lib/prism/node.rb', line 14644

def type
  :no_keywords_parameter_node
end