loom
39 строк · 1.2 Кб
1#include "simodo/lsp-client/TextDocumentPositionParams.h"
2
3#include "simodo/inout/convert/functions.h"
4
5namespace simodo::lsp
6{
7bool parseTextDocumentIdentifier(const variable::Value & textDocument_value,
8TextDocumentIdentifier & textDocument)
9{
10if (textDocument_value.type() != variable::ValueType::Object)
11return false;
12
13const variable::Value & uri_value = textDocument_value.getObject()->find(u"uri");
14if (uri_value.type() != variable::ValueType::String)
15return false;
16
17textDocument.uri = inout::toU8(uri_value.getString());
18
19return !textDocument.uri.empty();
20}
21
22bool parseTextDocumentPositionParams(const variable::Value & params_value,
23TextDocumentPositionParams & documentPosition)
24{
25if (params_value.type() != variable::ValueType::Object)
26return false;
27
28std::shared_ptr<variable::Object> params_object = params_value.getObject();
29
30if (!parseTextDocumentIdentifier(params_object->find(u"textDocument"), documentPosition.textDocument))
31return false;
32
33if (!parsePosition(params_object->find(u"position"), documentPosition.position))
34return false;
35
36return true;
37}
38
39}
40