16using namespace llvm::json;
19void Controller::updateSuppressed(
const std::vector<std::string> &
Sup) {
21 std::lock_guard
_(SuppressedDiagnosticsLock);
23 SuppressedDiagnostics.clear();
27 for (
const auto &Name :
Sup) {
29 SuppressedDiagnostics.insert(*
DK);
37bool Controller::isSuppressed(nixf::Diagnostic::DiagnosticKind Kind) {
38 std::lock_guard
_(SuppressedDiagnosticsLock);
39 return SuppressedDiagnostics.contains(Kind);
42void Controller::publishDiagnostics(
43 PathRef File, std::optional<int64_t> Version, std::string_view Src,
44 const std::vector<nixf::Diagnostic> &Diagnostics) {
46 LSPDiags.reserve(Diagnostics.size());
51 if (isSuppressed(D.kind()))
55 std::string Message = D.format();
58 if (!D.fixes().empty()) {
60 if (D.fixes().size() == 1) {
61 Message +=
"fix available";
63 Message += std::to_string(D.fixes().size());
64 Message +=
" fixes available";
76 .relatedInformation = std::vector<DiagnosticRelatedInformation>{},
79 assert(
Diag.relatedInformation &&
"Must be initialized");
80 Diag.relatedInformation->reserve(D.notes().size());
88 .message =
N.format(),
91 auto Notes = D.notes();
100 .message =
N.format(),
102 .relatedInformation =
103 std::vector<DiagnosticRelatedInformation>{
110 .message =
"original diagnostic",
Convert between LSP and nixf types.
Diagnostic::DiagnosticKind DK
static std::optional< Diagnostic::DiagnosticKind > parseKind(std::string_view SName)
Parse diagnostic "cname" to diagnostic id.
Whether current platform treats paths case insensitively.
void elog(const char *Fmt, Ts &&...Vals)
int getLSPSeverity(nixf::Diagnostic::DiagnosticKind Kind)
bool fromJSON(const llvm::json::Value &Params, Configuration::Diagnostic &R, llvm::json::Path P)
lspserver::Range toLSPRange(llvm::StringRef Code, const nixf::LexerCursorRange &R)
llvm::SmallVector< lspserver::DiagnosticTag, 1 > toLSPTags(const std::vector< nixf::DiagnosticTag > &Tags)
URIForFile uri
The text document's URI.
static URIForFile canonicalize(llvm::StringRef AbsPath, llvm::StringRef TUPath)