10 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_DIAGNOSTICS_H 11 #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_DIAGNOSTICS_H 15 #include "clang/Basic/Diagnostic.h" 16 #include "clang/Basic/LangOptions.h" 17 #include "llvm/ADT/ArrayRef.h" 18 #include "llvm/ADT/STLExtras.h" 19 #include "llvm/ADT/StringSet.h" 45 DiagnosticsEngine::Level Severity = DiagnosticsEngine::Note;
49 bool InsideMainFile =
false;
58 llvm::SmallVector<TextEdit, 1>
Edits;
60 llvm::raw_ostream &
operator<<(llvm::raw_ostream &OS,
const Fix &F);
96 std::vector<Diag> take();
98 void BeginSourceFile(
const LangOptions &Opts,
const Preprocessor *)
override;
99 void EndSourceFile()
override;
100 void HandleDiagnostic(DiagnosticsEngine::Level DiagLevel,
101 const clang::Diagnostic &
Info)
override;
104 void flushLastDiag();
106 std::vector<Diag> Output;
107 llvm::Optional<LangOptions> LangOpts;
108 llvm::Optional<Diag> LastDiag;
114 #endif // LLVM_CLANG_TOOLS_EXTRA_CLANGD_DIAGNOSTICS_H
StoreDiags collects the diagnostics that can later be reported by clangd.
bool EmbedFixesInDiagnostics
If true, Clangd uses an LSP extension to embed the fixes with the diagnostics that are sent to the cl...
Contains basic information about a diagnostic.
CodeAction toCodeAction(const Fix &F, const URIForFile &File)
Convert from Fix to LSP CodeAction.
A code action represents a change that can be performed in code, e.g.
A top-level diagnostic that may have Notes and Fixes.
std::string Message
Message for the fix-it.
std::vector< Fix > Fixes
Alternative fixes for this diagnostic, one should be chosen.
llvm::SmallVector< TextEdit, 1 > Edits
TextEdits from clang's fix-its. Must be non-empty.
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.
int getSeverity(DiagnosticsEngine::Level L)
Convert from clang diagnostic level to LSP severity.
Represents a single fix-it that editor can apply to fix the error.
std::vector< Note > Notes
Elaborate on the problem, usually pointing to a related piece of code.
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
bool SendDiagnosticCategory
If true, Clangd uses an LSP extension to send the diagnostic's category to the client.
Represents a note for the diagnostic.
llvm::raw_ostream & operator<<(llvm::raw_ostream &OS, const CodeCompletion &C)