Class: YARP::ParenthesesNode

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

Overview

Represents a parenthesized expression

(10 + 34)
^^^^^^^^^

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(statements, opening_loc, closing_loc, location) ⇒ ParenthesesNode

def initialize: (statements: Node?, opening_loc: Location, closing_loc: Location, location: Location) -> void



4612
4613
4614
4615
4616
4617
# File 'lib/yarp/node.rb', line 4612

def initialize(statements, opening_loc, closing_loc, location)
  @statements = statements
  @opening_loc = opening_loc
  @closing_loc = closing_loc
  @location = location
end

Instance Attribute Details

#closing_locObject (readonly)

attr_reader closing_loc: Location



4609
4610
4611
# File 'lib/yarp/node.rb', line 4609

def closing_loc
  @closing_loc
end

#opening_locObject (readonly)

attr_reader opening_loc: Location



4606
4607
4608
# File 'lib/yarp/node.rb', line 4606

def opening_loc
  @opening_loc
end

#statementsObject (readonly)

attr_reader statements: Node?



4603
4604
4605
# File 'lib/yarp/node.rb', line 4603

def statements
  @statements
end

Instance Method Details

#accept(visitor) ⇒ Object

def accept: (visitor: Visitor) -> void



4620
4621
4622
# File 'lib/yarp/node.rb', line 4620

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

#child_nodesObject Also known as: deconstruct

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



4629
4630
4631
# File 'lib/yarp/node.rb', line 4629

def child_nodes
  [statements]
end

#closingObject

def closing: () -> String



4647
4648
4649
# File 'lib/yarp/node.rb', line 4647

def closing
  closing_loc.slice
end

#deconstruct_keys(keys) ⇒ Object

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



4637
4638
4639
# File 'lib/yarp/node.rb', line 4637

def deconstruct_keys(keys)
  { statements: statements, opening_loc: opening_loc, closing_loc: closing_loc, location: location }
end

#openingObject

def opening: () -> String



4642
4643
4644
# File 'lib/yarp/node.rb', line 4642

def opening
  opening_loc.slice
end

#set_newline_flag(newline_marked) ⇒ Object



4624
4625
4626
# File 'lib/yarp/node.rb', line 4624

def set_newline_flag(newline_marked)
  # Never mark ParenthesesNode with a newline flag, mark children instead
end