@@ -26,25 +26,34 @@ struct SwiftDiagnosticsLocation {
2626 unsigned endColumn;
2727
2828 nlohmann::json json () const ;
29-
3029 std::string str () const ;
3130};
3231
3332// Models a diagnostic source for Swift, holding static information that goes out into a diagnostic
3433// These are internally stored into a map on id's. A specific error log can use binlog's category
3534// as id, which will then be used to recover the diagnostic source while dumping.
3635struct SwiftDiagnostic {
36+ enum class Visibility : unsigned char {
37+ none = 0b000 ,
38+ statusPage = 0b001 ,
39+ cliSummaryTable = 0b010 ,
40+ telemetry = 0b100 ,
41+ all = 0b111 ,
42+ };
43+
3744 std::string_view id;
3845 std::string_view name;
3946 static constexpr std::string_view extractorName = " swift" ;
4047 std::string_view action;
4148 // space separated if more than 1. Not a vector to allow constexpr
4249 // TODO(C++20) with vector going constexpr this can be turned to `std::vector<std::string_view>`
4350 std::string_view helpLinks;
44-
45- std::optional<SwiftDiagnosticsLocation> location;
4651 // for the moment, we only output errors, so no need to store the severity
4752
53+ Visibility visibility{Visibility::all};
54+
55+ std::optional<SwiftDiagnosticsLocation> location{};
56+
4857 // create a JSON diagnostics for this source with the given timestamp and message to out
4958 // A plaintextMessage is used that includes both the message and the action to take. Dots are
5059 // appended to both. The id is used to construct the source id in the form
@@ -64,8 +73,23 @@ struct SwiftDiagnostic {
6473 ret.location = SwiftDiagnosticsLocation{file, startLine, startColumn, endLine, endColumn};
6574 return ret;
6675 }
76+
77+ private:
78+ bool has (Visibility v) const ;
6779};
6880
81+ inline constexpr SwiftDiagnostic::Visibility operator |(SwiftDiagnostic::Visibility lhs,
82+ SwiftDiagnostic::Visibility rhs) {
83+ return static_cast <SwiftDiagnostic::Visibility>(static_cast <unsigned char >(lhs) |
84+ static_cast <unsigned char >(rhs));
85+ }
86+
87+ inline constexpr SwiftDiagnostic::Visibility operator &(SwiftDiagnostic::Visibility lhs,
88+ SwiftDiagnostic::Visibility rhs) {
89+ return static_cast <SwiftDiagnostic::Visibility>(static_cast <unsigned char >(lhs) &
90+ static_cast <unsigned char >(rhs));
91+ }
92+
6993constexpr SwiftDiagnostic internalError{
7094 " internal-error" ,
7195 " Internal error" ,
0 commit comments