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.



12893
12894
12895
12896
# File 'lib/syntax_tree.rb', line 12893

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

Instance Attribute Details

#commentsObject (readonly)

Array[ Comment | EmbDoc ]

the comments attached to this node



12891
12892
12893
# File 'lib/syntax_tree.rb', line 12891

def comments
  @comments
end

#locationObject (readonly)

Location

the location of this node



12888
12889
12890
# File 'lib/syntax_tree.rb', line 12888

def location
  @location
end

Instance Method Details

#format(q) ⇒ Object



12898
12899
# File 'lib/syntax_tree.rb', line 12898

def format(q)
end

#pretty_print(q) ⇒ Object



12901
12902
12903
12904
12905
12906
# File 'lib/syntax_tree.rb', line 12901

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

#to_json(*opts) ⇒ Object



12908
12909
12910
# File 'lib/syntax_tree.rb', line 12908

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