panel.html_lines=[]
line_range=sanitize_line_range(options[:line_range])
- snapshot.source.syntax_highlighted_lines()[line_range].each_with_index do |source, index|
- html_line=HtmlLine.new(source)
- html_line.revision=revisions_by_line[index+1]
- html_line.author=authors_by_line[index+1]
- date_string=dates_by_line[index+1]
- html_line.datetime=(date_string ? Java::OrgSonarApiUtils::DateUtils.parseDateTime(date_string): nil)
- panel.html_lines<<html_line
+ highlighted_lines=options[:highlighted_lines]||[]
+ snapshot.source.syntax_highlighted_lines().each_with_index do |source, index|
+ if line_range.include?(index+1)
+ html_line=HtmlLine.new(source, index+1)
+ html_line.revision=revisions_by_line[index+1]
+ html_line.author=authors_by_line[index+1]
+ html_line.highlighted=(highlighted_lines.include?(index+1))
+ date_string=dates_by_line[index+1]
+ html_line.datetime=(date_string ? Java::OrgSonarApiUtils::DateUtils.parseDateTime(date_string): nil)
+ panel.html_lines<<html_line
+ end
end
panel.filter_min_date(options[:min_date]) if options[:min_date]
end
class HtmlLine
- attr_accessor :source, :revision, :author, :datetime, :violations, :hits, :conditions, :covered_conditions, :hidden, :highlighted, :deprecated_conditions_label
+ attr_accessor :id, :source, :revision, :author, :datetime, :violations, :hits, :conditions, :covered_conditions, :hidden, :selected, :highlighted, :deprecated_conditions_label
- def initialize(source)
+ def initialize(source, id)
@source=source
+ @id=id
end
def add_violation(violation)
end
end
- def flag_as_highlighted
- @highlighted=true
+ def flag_as_selected
+ @selected=true
@hidden=false
end
- def flag_as_highlight_context
- # do not force if highlighted has already been set to true
- @highlighted=false if @highlighted.nil?
+ def flag_as_selected_context
+ # do not force if selected has already been set to true
+ @selected=false if @selected.nil?
@hidden=false
end
# do not force if it has already been flagged as visible
if @hidden.nil?
@hidden=true
- @highlighted=false
+ @selected=false
end
end
@hidden==true
end
- def highlighted?
- # highlighted if the @highlighted has not been set or has been set to true
- !hidden? && @highlighted!=false
+ def selected?
+ # selected if the @selected has not been set or has been set to true
+ !hidden? && @selected!=false
end
def deprecated_conditions_label=(label)
previous_hidden=false
first_section=true
has_displayed_lines=false
- panel.html_lines.each_with_index do |line, index|
+ panel.html_lines.each do |line|
if line.hidden? && panel.expanded
previous_hidden=true
next
first_section=false
status=hits_status=conditions_status=''
- if line.highlighted?
+ if line.selected?
has_displayed_lines=true
+ if line.highlighted
+ status='ko'
+ end
# if @display_coverage && line.hits
# hits_status=(line.hits>0 ? 'ok' : 'ko')
# if line.conditions && line.conditions>0 && line.covered_conditions
<% end
end
%>
- <td class="lid <%= ' section' if line.violations? -%>" id="L<%= index+1 -%>"><a name="L<%= index+1 -%>" href="#L<%= index+1 -%>"><%= index + 1 -%></a></td>
+ <td class="lid <%= ' section' if line.violations? -%>" id="L<%= line.id -%>"><a name="L<%= line.id -%>" href="#L<%= line.id -%>"><%= line.id -%></a></td>
<td class="line <%= status -%>">