From d4b1a3c4fa3c06c32a8e9a5a9b635dbc232a33ea Mon Sep 17 00:00:00 2001 From: simonbrandhof Date: Wed, 27 Apr 2011 09:22:40 +0200 Subject: [PATCH] SONAR-2382 Highlight selected line in source panel --- .../WEB-INF/app/helpers/source_helper.rb | 41 +++++++++++-------- .../app/views/reviews/_review.html.erb | 6 ++- .../WEB-INF/app/views/source/_source.html.erb | 9 ++-- 3 files changed, 33 insertions(+), 23 deletions(-) diff --git a/sonar-server/src/main/webapp/WEB-INF/app/helpers/source_helper.rb b/sonar-server/src/main/webapp/WEB-INF/app/helpers/source_helper.rb index c6ed7856961..2d6ae9a3d14 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/helpers/source_helper.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/helpers/source_helper.rb @@ -44,13 +44,17 @@ module SourceHelper 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< - <% if review.rule_failure %> - + <% if review.rule_failure && review.resource_line && review.rule_failure.snapshot %> +
+ <%= snapshot_source_to_html(review.rule_failure.snapshot, {:line_range => (review.resource_line-5)..(review.resource_line+5), :highlighted_lines => [review.resource_line]}) -%> +
<% end %>
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/source/_source.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/source/_source.html.erb index fe339ed35d5..d146d350da2 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/source/_source.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/source/_source.html.erb @@ -9,7 +9,7 @@ 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 @@ -27,8 +27,11 @@ 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 @@ -63,7 +66,7 @@ <% end end %> - <%= index + 1 -%> + <%= line.id -%> -- 2.39.5