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

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of VoidStmt.



11258
11259
11260
11261
# File 'lib/syntax_tree/node.rb', line 11258

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

Instance Attribute Details

#commentsObject (readonly)

Array[ Comment | EmbDoc ]

the comments attached to this node



11256
11257
11258
# File 'lib/syntax_tree/node.rb', line 11256

def comments
  @comments
end

#locationObject (readonly)

Location

the location of this node



11253
11254
11255
# File 'lib/syntax_tree/node.rb', line 11253

def location
  @location
end

Instance Method Details

#child_nodesObject Also known as: deconstruct



11263
11264
11265
# File 'lib/syntax_tree/node.rb', line 11263

def child_nodes
  []
end

#deconstruct_keys(keys) ⇒ Object



11269
11270
11271
# File 'lib/syntax_tree/node.rb', line 11269

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

#format(q) ⇒ Object



11273
11274
# File 'lib/syntax_tree/node.rb', line 11273

def format(q)
end

#pretty_print(q) ⇒ Object



11276
11277
11278
11279
11280
11281
# File 'lib/syntax_tree/node.rb', line 11276

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

#to_json(*opts) ⇒ Object



11283
11284
11285
# File 'lib/syntax_tree/node.rb', line 11283

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