@@ -26,25 +26,34 @@ struct SwiftDiagnosticsLocation {
26
26
unsigned endColumn;
27
27
28
28
nlohmann::json json () const ;
29
-
30
29
std::string str () const ;
31
30
};
32
31
33
32
// Models a diagnostic source for Swift, holding static information that goes out into a diagnostic
34
33
// These are internally stored into a map on id's. A specific error log can use binlog's category
35
34
// as id, which will then be used to recover the diagnostic source while dumping.
36
35
struct SwiftDiagnostic {
36
+ enum class Visibility : unsigned char {
37
+ none = 0b000 ,
38
+ statusPage = 0b001 ,
39
+ cliSummaryTable = 0b010 ,
40
+ telemetry = 0b100 ,
41
+ all = 0b111 ,
42
+ };
43
+
37
44
std::string_view id;
38
45
std::string_view name;
39
46
static constexpr std::string_view extractorName = " swift" ;
40
47
std::string_view action;
41
48
// space separated if more than 1. Not a vector to allow constexpr
42
49
// TODO(C++20) with vector going constexpr this can be turned to `std::vector<std::string_view>`
43
50
std::string_view helpLinks;
44
-
45
- std::optional<SwiftDiagnosticsLocation> location;
46
51
// for the moment, we only output errors, so no need to store the severity
47
52
53
+ Visibility visibility{Visibility::all};
54
+
55
+ std::optional<SwiftDiagnosticsLocation> location{};
56
+
48
57
// create a JSON diagnostics for this source with the given timestamp and message to out
49
58
// A plaintextMessage is used that includes both the message and the action to take. Dots are
50
59
// appended to both. The id is used to construct the source id in the form
@@ -64,8 +73,23 @@ struct SwiftDiagnostic {
64
73
ret.location = SwiftDiagnosticsLocation{file, startLine, startColumn, endLine, endColumn};
65
74
return ret;
66
75
}
76
+
77
+ private:
78
+ bool has (Visibility v) const ;
67
79
};
68
80
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
+
69
93
constexpr SwiftDiagnostic internalError{
70
94
" internal-error" ,
71
95
" Internal error" ,
0 commit comments