*/
public class HtmlTextWrapper {
- private static final String OPEN_TABLE_LINE = "<tr><td>";
- private static final String CLOSE_TABLE_LINE = "</td></tr>";
-
public static final char CR_END_OF_LINE = '\r';
public static final char LF_END_OF_LINE = '\n';
if (shouldStartNewLine(charsReader)) {
decoratedHtmlLines.add(currentHtmlLine.toString());
currentHtmlLine = new StringBuilder();
-// currentHtmlLine.append(OPEN_TABLE_LINE);
if (shouldReopenPendingTags(charsReader)) {
reopenCurrentSyntaxTags(charsReader, currentHtmlLine);
}
if (shouldClosePendingTags(charsReader)) {
closeCurrentSyntaxTags(charsReader, currentHtmlLine);
-// currentHtmlLine.append(CLOSE_TABLE_LINE);
}
Collection<String> tagsToOpen = getTagsToOpen(charsReader.getCurrentIndex(), context);
String snapshotSource = snapshotSourceDao.selectSnapshotSource(snapshotId);
String highlightingRules = snapshotDataDao.selectSnapshotData(snapshotId);
- HighlightingContext highlightingContext = HighlightingContext.buildFrom(highlightingRules);
-
- HtmlTextWrapper textWrapper = new HtmlTextWrapper();
-
- return textWrapper.wrapTextWithHtml(snapshotSource, highlightingContext);
+ if(snapshotSource != null && highlightingRules != null) {
+ HighlightingContext highlightingContext = HighlightingContext.buildFrom(highlightingRules);
+ HtmlTextWrapper textWrapper = new HtmlTextWrapper();
+ return textWrapper.wrapTextWithHtml(snapshotSource, highlightingContext);
+ }
+ return null;
}
}
return false;
}
});
- return conflictingRules.size() > 0;
+ return !conflictingRules.isEmpty();
}
}
@expanded=(params[:expand]=='true')
@display_manual_violation_form=(current_user && has_role?(:user, @snapshot))
if @snapshot.source
- source_lines=@snapshot.source.syntax_highlighted_lines()
+ source_lines = @snapshot.highlighting_data || @snapshot.source.syntax_highlighted_lines()
init_scm()
@lines=[]
panel.html_lines=[]
line_range=sanitize_line_range(options[:line_range])
highlighted_lines=options[:highlighted_lines]||[]
- snapshot.source.syntax_highlighted_lines().each_with_index do |source, index|
+ source_lines = snapshot.highlighting_data || snapshot.source.syntax_highlighted_lines()
+ 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]
end
end
+ def highlighting_data
+ Java::OrgSonarServerUi::JRubyFacade.getInstance().getHighlightedSourceLines(id)
+ end
+
private