1919namespace codeql {
2020
2121extern const std::string_view programName;
22+ extern const std::string_view extractorName;
2223
23- struct SwiftDiagnosticsLocation {
24+ struct DiagnosticsLocation {
2425 std::string_view file;
2526 unsigned startLine;
2627 unsigned startColumn;
@@ -34,7 +35,8 @@ struct SwiftDiagnosticsLocation {
3435// Models a diagnostic source for Swift, holding static information that goes out into a diagnostic
3536// These are internally stored into a map on id's. A specific error log can use binlog's category
3637// as id, which will then be used to recover the diagnostic source while dumping.
37- struct SwiftDiagnostic {
38+ class Diagnostic {
39+ public:
3840 enum class Visibility : unsigned char {
3941 none = 0b000 ,
4042 statusPage = 0b001 ,
@@ -51,16 +53,14 @@ struct SwiftDiagnostic {
5153 error,
5254 };
5355
54- static constexpr std::string_view extractorName = " swift" ;
55-
5656 std::string_view id;
5757 std::string_view name;
5858 std::string_view action;
5959
6060 Visibility visibility{Visibility::all};
6161 Severity severity{Severity::error};
6262
63- std::optional<SwiftDiagnosticsLocation > location{};
63+ std::optional<DiagnosticsLocation > location{};
6464
6565 // create a JSON diagnostics for this source with the given `timestamp` and Markdown `message`
6666 // A markdownMessage is emitted that includes both the message and the action to take. The id is
@@ -71,33 +71,33 @@ struct SwiftDiagnostic {
7171 // returns <id> or <id>@<location> if a location is present
7272 std::string abbreviation () const ;
7373
74- SwiftDiagnostic withLocation (std::string_view file,
75- unsigned startLine = 0 ,
76- unsigned startColumn = 0 ,
77- unsigned endLine = 0 ,
78- unsigned endColumn = 0 ) const {
74+ Diagnostic withLocation (std::string_view file,
75+ unsigned startLine = 0 ,
76+ unsigned startColumn = 0 ,
77+ unsigned endLine = 0 ,
78+ unsigned endColumn = 0 ) const {
7979 auto ret = *this ;
80- ret.location = SwiftDiagnosticsLocation {file, startLine, startColumn, endLine, endColumn};
80+ ret.location = DiagnosticsLocation {file, startLine, startColumn, endLine, endColumn};
8181 return ret;
8282 }
8383
8484 private:
8585 bool has (Visibility v) const ;
8686};
8787
88- inline constexpr SwiftDiagnostic ::Visibility operator |(SwiftDiagnostic ::Visibility lhs,
89- SwiftDiagnostic ::Visibility rhs) {
90- return static_cast <SwiftDiagnostic ::Visibility>(static_cast <unsigned char >(lhs) |
91- static_cast <unsigned char >(rhs));
88+ inline constexpr Diagnostic ::Visibility operator |(Diagnostic ::Visibility lhs,
89+ Diagnostic ::Visibility rhs) {
90+ return static_cast <Diagnostic ::Visibility>(static_cast <unsigned char >(lhs) |
91+ static_cast <unsigned char >(rhs));
9292}
9393
94- inline constexpr SwiftDiagnostic ::Visibility operator &(SwiftDiagnostic ::Visibility lhs,
95- SwiftDiagnostic ::Visibility rhs) {
96- return static_cast <SwiftDiagnostic ::Visibility>(static_cast <unsigned char >(lhs) &
97- static_cast <unsigned char >(rhs));
94+ inline constexpr Diagnostic ::Visibility operator &(Diagnostic ::Visibility lhs,
95+ Diagnostic ::Visibility rhs) {
96+ return static_cast <Diagnostic ::Visibility>(static_cast <unsigned char >(lhs) &
97+ static_cast <unsigned char >(rhs));
9898}
9999
100- constexpr SwiftDiagnostic internalError{
100+ constexpr Diagnostic internalError{
101101 .id = " internal-error" ,
102102 .name = " Internal error" ,
103103 .action =
@@ -107,6 +107,5 @@ constexpr SwiftDiagnostic internalError{
107107 " happened, or [open an issue in our open source repository][1].\n "
108108 " \n "
109109 " [1]: https://github.com/github/codeql/issues/new?labels=bug&template=ql---general.md" ,
110- .severity = SwiftDiagnostic::Severity::warning,
111- };
110+ .severity = Diagnostic::Severity::warning};
112111} // namespace codeql
0 commit comments