@@ -1804,65 +1804,60 @@ def parse_statements(container, single = NORMAL, current_method = nil,
18041804 non_comment_seen = true unless ( :on_comment == tk [ :kind ] or :on_embdoc == tk [ :kind ] )
18051805
18061806 case tk [ :kind ]
1807- when :on_nl , :on_ignored_nl , :on_comment , :on_embdoc then
1808- if :on_nl == tk [ :kind ] or :on_ignored_nl == tk [ :kind ]
1809- skip_tkspace
1810- tk = get_tk
1811- else
1812- past_tokens = @read . size > 1 ? @read [ 0 ..-2 ] : [ ]
1813- nl_position = 0
1814- past_tokens . reverse . each_with_index do |read_tk , i |
1815- if read_tk =~ /^\n $/ then
1816- nl_position = ( past_tokens . size - 1 ) - i
1817- break
1818- elsif read_tk =~ /^#.*\n $/ then
1819- nl_position = ( ( past_tokens . size - 1 ) - i ) + 1
1820- break
1821- end
1822- end
1823- comment_only_line = past_tokens [ nl_position ..-1 ] . all? { |c | c =~ /^\s +$/ }
1824- unless comment_only_line then
1825- tk = get_tk
1807+ when :on_nl , :on_ignored_nl then
1808+ skip_tkspace
1809+
1810+ keep_comment = true
1811+ container . current_line_visibility = nil
1812+
1813+ when :on_comment , :on_embdoc then
1814+ past_tokens = @read . size > 1 ? @read [ 0 ..-2 ] : [ ]
1815+ nl_position = 0
1816+ past_tokens . reverse . each_with_index do |read_tk , i |
1817+ if read_tk =~ /^\n $/ then
1818+ nl_position = ( past_tokens . size - 1 ) - i
1819+ break
1820+ elsif read_tk =~ /^#.*\n $/ then
1821+ nl_position = ( ( past_tokens . size - 1 ) - i ) + 1
1822+ break
18261823 end
18271824 end
1825+ comment_only_line = past_tokens [ nl_position ..-1 ] . all? { |c | c =~ /^\s +$/ }
1826+ unless comment_only_line then
1827+ tk = get_tk
1828+ end
18281829
1829- if tk and ( :on_comment == tk [ :kind ] or :on_embdoc == tk [ :kind ] ) then
1830- if non_comment_seen then
1831- # Look for RDoc in a comment about to be thrown away
1832- non_comment_seen = parse_comment container , tk , comment unless
1833- comment . empty?
1830+ if non_comment_seen then
1831+ # Look for RDoc in a comment about to be thrown away
1832+ non_comment_seen = parse_comment container , tk , comment unless
1833+ comment . empty?
18341834
1835- comment = ''
1836- comment = RDoc ::Encoding . change_encoding comment , @encoding if @encoding
1837- end
1835+ comment = ''
1836+ comment = RDoc ::Encoding . change_encoding comment , @encoding if @encoding
1837+ end
18381838
1839- line_no = nil
1840- while tk and ( :on_comment == tk [ :kind ] or :on_embdoc == tk [ :kind ] ) do
1841- comment_body = retrieve_comment_body ( tk )
1842- line_no = tk [ :line_no ] if comment . empty?
1843- comment += comment_body
1844- comment << "\n " unless comment_body =~ /\n \z /
1845-
1846- if comment_body . size > 1 && comment_body =~ /\n \z / then
1847- skip_tkspace_without_nl # leading spaces
1848- end
1849- tk = get_tk
1839+ line_no = nil
1840+ while tk and ( :on_comment == tk [ :kind ] or :on_embdoc == tk [ :kind ] ) do
1841+ comment_body = retrieve_comment_body ( tk )
1842+ line_no = tk [ :line_no ] if comment . empty?
1843+ comment += comment_body
1844+ comment << "\n " unless comment_body =~ /\n \z /
1845+
1846+ if comment_body . size > 1 && comment_body =~ /\n \z / then
1847+ skip_tkspace_without_nl # leading spaces
18501848 end
1849+ tk = get_tk
1850+ end
18511851
1852- comment = new_comment comment , line_no
1852+ comment = new_comment comment , line_no
18531853
1854- unless comment . empty? then
1855- look_for_directives_in container , comment
1854+ unless comment . empty? then
1855+ look_for_directives_in container , comment
18561856
1857- if container . done_documenting then
1858- throw :eof if RDoc ::TopLevel === container
1859- container . ongoing_visibility = save_visibility
1860- end
1857+ if container . done_documenting then
1858+ throw :eof if RDoc ::TopLevel === container
1859+ container . ongoing_visibility = save_visibility
18611860 end
1862-
1863- keep_comment = true
1864- else
1865- non_comment_seen = true
18661861 end
18671862
18681863 unget_tk tk
0 commit comments