Skip to content

Commit

Permalink
Keyword token that follows EXPR_FNAME must be a method name
Browse files Browse the repository at this point in the history
  • Loading branch information
aycabta committed Jul 1, 2019
1 parent 7ff2bfe commit 776759e
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions lib/irb/ruby-lex.rb
Expand Up @@ -283,13 +283,15 @@ def check_code_block(code)
end

def process_nesting_level
indent = @tokens.inject(0) { |indent, t|
indent = 0
@tokens.each_with_index { |t, index|
case t[1]
when :on_lbracket, :on_lbrace, :on_lparen
indent += 1
when :on_rbracket, :on_rbrace, :on_rparen
indent -= 1
when :on_kw
next if index > 0 and @tokens[index - 1][3].allbits?(Ripper::EXPR_FNAME)
case t[2]
when 'def', 'do', 'case', 'for', 'begin', 'class', 'module'
indent += 1
Expand All @@ -301,7 +303,6 @@ def process_nesting_level
end
end
# percent literals are not indented
indent
}
indent
end
Expand All @@ -324,6 +325,7 @@ def check_newline_depth_difference
when :on_rbracket, :on_rbrace, :on_rparen
depth_difference -= 1
when :on_kw
next if index > 0 and @tokens[index - 1][3].allbits?(Ripper::EXPR_FNAME)
case t[2]
when 'def', 'do', 'case', 'for', 'begin', 'class', 'module'
depth_difference += 1
Expand All @@ -346,7 +348,7 @@ def check_corresponding_token_depth
is_first_printable_of_line = true
spaces_of_nest = []
spaces_at_line_head = 0
@tokens.each do |t|
@tokens.each_with_index do |t, index|
corresponding_token_depth = nil
case t[1]
when :on_ignored_nl, :on_nl
Expand All @@ -370,6 +372,7 @@ def check_corresponding_token_depth
corresponding_token_depth = nil
end
when :on_kw
next if index > 0 and @tokens[index - 1][3].allbits?(Ripper::EXPR_FNAME)
case t[2]
when 'def', 'do', 'case', 'for', 'begin', 'class', 'module'
spaces_of_nest.push(spaces_at_line_head)
Expand Down

0 comments on commit 776759e

Please sign in to comment.