Go to the documentation of this file.
9 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_DIAGNOSTICS_H
10 #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_DIAGNOSTICS_H
14 #include "clang/Basic/Diagnostic.h"
15 #include "clang/Basic/LangOptions.h"
16 #include "clang/Basic/SourceLocation.h"
17 #include "llvm/ADT/ArrayRef.h"
18 #include "llvm/ADT/DenseSet.h"
19 #include "llvm/ADT/None.h"
20 #include "llvm/ADT/Optional.h"
21 #include "llvm/ADT/STLExtras.h"
22 #include "llvm/ADT/StringSet.h"
28 class ClangTidyContext;
63 DiagnosticsEngine::Level
Severity = DiagnosticsEngine::Note;
77 llvm::SmallVector<TextEdit, 1>
Edits;
125 void BeginSourceFile(
const LangOptions &Opts,
const Preprocessor *)
override;
130 using DiagFixer = std::function<std::vector<Fix>(DiagnosticsEngine::Level,
132 using LevelAdjuster = std::function<DiagnosticsEngine::Level(
142 void flushLastDiag();
146 std::vector<Diag> Output;
147 llvm::Optional<LangOptions> LangOpts;
148 llvm::Optional<Diag> LastDiag;
149 llvm::Optional<FullSourceLoc> LastDiagLoc;
150 bool LastDiagOriginallyError =
false;
152 llvm::DenseSet<std::pair<unsigned, unsigned>> IncludedErrorLocations;
153 bool LastPrimaryDiagnosticWasSuppressed =
false;
159 #endif // LLVM_CLANG_TOOLS_EXTRA_CLANGD_DIAGNOSTICS_H
DiagnosticsEngine::Level Severity
Represents a single fix-it that editor can apply to fix the error.
A code action represents a change that can be performed in code, e.g.
void BeginSourceFile(const LangOptions &Opts, const Preprocessor *) override
int getSeverity(DiagnosticsEngine::Level L)
Convert from clang diagnostic level to LSP severity.
std::function< std::vector< Fix >(DiagnosticsEngine::Level, const clang::Diagnostic &)> DiagFixer
enum clang::clangd::Diag::@2 Source
void HandleDiagnostic(DiagnosticsEngine::Level DiagLevel, const clang::Diagnostic &Info) override
std::function< DiagnosticsEngine::Level(DiagnosticsEngine::Level, const clang::Diagnostic &)> LevelAdjuster
bool DisplayFixesCount
If true, Clangd will add a number of available fixes to the diagnostic's message.
llvm::SmallVector< TextEdit, 1 > Edits
TextEdits from clang's fix-its. Must be non-empty.
DiagnosticCallback Diagnostic
std::string Message
Message for the fix-it.
void EndSourceFile() override
A top-level diagnostic that may have Notes and Fixes.
Every ClangTidyCheck reports errors through a DiagnosticsEngine provided by this context.
std::vector< Note > Notes
Elaborate on the problem, usually pointing to a related piece of code.
std::vector< Fix > Fixes
Alternative fixes for this diagnostic, one should be chosen.
llvm::raw_ostream & operator<<(llvm::raw_ostream &OS, const CodeCompletion &C)
llvm::Optional< std::string > AbsFile
CodeAction toCodeAction(const Fix &F, const URIForFile &File)
Convert from Fix to LSP CodeAction.
void contributeFixes(DiagFixer Fixer)
If set, possibly adds fixes for diagnostics using Fixer.
bool EmitRelatedLocations
If true, Clangd uses the relatedInformation field to include other locations (in particular attached ...
bool SendDiagnosticCategory
If true, Clangd uses an LSP extension to send the diagnostic's category to the client.
bool EmbedFixesInDiagnostics
If true, Clangd uses an LSP extension to embed the fixes with the diagnostics that are sent to the cl...
void toLSPDiags(const Diag &D, const URIForFile &File, const ClangdDiagnosticOptions &Opts, llvm::function_ref< void(clangd::Diagnostic, llvm::ArrayRef< Fix >)> OutFn)
Conversion to LSP diagnostics.
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
llvm::raw_string_ostream OS
StoreDiags collects the diagnostics that can later be reported by clangd.
Represents a note for the diagnostic.
void setLevelAdjuster(LevelAdjuster Adjuster)
If set, this allows the client of this class to adjust the level of diagnostics, such as promoting wa...
Contains basic information about a diagnostic.
std::vector< Diag > take(const clang::tidy::ClangTidyContext *Tidy=nullptr)