@@ -952,6 +952,7 @@ static void annotateSnippetWithInfo(SourceManager &SM,
952
952
}
953
953
}
954
954
955
+ #if SWIFT_SWIFT_PARSER
955
956
// / Enqueue a diagnostic with ASTGen's diagnostic rendering.
956
957
static void enqueueDiagnostic (
957
958
void *queuedDiagnostics, const DiagnosticInfo &info, SourceManager &SM
@@ -988,6 +989,7 @@ static void enqueueDiagnostic(
988
989
989
990
// FIXME: Need a way to add highlights, Fix-Its, and so on.
990
991
}
992
+ #endif
991
993
992
994
// MARK: Main DiagnosticConsumer entrypoint.
993
995
void PrintingDiagnosticConsumer::handleDiagnostic (SourceManager &SM,
@@ -1003,27 +1005,8 @@ void PrintingDiagnosticConsumer::handleDiagnostic(SourceManager &SM,
1003
1005
return ;
1004
1006
1005
1007
switch (FormattingStyle) {
1006
- case DiagnosticOptions::FormattingStyle::Swift:
1007
- if (Info.Kind == DiagnosticKind::Note && currentSnippet) {
1008
- // If this is a note and we have an in-flight message, add it to that
1009
- // instead of emitting it separately.
1010
- annotateSnippetWithInfo (SM, Info, *currentSnippet);
1011
- } else {
1012
- // If we encounter a new error/warning/remark, flush any in-flight
1013
- // snippets.
1014
- flush (/* includeTrailingBreak*/ true );
1015
- currentSnippet = std::make_unique<AnnotatedSourceSnippet>(SM);
1016
- annotateSnippetWithInfo (SM, Info, *currentSnippet);
1017
- }
1018
- if (PrintEducationalNotes) {
1019
- for (auto path : Info.EducationalNotePaths ) {
1020
- if (auto buffer = SM.getFileSystem ()->getBufferForFile (path))
1021
- BufferedEducationalNotes.push_back (buffer->get ()->getBuffer ().str ());
1022
- }
1023
- }
1024
- break ;
1025
-
1026
1008
case DiagnosticOptions::FormattingStyle::SwiftSyntax: {
1009
+ #if SWIFT_SWIFT_PARSER
1027
1010
if (Info.Loc .isValid ()) {
1028
1011
// Ignore "in macro expansion" diagnostics; we want to put them
1029
1012
// elsewhere.
@@ -1057,9 +1040,30 @@ void PrintingDiagnosticConsumer::handleDiagnostic(SourceManager &SM,
1057
1040
// Fall through to print using the LLVM style when there is no source
1058
1041
// location.
1059
1042
flush (/* includeTrailingBreak*/ false );
1043
+ #endif
1060
1044
LLVM_FALLTHROUGH;
1061
1045
}
1062
1046
1047
+ case DiagnosticOptions::FormattingStyle::Swift:
1048
+ if (Info.Kind == DiagnosticKind::Note && currentSnippet) {
1049
+ // If this is a note and we have an in-flight message, add it to that
1050
+ // instead of emitting it separately.
1051
+ annotateSnippetWithInfo (SM, Info, *currentSnippet);
1052
+ } else {
1053
+ // If we encounter a new error/warning/remark, flush any in-flight
1054
+ // snippets.
1055
+ flush (/* includeTrailingBreak*/ true );
1056
+ currentSnippet = std::make_unique<AnnotatedSourceSnippet>(SM);
1057
+ annotateSnippetWithInfo (SM, Info, *currentSnippet);
1058
+ }
1059
+ if (PrintEducationalNotes) {
1060
+ for (auto path : Info.EducationalNotePaths ) {
1061
+ if (auto buffer = SM.getFileSystem ()->getBufferForFile (path))
1062
+ BufferedEducationalNotes.push_back (buffer->get ()->getBuffer ().str ());
1063
+ }
1064
+ }
1065
+ break ;
1066
+
1063
1067
case DiagnosticOptions::FormattingStyle::LLVM:
1064
1068
printDiagnostic (SM, Info);
1065
1069
@@ -1095,6 +1099,7 @@ void PrintingDiagnosticConsumer::flush(bool includeTrailingBreak) {
1095
1099
currentSnippet.reset ();
1096
1100
}
1097
1101
1102
+ #if SWIFT_SWIFT_PARSER
1098
1103
if (queuedDiagnostics) {
1099
1104
Stream << " === " << queuedBufferName << " ===\n " ;
1100
1105
@@ -1113,6 +1118,7 @@ void PrintingDiagnosticConsumer::flush(bool includeTrailingBreak) {
1113
1118
if (includeTrailingBreak)
1114
1119
Stream << " \n " ;
1115
1120
}
1121
+ #endif
1116
1122
1117
1123
for (auto note : BufferedEducationalNotes) {
1118
1124
printMarkdown (note, Stream, ForceColors);
0 commit comments