class RubyLex
def self.ripper_lex_without_warning(code, context: nil)
def self.ripper_lex_without_warning(code, context: nil) verbose, $VERBOSE = $VERBOSE, nil lvars_code = generate_local_variables_assign_code(context&.local_variables || []) original_code = code if lvars_code code = "#{lvars_code}\n#{code}" line_no = 0 else line_no = 1 end compile_with_errors_suppressed(code, line_no: line_no) do |inner_code, line_no| lexer = Ripper::Lexer.new(inner_code, '-', line_no) tokens = [] lexer.scan.each do |t| next if t.pos.first == 0 prev_tk = tokens.last position_overlapped = prev_tk && t.pos[0] == prev_tk.pos[0] && t.pos[1] < prev_tk.pos[1] + prev_tk.tok.bytesize if position_overlapped tokens[-1] = t if ERROR_TOKENS.include?(prev_tk.event) && !ERROR_TOKENS.include?(t.event) else tokens << t end end interpolate_ripper_ignored_tokens(original_code, tokens) end ensure $VERBOSE = verbose end