Changed handleDiagnostic to take a format string and format args instead of the formatted string

This allows diagnostic consumers to modify the way formatting of diagnostics is performed.
rdar://problem/31305854
This commit is contained in:
Maxwell Swadling
2017-04-14 11:28:04 -07:00
parent 62d077d2d3
commit 93d485e4f7
18 changed files with 160 additions and 78 deletions

View File

@@ -43,9 +43,11 @@ using namespace SourceKit;
using namespace swift;
using namespace ide;
void EditorDiagConsumer::handleDiagnostic(SourceManager &SM, SourceLoc Loc,
DiagnosticKind Kind, StringRef Text,
const DiagnosticInfo &Info) {
void EditorDiagConsumer::handleDiagnostic(
SourceManager &SM, SourceLoc Loc, DiagnosticKind Kind,
StringRef FormatString, ArrayRef<DiagnosticArgument> FormatArgs,
const DiagnosticInfo &Info) {
if (Kind == DiagnosticKind::Error) {
HadAnyError = true;
}
@@ -68,7 +70,13 @@ void EditorDiagConsumer::handleDiagnostic(SourceManager &SM, SourceLoc Loc,
DiagnosticEntryInfo SKInfo;
SKInfo.Description = Text;
// Actually substitute the diagnostic arguments into the diagnostic text.
llvm::SmallString<256> Text;
{
llvm::raw_svector_ostream Out(Text);
DiagnosticEngine::formatDiagnosticText(Out, FormatString, FormatArgs);
}
SKInfo.Description = Text.str();
unsigned BufferID = SM.findBufferContainingLoc(Loc);