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

Attributes inherited from Node

#location

Instance Method Summary collapse

Methods inherited from Node

#construct_keys, #end_char, #pretty_print, #start_char, #to_json, #to_mermaid

Constructor Details

#initialize(location:) ⇒ VoidStmt

Returns a new instance of VoidStmt.



11731
11732
11733
11734
# File 'lib/syntax_tree/node.rb', line 11731

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

Instance Attribute Details

#commentsObject (readonly)

Array[ Comment | EmbDoc ]

the comments attached to this node



11729
11730
11731
# File 'lib/syntax_tree/node.rb', line 11729

def comments
  @comments
end

Instance Method Details

#===(other) ⇒ Object



11760
11761
11762
# File 'lib/syntax_tree/node.rb', line 11760

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

#accept(visitor) ⇒ Object



11736
11737
11738
# File 'lib/syntax_tree/node.rb', line 11736

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

#child_nodesObject Also known as: deconstruct



11740
11741
11742
# File 'lib/syntax_tree/node.rb', line 11740

def child_nodes
  []
end

#copy(location: nil) ⇒ Object



11744
11745
11746
11747
11748
11749
# File 'lib/syntax_tree/node.rb', line 11744

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

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

#deconstruct_keys(_keys) ⇒ Object



11753
11754
11755
# File 'lib/syntax_tree/node.rb', line 11753

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

#format(q) ⇒ Object



11757
11758
# File 'lib/syntax_tree/node.rb', line 11757

def format(q)
end