Class: SyntaxTree::VoidStmt

Inherits:
Node
  • Object
show all
Defined in:
lib/syntax_tree/node.rb

Overview

VoidStmt represents an empty lexical block of code.

;;

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Node

#construct_keys, #pretty_print, #to_json

Constructor Details

#initialize(location:) ⇒ VoidStmt



11610
11611
11612
11613
# File 'lib/syntax_tree/node.rb', line 11610

def initialize(location:)
  @location = location
  @comments = []
end

Instance Attribute Details

#commentsObject (readonly)

Array[ Comment | EmbDoc ]

the comments attached to this node



11608
11609
11610
# File 'lib/syntax_tree/node.rb', line 11608

def comments
  @comments
end

#locationObject (readonly)

Location

the location of this node



11605
11606
11607
# File 'lib/syntax_tree/node.rb', line 11605

def location
  @location
end

Instance Method Details

#===(other) ⇒ Object



11639
11640
11641
# File 'lib/syntax_tree/node.rb', line 11639

def ===(other)
  other.is_a?(VoidStmt)
end

#accept(visitor) ⇒ Object



11615
11616
11617
# File 'lib/syntax_tree/node.rb', line 11615

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

#child_nodesObject Also known as: deconstruct



11619
11620
11621
# File 'lib/syntax_tree/node.rb', line 11619

def child_nodes
  []
end

#copy(location: nil) ⇒ Object



11623
11624
11625
11626
11627
11628
# File 'lib/syntax_tree/node.rb', line 11623

def copy(location: nil)
  node = VoidStmt.new(location: location || self.location)

  node.comments.concat(comments.map(&:copy))
  node
end

#deconstruct_keys(_keys) ⇒ Object



11632
11633
11634
# File 'lib/syntax_tree/node.rb', line 11632

def deconstruct_keys(_keys)
  { location: location, comments: comments }
end

#format(q) ⇒ Object



11636
11637
# File 'lib/syntax_tree/node.rb', line 11636

def format(q)
end