Debian Codegraph @

src/FixItExporter.h

raw
1 /*
2 SPDX-FileCopyrightText: 2019 Christian Gagneraud <[email protected]>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6
7 #ifndef CLAZY_FIX_IT_EXPORTER_H
8 #define CLAZY_FIX_IT_EXPORTER_H
9
10 #include <clang/Basic/Diagnostic.h>
11 #include <clang/Tooling/Core/Diagnostic.h>
12
13 namespace clang
14 {
15 class FixItOptions;
16 }
17
18 class FixItExporter : public clang::DiagnosticConsumer
19 {
20 public:
21 explicit FixItExporter(clang::DiagnosticsEngine &DiagEngine,
22 clang::SourceManager &SourceMgr,
23 const clang::LangOptions &LangOpts,
24 const std::string &exportFixes,
25 bool isClazyStandalone);
26
27 ~FixItExporter() override;
28
29 bool IncludeInDiagnosticCounts() const override;
30
31 void BeginSourceFile(const clang::LangOptions &LangOpts, const clang::Preprocessor *PP = nullptr) override;
32
33 void EndSourceFile() override;
34
35 void HandleDiagnostic(clang::DiagnosticsEngine::Level DiagLevel, const clang::Diagnostic &Info) override;
36
37 void Export();
38
39 /// Emit a diagnostic via the adapted diagnostic client.
40 void Diag(clang::SourceLocation Loc, unsigned DiagID);
41
42 private:
43 clang::DiagnosticsEngine &DiagEngine;
44 clang::SourceManager &SourceMgr;
45 const clang::LangOptions &LangOpts;
46 const std::string exportFixes;
47 DiagnosticConsumer *Client = nullptr;
48 std::unique_ptr<DiagnosticConsumer> Owner;
49 bool m_recordNotes = false;
50 clang::tooling::Diagnostic ConvertDiagnostic(const clang::Diagnostic &Info);
51 clang::tooling::Replacement ConvertFixIt(const clang::FixItHint &Hint);
52 };
53
54 #endif // CLAZY_FIX_IT_EXPORTER_H