Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions test/SourceKit/Diagnostics/remarks.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// RUN: env %sourcekitd-test -req=diags %s -- %s -Xfrontend -Rmodule-api-import | %FileCheck %s
public typealias Foo = String

// CHECK: {
// CHECK-NEXT: key.diagnostics: [
// CHECK-NEXT: {
// CHECK-NEXT: key.line: 2,
// CHECK-NEXT: key.column: 24,
// CHECK-NEXT: key.filepath: "{{.*}}",
// CHECK-NEXT: key.severity: source.diagnostic.severity.remark,
// CHECK-NEXT: key.id: "module_api_import",
// CHECK-NEXT: key.description: "struct 'String' is imported via 'Swift'"
// CHECK-NEXT: }
// CHECK-NEXT: ]
// CHECK-NEXT: }
3 changes: 2 additions & 1 deletion tools/SourceKit/include/SourceKit/Core/LangSupport.h
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,8 @@ struct FilterRule {

enum class DiagnosticSeverityKind {
Warning,
Error
Error,
Remark
};

enum class DiagnosticCategory {
Expand Down
12 changes: 3 additions & 9 deletions tools/SourceKit/lib/SwiftLang/SwiftEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,19 +147,12 @@ void EditorDiagConsumer::handleDiagnostic(SourceManager &SM,
if (Info.ID == diag::lex_editor_placeholder.ID ||
Info.ID == diag::oslog_invalid_log_message.ID)
return;

bool IsNote = (Info.Kind == DiagnosticKind::Note);

if (IsNote && !haveLastDiag())
// Is this possible?
return;

if (Info.Kind == DiagnosticKind::Remark) {
// FIXME: we may want to handle optimization remarks in sourcekitd.
LOG_WARN_FUNC("unhandled optimization remark");
return;
}

DiagnosticEntryInfo SKInfo;

SKInfo.ID = DiagnosticEngine::diagnosticIDStringFor(Info.ID).str();
Expand Down Expand Up @@ -237,16 +230,17 @@ void EditorDiagConsumer::handleDiagnostic(SourceManager &SM,
getLastDiag().Notes.push_back(std::move(SKInfo));
return;
}

switch (Info.Kind) {
case DiagnosticKind::Error:
SKInfo.Severity = DiagnosticSeverityKind::Error;
break;
case DiagnosticKind::Warning:
SKInfo.Severity = DiagnosticSeverityKind::Warning;
break;
case DiagnosticKind::Note:
case DiagnosticKind::Remark:
SKInfo.Severity = DiagnosticSeverityKind::Remark;
break;
case DiagnosticKind::Note:
llvm_unreachable("already covered");
}

Expand Down
4 changes: 4 additions & 0 deletions tools/SourceKit/tools/sourcekitd/lib/Service/Requests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4057,13 +4057,17 @@ fillDictionaryForDiagnosticInfo(ResponseBuilder::Dictionary Elem,
UIdent SeverityUID;
static UIdent UIDKindDiagWarning(KindDiagWarning.str());
static UIdent UIDKindDiagError(KindDiagError.str());
static UIdent UIDKindDiagRemark(KindDiagRemark.str());
switch (Info.Severity) {
case DiagnosticSeverityKind::Warning:
SeverityUID = UIDKindDiagWarning;
break;
case DiagnosticSeverityKind::Error:
SeverityUID = UIDKindDiagError;
break;
case DiagnosticSeverityKind::Remark:
SeverityUID = UIDKindDiagRemark;
break;
}

Elem.set(KeySeverity, SeverityUID);
Expand Down
1 change: 1 addition & 0 deletions utils/gyb_sourcekit_support/UIDs.py
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,7 @@ def __init__(self, internal_name, external_name):
KIND('DiagNote', 'source.diagnostic.severity.note'),
KIND('DiagWarning', 'source.diagnostic.severity.warning'),
KIND('DiagError', 'source.diagnostic.severity.error'),
KIND('DiagRemark', 'source.diagnostic.severity.remark'),
KIND('DiagDeprecation', 'source.diagnostic.category.deprecation'),
KIND('DiagNoUsage', 'source.diagnostic.category.no_usage'),
KIND('CodeCompletionEverything', 'source.codecompletion.everything'),
Expand Down