Class: YARP::NextNode

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

Overview

Represents the use of the ‘next` keyword.

next 1
^^^^^^

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(arguments, keyword_loc, location) ⇒ NextNode

def initialize: (arguments: ArgumentsNode?, keyword_loc: Location, location: Location) -> void



7359
7360
7361
7362
7363
# File 'lib/yarp/node.rb', line 7359

def initialize(arguments, keyword_loc, location)
  @arguments = arguments
  @keyword_loc = keyword_loc
  @location = location
end

Instance Attribute Details

#argumentsObject (readonly)

attr_reader arguments: ArgumentsNode?



7353
7354
7355
# File 'lib/yarp/node.rb', line 7353

def arguments
  @arguments
end

#keyword_locObject (readonly)

attr_reader keyword_loc: Location



7356
7357
7358
# File 'lib/yarp/node.rb', line 7356

def keyword_loc
  @keyword_loc
end

Instance Method Details

#accept(visitor) ⇒ Object

def accept: (visitor: Visitor) -> void



7366
7367
7368
# File 'lib/yarp/node.rb', line 7366

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

#child_nodesObject Also known as: deconstruct

def child_nodes: () -> Array[nil | Node]



7371
7372
7373
# File 'lib/yarp/node.rb', line 7371

def child_nodes
  [arguments]
end

#comment_targetsObject

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



7376
7377
7378
# File 'lib/yarp/node.rb', line 7376

def comment_targets
  [*arguments, keyword_loc]
end

#copy(**params) ⇒ Object

def copy: (**params) -> NextNode



7381
7382
7383
7384
7385
7386
7387
# File 'lib/yarp/node.rb', line 7381

def copy(**params)
  NextNode.new(
    params.fetch(:arguments) { arguments },
    params.fetch(:keyword_loc) { keyword_loc },
    params.fetch(:location) { location },
  )
end

#deconstruct_keys(keys) ⇒ Object

def deconstruct_keys: (keys: Array) -> Hash[Symbol, nil | Node | Array | String | Token | Array | Location]



7393
7394
7395
# File 'lib/yarp/node.rb', line 7393

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

#inspect(inspector = NodeInspector.new) ⇒ Object



7402
7403
7404
7405
7406
7407
7408
7409
7410
7411
7412
# File 'lib/yarp/node.rb', line 7402

def inspect(inspector = NodeInspector.new)
  inspector << inspector.header(self)
  if (arguments = self.arguments).nil?
    inspector << "├── arguments: ∅\n"
  else
    inspector << "├── arguments:\n"
    inspector << arguments.inspect(inspector.child_inspector("")).delete_prefix(inspector.prefix)
  end
  inspector << "└── keyword_loc: #{inspector.location(keyword_loc)}\n"
  inspector.to_str
end

#keywordObject

def keyword: () -> String



7398
7399
7400
# File 'lib/yarp/node.rb', line 7398

def keyword
  keyword_loc.slice
end