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.



11779
11780
11781
11782
# File 'lib/syntax_tree/node.rb', line 11779

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

Instance Attribute Details

#commentsObject (readonly)

Array[ Comment | EmbDoc ]

the comments attached to this node



11777
11778
11779
# File 'lib/syntax_tree/node.rb', line 11777

def comments
  @comments
end

Instance Method Details

#===(other) ⇒ Object



11808
11809
11810
# File 'lib/syntax_tree/node.rb', line 11808

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

#accept(visitor) ⇒ Object



11784
11785
11786
# File 'lib/syntax_tree/node.rb', line 11784

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

#child_nodesObject Also known as: deconstruct



11788
11789
11790
# File 'lib/syntax_tree/node.rb', line 11788

def child_nodes
  []
end

#copy(location: nil) ⇒ Object



11792
11793
11794
11795
11796
11797
# File 'lib/syntax_tree/node.rb', line 11792

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

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

#deconstruct_keys(_keys) ⇒ Object



11801
11802
11803
# File 'lib/syntax_tree/node.rb', line 11801

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

#format(q) ⇒ Object



11805
11806
# File 'lib/syntax_tree/node.rb', line 11805

def format(q)
end