clang-tools 24.0.0git
LSPBinder.cpp
Go to the documentation of this file.
1//===--- LSPBinder.cpp - Tables of LSP handlers --------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#include "LSPBinder.h"
10#include "llvm/Support/Compiler.h"
11#include "llvm/Support/FormatVariadic.h"
12#include "llvm/Support/raw_ostream.h"
13
14namespace clang {
15namespace clangd {
16
17// Keep handleParseError out of every parse<T> instantiation.
18LLVM_ATTRIBUTE_NOINLINE llvm::Error LSPBinder::handleParseError(
19 const llvm::json::Value &Raw, llvm::StringRef PayloadName,
20 llvm::StringRef PayloadKind, const llvm::json::Path::Root &Root) {
21 elog("Failed to decode {0} {1}: {2}", PayloadName, PayloadKind,
22 Root.getError());
23 // Dump the relevant parts of the broken message.
24 std::string Context;
25 llvm::raw_string_ostream OS(Context);
26 Root.printErrorContext(Raw, OS);
27 vlog("{0}", OS.str());
28 // Report the error (e.g. to the client).
29 return llvm::make_error<LSPError>(
30 llvm::formatv("failed to decode {0} {1}: {2}", PayloadName, PayloadKind,
31 fmt_consume(Root.getError())),
33}
34
35} // namespace clangd
36} // namespace clang
FIXME: Skip testing on windows temporarily due to the different escaping code mode.
Definition AST.cpp:44
void vlog(const char *Fmt, Ts &&... Vals)
Definition Logger.h:72
void elog(const char *Fmt, Ts &&... Vals)
Definition Logger.h:61
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//