class RubyLex
def check_termination_in_prev_line(code)
def check_termination_in_prev_line(code) tokens = self.class.ripper_lex_without_warning(code, context: @context) past_first_newline = false index = tokens.rindex do |t| # traverse first token before last line if past_first_newline if t.tok.include?("\n") true end elsif t.tok.include?("\n") past_first_newline = true false else false end end if index first_token = nil last_line_tokens = tokens[(index + 1)..(tokens.size - 1)] last_line_tokens.each do |t| unless [:on_sp, :on_ignored_sp, :on_comment].include?(t.event) first_token = t break end end if first_token && first_token.state != Ripper::EXPR_DOT tokens_without_last_line = tokens[0..index] code_without_last_line = tokens_without_last_line.map(&:tok).join opens_without_last_line = IRB::NestingParser.open_tokens(tokens_without_last_line) if code_terminated?(code_without_last_line, tokens_without_last_line, opens_without_last_line) return last_line_tokens.map(&:tok).join end end end false end