Class: SyntaxTree::VoidStmt

Inherits:
Object
  • Object
show all
Defined in:
lib/syntax_tree.rb

Overview

VoidStmt represents an empty lexical block of code.

;;

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(location:, comments: []) ⇒ VoidStmt

Returns a new instance of VoidStmt.



13166
13167
13168
13169
# File 'lib/syntax_tree.rb', line 13166

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

Instance Attribute Details

#commentsObject (readonly)

[Array[ Comment | EmbDoc ]] the comments attached to this node



13164
13165
13166
# File 'lib/syntax_tree.rb', line 13164

def comments
  @comments
end

#locationObject (readonly)

[Location] the location of this node



13161
13162
13163
# File 'lib/syntax_tree.rb', line 13161

def location
  @location
end

Instance Method Details

#child_nodesObject



13171
13172
13173
# File 'lib/syntax_tree.rb', line 13171

def child_nodes
  []
end

#format(q) ⇒ Object



13175
13176
# File 'lib/syntax_tree.rb', line 13175

def format(q)
end

#pretty_print(q) ⇒ Object



13178
13179
13180
13181
13182
13183
# File 'lib/syntax_tree.rb', line 13178

def pretty_print(q)
  q.group(2, "(", ")") do
    q.text("void_stmt")
    q.pp(Comment::List.new(comments))
  end
end

#to_json(*opts) ⇒ Object



13185
13186
13187
# File 'lib/syntax_tree.rb', line 13185

def to_json(*opts)
  { type: :void_stmt, loc: location, cmts: comments }.to_json(*opts)
end