class Rufo::Formatter
def visit_string_literal_end(node)
def visit_string_literal_end(node) line = @line inner = node[1] inner = inner[1..-1] unless node[0] == :xstring_literal visit_exps(inner, with_lines: false) # Every line between the first line and end line of this # string (excluding the first line) must remain like it is # now (we don't want to mess with that when indenting/dedenting) # # This can happen with heredocs, but also with string literals # spanning multiple lines. (line + 1..@line).each do |i| @unmodifiable_string_lines[i] = true end case current_token_kind when :on_heredoc_end heredoc, tilde = @current_heredoc if heredoc && tilde write_indent write current_token_value.strip else write current_token_value.rstrip end next_token skip_space # Simulate a newline after the heredoc @tokens << [[0, 0], :on_ignored_nl, "\n"] when :on_backtick consume_token :on_backtick else consume_token :on_tstring_end end end