class Rcov::FileStatistics
def prev_expr_continued?(lineno)
def prev_expr_continued?(lineno) return false if lineno <= 0 return false if lineno >= @lines.size found = false if @multiline_string_start[lineno] && @multiline_string_start[lineno] < lineno return true end # find index of previous code line idx = (lineno-1).downto(0) do |i| if @heredoc_start[i] found = true break @heredoc_start[i] end next unless is_code? i found = true break i end return false unless found #TODO: write a comprehensive list if is_code?(lineno) && /^\s*((\)|\]|\})\s*)+(?:#.*)?$/.match(@lines[lineno]) return true end #FIXME: / matches regexps too # the following regexp tries to reject #{interpolation} r = /(,|\.|\+|-|\*|\/|<|>|%|&&|\|\||<<|\(|\[|\{|=|and|or|\\)\s*(?:#(?![{$@]).*)?$/.match @lines[idx] # try to see if a multi-line expression with opening, closing delimiters # started on that line [%w!( )!].each do |opening_str, closing_str| # conservative: only consider nesting levels opened in that line, not # previous ones too. # next regexp considers interpolation too line = @lines[idx].gsub(/#(?![{$@]).*$/, "") opened = line.scan(/#{Regexp.escape(opening_str)}/).size closed = line.scan(/#{Regexp.escape(closing_str)}/).size return true if opened - closed > 0 end if /(do|\{)\s*\|[^|]*\|\s*(?:#.*)?$/.match @lines[idx] return false end r end