}
private void highlightLines( File toHighlight, List<RuleFailure> failuresForFile, List<File> snapshotFiles ) {
StringBuffer highlightedSource = new StringBuffer( 32768 );
Set<Integer> highlightedLines = new HashSet<Integer>();
FileSource fileSource = toHighlight.getFileSource();
String[] lines = fileSource.getSource().split( "\\n" );
for (String line1 : lines) {
String line = line1.trim();
if ( line.length() == 0 ) continue;
Matcher sourceLineMatcher = getSourceLineMatcher( line );
if ( sourceLineMatcher.find() ) {
int lineNumber = Integer.parseInt( sourceLineMatcher.group( 1 ) );
int sourceCodeStart = sourceLineMatcher.end( 0 );
List<RuleFailure> failuresForGivenLine = getFailuresForGivenLine( toHighlight, failuresForFile, lineNumber );
if ( failuresForGivenLine.size() > 0 ) {
line = highlightLine( toHighlight, failuresForGivenLine, line, sourceCodeStart, lineNumber );
highlightedLines.add( lineNumber );
}
line = replaceLineHrefs( snapshotFiles, line );
}
highlightedSource.append( line ).append( "\n" );
}
fileSource.setSource( highlightedSource.toString() );
if ( highlightedLines.size() > 0 ) {
addTooltipActivators( fileSource, highlightedLines );
}
}