diff options
author | Ted Kremenek <kremenek@apple.com> | 2008-04-17 18:37:23 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2008-04-17 18:37:23 +0000 |
commit | b7478148953ba8925e64e6f4b5b35442969e8377 (patch) | |
tree | bad3030dcf63e8c6e0d449c6300bb59633a8c704 /Driver/HTMLDiagnostics.cpp | |
parent | 3dd4ba4068e953125b95ce85c723322cdd0a3cb5 (diff) |
HAve HTMLDiagnostics use html::HighlightRange to highlight message ranges.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@49863 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'Driver/HTMLDiagnostics.cpp')
-rw-r--r-- | Driver/HTMLDiagnostics.cpp | 70 |
1 files changed, 6 insertions, 64 deletions
diff --git a/Driver/HTMLDiagnostics.cpp b/Driver/HTMLDiagnostics.cpp index b49586f223..9b7d4f5dac 100644 --- a/Driver/HTMLDiagnostics.cpp +++ b/Driver/HTMLDiagnostics.cpp @@ -329,69 +329,11 @@ void HTMLDiagnostics::HighlightRange(Rewriter& R, SourceRange Range) { // Highlight the range. Make the span tag the outermost tag for the // selected range. - - SourceLocation E = - LogicalEnd.getFileLocWithOffset(OldEndColNo > EndColNo - ? -(OldEndColNo - EndColNo) - : EndColNo - OldEndColNo); - - R.InsertCStrBefore(LogicalStart, "<span class=\"mrange\">"); - R.InsertCStrAfter(E, "</span>"); - - if (EndLineNo == StartLineNo) - return; - - // Add in </span><span> tags for intermediate lines. - - unsigned FileID = SM.getCanonicalFileID(LogicalStart); - const llvm::MemoryBuffer *Buf = R.getSourceMgr().getBuffer(FileID); - - unsigned Pos = SM.getFullFilePos(LogicalStart); - unsigned EndPos = SM.getFullFilePos(E); - const char* buf = Buf->getBufferStart(); - - for (; Pos != EndPos; ++Pos) { - SourceLocation L = SourceLocation::getFileLoc(FileID, Pos); - unsigned Col = SM.getColumnNumber(L); - - if (Col == 1) { - - // Start if a new line. Scan to see if we hit anything that is not - // whitespace or a newline. - - unsigned PosTmp = Pos; - bool NewLine = false; - - for ( ; PosTmp != EndPos ; ++PosTmp) { - switch (buf[PosTmp]) { - case ' ': - case '\t': continue; - case '\n': - NewLine = true; - break; - default: - break; - } - - break; - } - - if (PosTmp == EndPos) - break; - - Pos = PosTmp; - - // Don't highlight a blank line. - if (NewLine) - continue; - - // This line contains text that we should highlight. - // Ignore leading whitespace. - L = SourceLocation::getFileLoc(FileID, Pos); - R.InsertCStrAfter(L, "<span class=\"mrange\">"); - } - else if (buf[Pos] == '\n') - R.InsertCStrBefore(L, "</span>"); - } + SourceLocation E = LogicalEnd.getFileLocWithOffset(OldEndColNo > EndColNo + ? -(OldEndColNo - EndColNo) + : EndColNo - OldEndColNo); + + html::HighlightRange(R, LogicalStart, E, + "<span class=\"mrange\">", "</span>"); } |