Maintenance Ruby 3.4 gets fixes, but no new features. Switch to Ruby 4.0 →
instance method
Prism::Translation::Parser::Compiler#visit_interpolated_string_node
visit_interpolated_string_node(node)
lib/prism/translation/parser/compiler.rb
View on GitHub ↗
# File tmp/rubies/ruby-3.4.1/lib/prism/translation/parser/compiler.rb, line 1083
def visit_interpolated_string_node(node)
if node.heredoc?
return visit_heredoc(node) { |children, closing| builder.string_compose(token(node.opening_loc), children, closing) }
end
parts = if node.parts.one? { |part| part.type == :string_node }
node.parts.flat_map do |node|
if node.type == :string_node && node.unescaped.lines.count >= 2
start_offset = node.content_loc.start_offset
node.unescaped.lines.map do |line|
end_offset = start_offset + line.length
offsets = srange_offsets(start_offset, end_offset)
start_offset = end_offset
builder.string_internal([line, offsets])
end
else
visit(node)
end
end
else
visit_all(node.parts)
end
builder.string_compose(
token(node.opening_loc),
parts,
token(node.closing_loc)
)
end
“foo #{bar}” ^^^^^^^^^^^^