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



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

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

Instance Attribute Details

#commentsObject (readonly)

Array[ Comment | EmbDoc ]

the comments attached to this node



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

def comments
  @comments
end

#locationObject (readonly)

Location

the location of this node



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

def location
  @location
end

Instance Method Details

#===(other) ⇒ Object



11669
11670
11671
# File 'lib/syntax_tree/node.rb', line 11669

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

#accept(visitor) ⇒ Object



11645
11646
11647
# File 'lib/syntax_tree/node.rb', line 11645

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

#child_nodesObject Also known as: deconstruct



11649
11650
11651
# File 'lib/syntax_tree/node.rb', line 11649

def child_nodes
  []
end

#copy(location: nil) ⇒ Object



11653
11654
11655
11656
11657
11658
# File 'lib/syntax_tree/node.rb', line 11653

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

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

#deconstruct_keys(_keys) ⇒ Object



11662
11663
11664
# File 'lib/syntax_tree/node.rb', line 11662

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

#format(q) ⇒ Object



11666
11667
# File 'lib/syntax_tree/node.rb', line 11666

def format(q)
end