mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
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:
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user