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) {
45 std::vector<Diagnostic> LSPDiags;
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>{},
88 .message = N.format(),
91 auto Notes = D.notes();
92 auto DRange = Diag.
range;
100 .message = N.format(),
102 .relatedInformation =
103 std::vector<DiagnosticRelatedInformation>{
110 .message =
"original diagnostic",
117 .diagnostics = std::move(LSPDiags),
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)
lspserver::Range toLSPRange(llvm::StringRef Code, const nixf::LexerCursorRange &R)
llvm::SmallVector< lspserver::DiagnosticTag, 1 > toLSPTags(const std::vector< nixf::DiagnosticTag > &Tags)
Range range
The range at which the message applies.
std::optional< std::vector< DiagnosticRelatedInformation > > relatedInformation
static URIForFile canonicalize(llvm::StringRef AbsPath, llvm::StringRef TUPath)