public
Description: PLEASE GO TO http://yard.soen.ca FOR IMPORTANT NEWS ABOUT YARD / THE AUTHOR!!!
Homepage: http://yard.soen.ca / IRC: #yard on irc.freenode.net
Clone URL: git://github.com/lsegal/yard.git
Search Repo:
Click here to lend your support to: yard and make a donation at www.pledgie.com !
Block parsing bug fixes and specs based on patch by Aman Gupta
lsegal (author)
Mon Jun 30 10:16:59 -0700 2008
commit  e75000c371855ba7476828792002d3fa4763930d
tree    ff727b7881c65a16243e769fff46615ab6e29224
parent  60d5695061b7e12e0b1ed47160e12dc56b8af4d6
...
72
73
74
75
 
76
77
78
 
 
 
 
 
 
 
 
79
80
81
...
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
...
160
161
162
163
 
 
 
 
 
164
165
166
...
72
73
74
 
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
...
97
98
99
 
 
 
 
 
 
 
 
 
100
101
102
...
159
160
161
 
162
163
164
165
166
167
168
169
0
@@ -72,10 +72,18 @@ module YARD
0
           end
0
                 
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
         
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
+ stmt_number += 1
0
+ new_statement = true
0
+ level += 1
0
+ end
0
+
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
             if stmt_number > 0
0
@@ -89,15 +97,6 @@ module YARD
0
 
0
             #puts "#{tk.line_no} #{level} #{open_parens} #{tk.class.class_name} \t#{tk.text.inspect} #{tk.lex_state} #{open_block.inspect}"
0
 
0
- # Increase level if we have a 'do' or block opening
0
- if tk.class == TkLBRACE #|| tk.class == TkfLBRACE
0
- level += 1
0
- elsif [TkDO, TkBEGIN].include?(tk.class)
0
- #p "#{tk.line_no} #{level} #{tk} \t#{tk.text} #{tk.lex_state}"
0
- level += 1
0
- open_block = false # Cancel our wish to open a block for the if, we're doing it now
0
- end
0
-
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)
0
+ else
0
+ nil
0
+ end
0
       end
0
     end
0
   end

Comments

    No one has commented yet.