Skip to content

Commit 57062d8

Browse files
authored
Merge pull request #84031 from owenv/owenv/sourcekit-remarks
2 parents a6ec4a9 + 593346a commit 57062d8

File tree

5 files changed

+25
-10
lines changed

5 files changed

+25
-10
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// RUN: env %sourcekitd-test -req=diags %s -- %s -Xfrontend -Rmodule-api-import | %FileCheck %s
2+
public typealias Foo = String
3+
4+
// CHECK: {
5+
// CHECK-NEXT: key.diagnostics: [
6+
// CHECK-NEXT: {
7+
// CHECK-NEXT: key.line: 2,
8+
// CHECK-NEXT: key.column: 24,
9+
// CHECK-NEXT: key.filepath: "{{.*}}",
10+
// CHECK-NEXT: key.severity: source.diagnostic.severity.remark,
11+
// CHECK-NEXT: key.id: "module_api_import",
12+
// CHECK-NEXT: key.description: "struct 'String' is imported via 'Swift'"
13+
// CHECK-NEXT: }
14+
// CHECK-NEXT: ]
15+
// CHECK-NEXT: }

tools/SourceKit/include/SourceKit/Core/LangSupport.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,8 @@ struct FilterRule {
213213

214214
enum class DiagnosticSeverityKind {
215215
Warning,
216-
Error
216+
Error,
217+
Remark
217218
};
218219

219220
enum class DiagnosticCategory {

tools/SourceKit/lib/SwiftLang/SwiftEditor.cpp

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -147,19 +147,12 @@ void EditorDiagConsumer::handleDiagnostic(SourceManager &SM,
147147
if (Info.ID == diag::lex_editor_placeholder.ID ||
148148
Info.ID == diag::oslog_invalid_log_message.ID)
149149
return;
150-
151150
bool IsNote = (Info.Kind == DiagnosticKind::Note);
152151

153152
if (IsNote && !haveLastDiag())
154153
// Is this possible?
155154
return;
156155

157-
if (Info.Kind == DiagnosticKind::Remark) {
158-
// FIXME: we may want to handle optimization remarks in sourcekitd.
159-
LOG_WARN_FUNC("unhandled optimization remark");
160-
return;
161-
}
162-
163156
DiagnosticEntryInfo SKInfo;
164157

165158
SKInfo.ID = DiagnosticEngine::diagnosticIDStringFor(Info.ID).str();
@@ -237,16 +230,17 @@ void EditorDiagConsumer::handleDiagnostic(SourceManager &SM,
237230
getLastDiag().Notes.push_back(std::move(SKInfo));
238231
return;
239232
}
240-
241233
switch (Info.Kind) {
242234
case DiagnosticKind::Error:
243235
SKInfo.Severity = DiagnosticSeverityKind::Error;
244236
break;
245237
case DiagnosticKind::Warning:
246238
SKInfo.Severity = DiagnosticSeverityKind::Warning;
247239
break;
248-
case DiagnosticKind::Note:
249240
case DiagnosticKind::Remark:
241+
SKInfo.Severity = DiagnosticSeverityKind::Remark;
242+
break;
243+
case DiagnosticKind::Note:
250244
llvm_unreachable("already covered");
251245
}
252246

tools/SourceKit/tools/sourcekitd/lib/Service/Requests.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4057,13 +4057,17 @@ fillDictionaryForDiagnosticInfo(ResponseBuilder::Dictionary Elem,
40574057
UIdent SeverityUID;
40584058
static UIdent UIDKindDiagWarning(KindDiagWarning.str());
40594059
static UIdent UIDKindDiagError(KindDiagError.str());
4060+
static UIdent UIDKindDiagRemark(KindDiagRemark.str());
40604061
switch (Info.Severity) {
40614062
case DiagnosticSeverityKind::Warning:
40624063
SeverityUID = UIDKindDiagWarning;
40634064
break;
40644065
case DiagnosticSeverityKind::Error:
40654066
SeverityUID = UIDKindDiagError;
40664067
break;
4068+
case DiagnosticSeverityKind::Remark:
4069+
SeverityUID = UIDKindDiagRemark;
4070+
break;
40674071
}
40684072

40694073
Elem.set(KeySeverity, SeverityUID);

utils/gyb_sourcekit_support/UIDs.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,7 @@ def __init__(self, internal_name, external_name):
477477
KIND('DiagNote', 'source.diagnostic.severity.note'),
478478
KIND('DiagWarning', 'source.diagnostic.severity.warning'),
479479
KIND('DiagError', 'source.diagnostic.severity.error'),
480+
KIND('DiagRemark', 'source.diagnostic.severity.remark'),
480481
KIND('DiagDeprecation', 'source.diagnostic.category.deprecation'),
481482
KIND('DiagNoUsage', 'source.diagnostic.category.no_usage'),
482483
KIND('CodeCompletionEverything', 'source.codecompletion.everything'),

0 commit comments

Comments
 (0)