instance method
Prism::Translation::RubyParser::Compiler#attach_comments
attach_comments(sexp, node)
lib/prism/translation/ruby_parser.rb
View on GitHub ↗
# File tmp/rubies/ruby-4.0.0/lib/prism/translation/ruby_parser.rb, line 1839
def attach_comments(sexp, node)
return unless node.comments
return if node.comments.empty?
extra = node.location.start_line - node.comments.last.location.start_line
comments = node.comments.map(&:slice)
comments.concat([nil] * [0, extra].max)
sexp.comments = comments.join("\n")
end
Attach prism comments to the given sexp.