| 1 | //===-- ProtocolEvents.cpp ------------------------------------------------===// |
|---|---|
| 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 "Protocol/ProtocolEvents.h" |
| 10 | #include "llvm/Support/JSON.h" |
| 11 | |
| 12 | using namespace llvm; |
| 13 | |
| 14 | namespace lldb_dap::protocol { |
| 15 | |
| 16 | json::Value toJSON(const CapabilitiesEventBody &CEB) { |
| 17 | return json::Object{{.K: "capabilities", .V: CEB.capabilities}}; |
| 18 | } |
| 19 | |
| 20 | json::Value toJSON(const ModuleEventBody::Reason &MEBR) { |
| 21 | switch (MEBR) { |
| 22 | case ModuleEventBody::eReasonNew: |
| 23 | return "new"; |
| 24 | case ModuleEventBody::eReasonChanged: |
| 25 | return "changed"; |
| 26 | case ModuleEventBody::eReasonRemoved: |
| 27 | return "removed"; |
| 28 | } |
| 29 | llvm_unreachable("unhandled module event reason!."); |
| 30 | } |
| 31 | |
| 32 | json::Value toJSON(const ModuleEventBody &MEB) { |
| 33 | return json::Object{{.K: "reason", .V: MEB.reason}, {.K: "module", .V: MEB.module}}; |
| 34 | } |
| 35 | |
| 36 | } // namespace lldb_dap::protocol |
| 37 |
