aboutsummaryrefslogtreecommitdiff
path: root/lldb/unittests/Protocol/ProtocolMCPTestUtilities.h
blob: f8a14f4be03c918f42dd0eb0fe47d6a5ee8ac746 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#ifndef LLDB_UNITTESTS_PROTOCOL_PROTOCOLMCPTESTUTILITIES_H
#define LLDB_UNITTESTS_PROTOCOL_PROTOCOLMCPTESTUTILITIES_H

#include "lldb/Protocol/MCP/Protocol.h"
#include "llvm/Support/FormatVariadic.h"
#include "llvm/Support/JSON.h" // IWYU pragma: keep
#include "gtest/gtest.h"       // IWYU pragma: keep
#include <ostream>
#include <variant>

namespace lldb_protocol::mcp {

inline void PrintTo(const Request &req, std::ostream *os) {
  *os << llvm::formatv("{0}", toJSON(req)).str();
}

inline void PrintTo(const Response &resp, std::ostream *os) {
  *os << llvm::formatv("{0}", toJSON(resp)).str();
}

inline void PrintTo(const Notification &note, std::ostream *os) {
  *os << llvm::formatv("{0}", toJSON(note)).str();
}

inline void PrintTo(const Message &message, std::ostream *os) {
  return std::visit([os](auto &&message) { return PrintTo(message, os); },
                    message);
}

} // namespace lldb_protocol::mcp

#endif