font-weight: normal;
}
-.highlightable {
- /*text-decoration: underline;*/
- /*color: #0000AA;*/
+.sym {
cursor: hand; cursor: pointer;
}
-.highlightable:hover {
+.sym:hover {
background-color: #ff8c00;
}
.highlighted {
- background-color: yellow;
+ background-color: #B3D4FF;
}
private static final String ENTITY_SEPARATOR = ";";
private static final String FIELD_SEPARATOR = ",";
- private static final String SYMBOL_PREFIX = "symbol-";
- private static final String HIGHLIGHTABLE = "highlightable";
+ private static final String SYMBOL_PREFIX = "sym-";
+ private static final String HIGHLIGHTABLE = "sym";
private List<TagEntry> openingTagsEntries;
private int openingTagsIndex;
assertThat(openingTagsEntries.get(1)).isEqualTo(new TagEntry(0, "cppd"));
assertThat(openingTagsEntries.get(2)).isEqualTo(new TagEntry(54, "a"));
assertThat(openingTagsEntries.get(3)).isEqualTo(new TagEntry(69, "k"));
- assertThat(openingTagsEntries.get(4)).isEqualTo(new TagEntry(80, "symbol-80 highlightable"));
- assertThat(openingTagsEntries.get(5)).isEqualTo(new TagEntry(90, "symbol-80 highlightable"));
+ assertThat(openingTagsEntries.get(4)).isEqualTo(new TagEntry(80, "sym-80 sym"));
+ assertThat(openingTagsEntries.get(5)).isEqualTo(new TagEntry(90, "sym-80 sym"));
assertThat(openingTagsEntries.get(6)).isEqualTo(new TagEntry(106, "cppd"));
assertThat(openingTagsEntries.get(7)).isEqualTo(new TagEntry(114, "k"));
- assertThat(openingTagsEntries.get(8)).isEqualTo(new TagEntry(140, "symbol-80 highlightable"));
+ assertThat(openingTagsEntries.get(8)).isEqualTo(new TagEntry(140, "sym-80 sym"));
}
@Test
" * Header",
" */",
"",
- "public class <span class=\"symbol-31 highlightable\">HelloWorld</span> {",
+ "public class <span class=\"sym-31 sym\">HelloWorld</span> {",
"}"
);
}
"<span class=\"cppd\"> * Header</span>",
"<span class=\"cppd\"> */</span>",
"",
- "<span class=\"k\">public </span><span class=\"k\">class </span><span class=\"symbol-31 highlightable\">HelloWorld</span> {",
- " <span class=\"k\">public</span> <span class=\"k\">void</span> <span class=\"symbol-58 highlightable\">foo</span>() {",
+ "<span class=\"k\">public </span><span class=\"k\">class </span><span class=\"sym-31 sym\">HelloWorld</span> {",
+ " <span class=\"k\">public</span> <span class=\"k\">void</span> <span class=\"sym-58 sym\">foo</span>() {",
" }",
- " <span class=\"k\">public</span> <span class=\"k\">void</span> <span class=\"symbol-84 highlightable\">bar</span>() {",
- " <span class=\"symbol-58 highlightable\">foo</span>();",
+ " <span class=\"k\">public</span> <span class=\"k\">void</span> <span class=\"sym-84 sym\">bar</span>() {",
+ " <span class=\"sym-58 sym\">foo</span>();",
" }",
"}"
);
if line
line.index = line_id
line.covered_lines = @testable ? @testable.countTestCasesOfLine(line_id) : 0
- puts "covered_lines for line #{line.index} has been set to #{line.covered_lines}"
line.hits = hits.to_i
line.conditions = @conditions_by_line[line_id].to_i
line.covered_conditions = @covered_conditions_by_line[line_id].to_i
to = (@period && @snapshot.period_datetime(@period) ? Java::JavaUtil::Date.new(@snapshot.period_datetime(@period).to_f * 1000) : nil)
@filtered = true
- puts "coverage filter is #{@coverage_filter}"
if ('lines_to_cover'==@coverage_filter || 'coverage'==@coverage_filter || 'line_coverage'==@coverage_filter ||
'new_lines_to_cover'==@coverage_filter || 'new_coverage'==@coverage_filter || 'new_line_coverage'==@coverage_filter ||
'it_lines_to_cover'==@coverage_filter || 'it_coverage'==@coverage_filter || 'it_line_coverage'==@coverage_filter ||
'overall_lines_to_cover'==@coverage_filter || 'overall_coverage'==@coverage_filter || 'overall_line_coverage'==@coverage_filter ||
'new_overall_lines_to_cover'==@coverage_filter || 'new_overall_coverage'==@coverage_filter || 'new_overall_line_coverage'==@coverage_filter)
@coverage_filter = "#{it_prefix}lines_to_cover"
- filtered_lines = filter_lines { |line| line.hits && line.after(to) }
- puts "filtered lines length : #{filtered_lines.length}"
- filtered_lines
+ filter_lines { |line| line.hits && line.after(to) }
elsif ('uncovered_lines'==@coverage_filter || 'new_uncovered_lines'==@coverage_filter ||
'it_uncovered_lines'==@coverage_filter || 'new_it_uncovered_lines'==@coverage_filter ||
html
end
-
- def prepare_colspans(display_violation_form, scm_available, display_coverage)
-
- colspan=2
- gray_colspan=1
- white_colspan=0
- if display_violation_form
- colspan+=1
- gray_colspan+=1
- end
- if scm_available
- colspan+=1
- gray_colspan+=1
- end
- if display_coverage
- colspan+=2
- white_colspan+=2
- end
-
- {:base => colspan, :gray => gray_colspan, :white => white_colspan}
- end
-
-
- def compute_statuses(line, display_coverage, display_violations)
-
- status=hits_status=conditions_status=''
-
- if line.displayed?
- if display_coverage && line.hits
- hits_status=(line.hits>0 ? 'ok' : 'ko')
- if line.conditions && line.conditions>0 && line.covered_conditions
- if line.covered_conditions==0
- status='ko'
- conditions_status='ko'
- elsif line.covered_conditions==line.conditions
- status=''
- conditions_status='ok'
- else
- conditions_status='warn'
- status='warn'
- end
- elsif line.hits
- status=(line.hits>0 ? '' : 'ko')
- end
- elsif display_violations && line.violations?
- status="ko"
- end
- end
-
- {:base => status, :hits => hits_status, :conditions => conditions_status}
- end
-
def to_date(java_date)
java_date ? Time.at(java_date.time/1000) : nil
end
# - line_range : range (default is complete lines range)
# - highlighted_lines : range (default is complete lines range)
#
- def snapshot_source_to_html(snapshot, options={})
+ def snapshot_html_source(snapshot, options={})
panel = get_html_source_panel(snapshot, options)
- unless panel.nil?
+ if panel
panel.filter_min_date(options[:min_date]) if options[:min_date]
unless panel.empty?
panel.html_lines=[]
html_source_lines = snapshot.highlighting_data || snapshot.source.syntax_highlighted_lines()
line_range=sanitize_range(options[:line_range], 1..html_source_lines.length)
- highlighted_lines=sanitize_range(options[:highlighted_lines], 1..html_source_lines.length)
html_source_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.displayed=highlighted_lines.include?(index+1)
+ if options[:highlighted_lines]
+ html_line.displayed=options[:highlighted_lines].include?(index+1)
+ end
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
class HtmlLine
- attr_accessor :index, :source, :revision, :author, :datetime, :violations, :issues, :hits, :conditions,
+ attr_accessor :id, :index, :source, :revision, :author, :datetime, :violations, :issues, :hits, :conditions,
:covered_conditions, :hidden, :displayed, :deprecated_conditions_label, :covered_lines
- def initialize(source, index)
+ def initialize(source, id)
@source=source
- @index=index
+ @id=id
end
def add_violation(violation)
def flag_as_displayed
@displayed=true
@hidden=false
- puts "line #{index} will be displayed"
end
def flag_as_displayed_context
- # do not force if selected has already been set to true
+ # do not force if displayed has already been set to true
@displayed=false if @displayed.nil?
@hidden=false
- puts "line #{index} will be displayed as context"
end
def flag_as_hidden
if @hidden.nil?
@hidden=true
@displayed=false
- puts "line #{index} will be hidden"
end
end
end
def displayed?
- # selected if the @selected has not been set or has been set to true
+ # displayed if the @displayed has not been set or has been set to true
!hidden? && @displayed!=false
end
<% if review.rule_failure && review.resource_line && review.rule_failure.snapshot && has_role?(:codeviewer, review.project) %>
<div class="marginbottom10">
- <%= snapshot_source_to_html(review.rule_failure.snapshot, {:line_range => (review.resource_line-5)..(review.resource_line+5), :highlighted_lines => [review.resource_line]}) -%>
+ <%= snapshot_html_source(review.rule_failure.snapshot, {:line_range => (review.resource_line-5)..(review.resource_line+5), :highlighted_lines => [review.resource_line]}) -%>
</div>
<% end %>
</p>
<% end %>
- <%= snapshot_source_to_html(resource.last_snapshot, {:line_range => from_line..to_line}) -%>
+ <%= snapshot_html_source(resource.last_snapshot, {:line_range => from_line..to_line}) -%>
<% if lines_count > ResourceHelper::DUPLICATION_SNIPPET_DEFAULT_NB_OF_LINES %>
<p class="small">
<% if line.displayed? && line.covered_lines %>
- <% puts "displaying coverage info #{line.covered_lines} for line #{line.index}" %>
<td class="ind <%= statuses[:hits] -%>" title="<%= message('coverage_viewer.line_covered_by_x_tests', {:params => line.covered_lines.to_s}) if line.covered_lines > 0 -%>">
<% if line.covered_lines > 0 %>
<a href="<%= ApplicationController.root_context -%>/test/testable/<%= h resource_key -%>?line=<%= index+1 -%>"
<table id="<%= current_display_id %>" class="sources2 code" cellpadding="0" cellspacing="0" border="0">
<script>
- $j("#<%= current_display_id %>").on("click", "span[class|='symbol']", {id: "<%= current_display_id.to_s() %>"}, highlight_usages);
+ $j("#<%= current_display_id %>").on("click", "span.sym", {id: "<%= current_display_id.to_s() %>"}, highlight_usages);
</script>
<%
<% end %>
- <%= render :partial => "shared/source_line_numbers", :locals => {:index => line.index} %>
+ <%= render :partial => "shared/source_line_numbers", :locals => {:index => line.id} %>
<% if display_coverage %>
<%= render :partial => "shared/source_coverage", :locals => {:line => line, \