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.



11795
11796
11797
11798
# File 'lib/syntax_tree/node.rb', line 11795

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

Instance Attribute Details

#commentsObject (readonly)

Array[ Comment | EmbDoc ]

the comments attached to this node



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

def comments
  @comments
end

Instance Method Details

#===(other) ⇒ Object



11824
11825
11826
# File 'lib/syntax_tree/node.rb', line 11824

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

#accept(visitor) ⇒ Object



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

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

#child_nodesObject Also known as: deconstruct



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

def child_nodes
  []
end

#copy(location: nil) ⇒ Object



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

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

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

#deconstruct_keys(_keys) ⇒ Object



11817
11818
11819
# File 'lib/syntax_tree/node.rb', line 11817

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

#format(q) ⇒ Object



11821
11822
# File 'lib/syntax_tree/node.rb', line 11821

def format(q)
end