instance method
Prism::Translation::Parser#parse_with_comments
parse_with_comments(source_buffer)
lib/prism/translation/parser.rb
View on GitHub ↗
# File tmp/rubies/ruby-4.0.0/lib/prism/translation/parser.rb, line 112
def parse_with_comments(source_buffer)
@source_buffer = source_buffer
source = source_buffer.source
offset_cache = build_offset_cache(source)
result = unwrap(@parser.parse(source, **prism_options), offset_cache)
[
build_ast(result.value, offset_cache),
build_comments(result.comments, offset_cache)
]
ensure
@source_buffer = nil
end
Parses a source buffer and returns the AST and the source code comments.