mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
parent
cae8bbfe62
commit
47b26795d0
1 changed files with 8 additions and 8 deletions
|
@ -201,14 +201,14 @@ class RubyLex
|
||||||
code = @line + (line.nil? ? '' : line)
|
code = @line + (line.nil? ? '' : line)
|
||||||
code.gsub!(/\s*\z/, '').concat("\n")
|
code.gsub!(/\s*\z/, '').concat("\n")
|
||||||
@tokens = ripper_lex_without_warning(code)
|
@tokens = ripper_lex_without_warning(code)
|
||||||
@continue = process_continue(@tokens)
|
@continue = process_continue
|
||||||
@code_block_open = check_code_block(code, @tokens)
|
@code_block_open = check_code_block(code)
|
||||||
@indent = process_nesting_level(@tokens)
|
@indent = process_nesting_level
|
||||||
@ltype = process_literal_type(@tokens)
|
@ltype = process_literal_type
|
||||||
line
|
line
|
||||||
end
|
end
|
||||||
|
|
||||||
def process_continue(tokens)
|
def process_continue(tokens = @tokens)
|
||||||
# last token is always newline
|
# last token is always newline
|
||||||
if tokens.size >= 2 and tokens[-2][1] == :on_regexp_end
|
if tokens.size >= 2 and tokens[-2][1] == :on_regexp_end
|
||||||
# end of regexp literal
|
# end of regexp literal
|
||||||
|
@ -228,7 +228,7 @@ class RubyLex
|
||||||
false
|
false
|
||||||
end
|
end
|
||||||
|
|
||||||
def check_code_block(code, tokens)
|
def check_code_block(code, tokens = @tokens)
|
||||||
return true if tokens.empty?
|
return true if tokens.empty?
|
||||||
if tokens.last[1] == :on_heredoc_beg
|
if tokens.last[1] == :on_heredoc_beg
|
||||||
return true
|
return true
|
||||||
|
@ -321,7 +321,7 @@ class RubyLex
|
||||||
false
|
false
|
||||||
end
|
end
|
||||||
|
|
||||||
def process_nesting_level(tokens)
|
def process_nesting_level(tokens = @tokens)
|
||||||
indent = 0
|
indent = 0
|
||||||
in_oneliner_def = nil
|
in_oneliner_def = nil
|
||||||
tokens.each_with_index { |t, index|
|
tokens.each_with_index { |t, index|
|
||||||
|
@ -574,7 +574,7 @@ class RubyLex
|
||||||
start_token.last.nil? ? '' : start_token.last
|
start_token.last.nil? ? '' : start_token.last
|
||||||
end
|
end
|
||||||
|
|
||||||
def process_literal_type(tokens)
|
def process_literal_type(tokens = @tokens)
|
||||||
start_token = check_string_literal(tokens)
|
start_token = check_string_literal(tokens)
|
||||||
case start_token[1]
|
case start_token[1]
|
||||||
when :on_tstring_beg
|
when :on_tstring_beg
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue