jak-project/lsp/protocol/document_symbols.cpp
Tyler Wilding 01c70368e3
LSP: initial LSP implementation for IR files to assist with decompilation (#1647)
* lsp: json-rpc example is working, a decent place to start...

* lsp: vendor library

* lsp: cleanup and time to get started

* lsp: commit what i got so far

* lsp: example `initialize` payload

* lsp: switch to `stdio`

* stash

* modularize the lsp implementation

* lsp: implement first actual LSP feature - function names in outline

* lsp: produce document diagnostics

* lsp: remove unused third-party lib

* lsp: support hovering MIPS instructions in IR files

* lsp: basic go-to all-types definition

* stash

* lsp: cleanup code, just need to add it to the release artifacts

* fix some project configuration

* fix linux build

* lsp: add lsp to PR artifacts and release assets

* lsp: address feedback
2022-07-18 18:26:57 -04:00

42 lines
1.2 KiB
C++

#include "document_symbols.h"
void LSPSpec::to_json(json& j, const DocumentSymbol& obj) {
j = json{{"name", obj.m_name},
{"kind", obj.m_kind},
{"range", obj.m_range},
{"selectionRange", obj.m_selectionRange}};
if (obj.m_detail) {
j["detail"] = obj.m_detail.value();
}
if (obj.m_tags) {
j["tags"] = obj.m_tags.value();
}
if (obj.m_children) {
j["children"] = obj.m_children.value();
}
}
void LSPSpec::from_json(const json& j, DocumentSymbol& obj) {
j.at("name").get_to(obj.m_name);
j.at("kind").get_to(obj.m_kind);
j.at("range").get_to(obj.m_range);
j.at("selectionRange").get_to(obj.m_selectionRange);
if (j.contains("detail")) {
obj.m_detail = std::make_optional(j.at("detail").get<std::string>());
}
if (j.contains("tags")) {
obj.m_tags = std::make_optional(j.at("tags").get<std::vector<SymbolTag>>());
}
if (j.contains("children")) {
obj.m_children = std::make_optional(j.at("children").get<std::vector<DocumentSymbol>>());
}
}
void LSPSpec::to_json(json& j, const DocumentSymbolParams& obj) {
j = json{{"textDocument", obj.m_textDocument}};
}
void LSPSpec::from_json(const json& j, DocumentSymbolParams& obj) {
j.at("textDocument").get_to(obj.m_textDocument);
}