Class
This is a result specific to the ‘parse` and `parse_file` methods.
Attributes
Read
The syntax tree that was parsed from the source code.
Class Methods
lib/prism/parse_result.rb
View on GitHub
# File tmp/rubies/ruby-3.4.0-preview1/lib/prism/parse_result.rb, line 587
def initialize(value, comments, magic_comments, data_loc, errors, warnings, source)
@value = value
super(comments, magic_comments, data_loc, errors, warnings, source)
end
Create a new parse result object with the given values.
Instance Methods
lib/prism/parse_result.rb
View on GitHub
# File tmp/rubies/ruby-3.4.0-preview1/lib/prism/parse_result.rb, line 598
def attach_comments!
Comments.new(self).attach! # steep:ignore
end
Attach the list of comments to their respective locations in the tree.
lib/prism/parse_result.rb
View on GitHub
# File tmp/rubies/ruby-3.4.0-preview1/lib/prism/parse_result.rb, line 593
def deconstruct_keys(keys)
super.merge!(value: value)
end
Implement the hash pattern matching interface for ParseResult
.
lib/prism/parse_result.rb
View on GitHub
# File tmp/rubies/ruby-3.4.0-preview1/lib/prism/parse_result.rb, line 604
def mark_newlines!
value.accept(Newlines.new(source.offsets.size)) # steep:ignore
end
Walk the tree and mark nodes that are on a new line, loosely emulating the behavior of CRuby’s ‘:line` tracepoint event.