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.



12974
12975
12976
12977
# File 'lib/syntax_tree.rb', line 12974

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

Instance Attribute Details

#commentsObject (readonly)

Array[ Comment | EmbDoc ]

the comments attached to this node



12972
12973
12974
# File 'lib/syntax_tree.rb', line 12972

def comments
  @comments
end

#locationObject (readonly)

Location

the location of this node



12969
12970
12971
# File 'lib/syntax_tree.rb', line 12969

def location
  @location
end

Instance Method Details

#format(q) ⇒ Object



12979
12980
# File 'lib/syntax_tree.rb', line 12979

def format(q)
end

#pretty_print(q) ⇒ Object



12982
12983
12984
12985
12986
12987
# File 'lib/syntax_tree.rb', line 12982

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

#to_json(*opts) ⇒ Object



12989
12990
12991
# File 'lib/syntax_tree.rb', line 12989

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