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.



13745
13746
13747
13748
13749
13750
13751
13752
# File 'lib/prism/node.rb', line 13745

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`.



13834
13835
13836
# File 'lib/prism/node.rb', line 13834

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.



13840
13841
13842
13843
13844
# File 'lib/prism/node.rb', line 13840

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



13755
13756
13757
# File 'lib/prism/node.rb', line 13755

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

#child_nodesObject Also known as: deconstruct

def child_nodes: () -> Array



13760
13761
13762
# File 'lib/prism/node.rb', line 13760

def child_nodes
  []
end

#comment_targetsObject

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



13770
13771
13772
# File 'lib/prism/node.rb', line 13770

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

#compact_child_nodesObject

def compact_child_nodes: () -> Array



13765
13766
13767
# File 'lib/prism/node.rb', line 13765

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



13775
13776
13777
# File 'lib/prism/node.rb', line 13775

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 }



13783
13784
13785
# File 'lib/prism/node.rb', line 13783

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

#inspectObject

def inspect -> String



13824
13825
13826
# File 'lib/prism/node.rb', line 13824

def inspect
  InspectVisitor.compose(self)
end

#keywordObject

def keyword: () -> String



13819
13820
13821
# File 'lib/prism/node.rb', line 13819

def keyword
  keyword_loc.slice
end

#keyword_locObject

attr_reader keyword_loc: Location



13801
13802
13803
13804
13805
# File 'lib/prism/node.rb', line 13801

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



13814
13815
13816
# File 'lib/prism/node.rb', line 13814

def operator
  operator_loc.slice
end

#operator_locObject

attr_reader operator_loc: Location



13788
13789
13790
13791
13792
# File 'lib/prism/node.rb', line 13788

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.



13809
13810
13811
# File 'lib/prism/node.rb', line 13809

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.



13796
13797
13798
# File 'lib/prism/node.rb', line 13796

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

#typeObject

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



13829
13830
13831
# File 'lib/prism/node.rb', line 13829

def type
  :no_keywords_parameter_node
end