0
@@ -72,10 +72,18 @@ module YARD
0
# Ignore any initial comments or whitespace
0
- unless statement.empty? &&
[TkSPACE, TkNL, TkCOMMENT].include?(tk.class)
0
+ unless statement.empty? &&
stmt_number == 0 && [TkSPACE, TkNL, TkCOMMENT].include?(tk.class)
0
# Decrease if end or '}' is seen
0
level -= 1 if [TkEND, TkRBRACE].include?(tk.class)
0
+ # Increase level if we have a 'do' or block opening
0
+ if [TkLBRACE, TkDO, TkBEGIN].include?(tk.class)
0
+ #p "#{tk.line_no} #{level} #{tk} \t#{tk.text} #{tk.lex_state}"
0
# If the level is greater than 0, add the code to the block text
0
# otherwise it's part of the statement text
0
@@ -89,15 +97,6 @@ module YARD
0
#puts "#{tk.line_no} #{level} #{open_parens} #{tk.class.class_name} \t#{tk.text.inspect} #{tk.lex_state} #{open_block.inspect}"
0
- # Increase level if we have a 'do' or block opening
0
- if tk.class == TkLBRACE #|| tk.class == TkfLBRACE
0
- elsif [TkDO, TkBEGIN].include?(tk.class)
0
- #p "#{tk.line_no} #{level} #{tk} \t#{tk.text} #{tk.lex_state}"
0
- open_block = false # Cancel our wish to open a block for the if, we're doing it now
0
# Vouch to open a block when this statement would otherwise end
0
open_block = [level, tk.class] if (new_statement ||
0
(last_tk && last_tk.lex_state == EXPR_BEG)) &&
0
@@ -160,7 +159,11 @@ module YARD
0
# Return the code block with starting token and initial comments
0
# If there is no code in the block, return nil
0
comments = comments.compact if comments
0
- statement.empty? ? nil : Statement.new(statement, block, comments)
0
+ if block || !statement.empty?
0
+ Statement.new(statement, block, comments)
Comments
No one has commented yet.