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.



11762
11763
11764
11765
# File 'lib/syntax_tree/node.rb', line 11762

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

Instance Attribute Details

#commentsObject (readonly)

Array[ Comment | EmbDoc ]

the comments attached to this node



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

def comments
  @comments
end

Instance Method Details

#===(other) ⇒ Object



11791
11792
11793
# File 'lib/syntax_tree/node.rb', line 11791

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

#accept(visitor) ⇒ Object



11767
11768
11769
# File 'lib/syntax_tree/node.rb', line 11767

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

#child_nodesObject Also known as: deconstruct



11771
11772
11773
# File 'lib/syntax_tree/node.rb', line 11771

def child_nodes
  []
end

#copy(location: nil) ⇒ Object



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

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

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

#deconstruct_keys(_keys) ⇒ Object



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

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

#format(q) ⇒ Object



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

def format(q)
end